magento - 活跃客户在 Magento 中不起作用

标签 magento

让我澄清一下上下文:

查看 customer_entity 表:

+-----------+----------------+------------------+------------+----------------------+----------+--------------+----------+---------------------+---------------------+-----------+
| entity_id | entity_type_id | attribute_set_id | website_id | email                | group_id | increment_id | store_id | created_at          | updated_at          | is_active |
+-----------+----------------+------------------+------------+----------------------+----------+--------------+----------+---------------------+---------------------+-----------+
|         1 |              1 |                0 |          1 | john.doe@example.com |        1 | 000000001    |        1 | 2007-08-30 23:23:13 | 2008-08-08 12:28:24 |         1 |
|         2 |              1 |                0 |          1 | vietean@gmail.com    |        1 |              |        1 | 2011-08-15 09:51:20 | 2011-09-06 07:31:17 |         0 |
+-----------+----------------+------------------+------------+----------------------+----------+--------------+----------+---------------------+---------------------+-----------+

客户的 id 为 2,is_active 属性为 0,现在我想更改为 1。

$customerId = 2;
$modelCustomer = Mage::getModel('customer/customer')->load($customerId);
$modelCustomer->setIsActive(1);
$modelCustomer->save();

但是,这不起作用。 我该如何修复它或者我遗漏了一些东西?

更新:

我可以获取该客户的IsActive。

$modelCustomer->getIsActive();//0

调试:

当我显示日志时,我刚刚看到,我猜它没有更新 is_active 属性:

UPDATE `customer_entity` SET `entity_id` = ?, `entity_type_id` = ?, `attribute_set_id` = ?, `website_id` = ?, `email` = ?, `group_id` = ?, `increment_id` = ?, `store_id` = ?, `created_at` = ?, `updated_at` = ? WHERE (entity_id='2')

最佳答案

对于毛皮客户实体,您需要创建与您创建的字段同名的静态属性。例如,您的 sql 安装程序可以是这样的:

$installer->getConnection()->addColumn($installer->getTable('customer_entity'), 'is_active', "TINYINT(2)");

$installer->addAttribute('customer', 'is_active', array(
'label'         => 'Active',
'type'          => 'static',
'visible'       => 1,
'required'      => 0,
'position'      => 1,
));

如果您需要对此进行解释,您可以调试保存过程。

关于magento - 活跃客户在 Magento 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7316592/

相关文章:

content-management-system - 在 Magento 中创建子 CMS 页面

jquery - Magento 可配置产品图像缩放问题

mysql - 未分类产品查询

php - AJAX 和 JSON 不起作用,没有错误或成功处理程序

html - 将 magento 可配置产品选项下拉列表转换为可选链接或单选按钮

Magento 从页脚链接中删除 SEO 术语和高级搜索

php - 付款被拒绝后恢复 magento 报价

mysql - sql 检索 magento 中的所有订单和产品详细信息

MySQL根据对应的ID向列中插入数据

javascript - Magento,如何在注册中添加条款协议(protocol)?