积极的客户不在Magento工作

vie*_*ean 3 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 |
+-----------+----------------+------------------+------------+----------------------+----------+--------------+----------+---------------------+---------------------+-----------+
Run Code Online (Sandbox Code Playgroud)

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

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

但是,它不起作用.我怎么能解决它或者我错过了什么?

更新:

我可以得到这个客户的积极性.

$modelCustomer->getIsActive();//0
Run Code Online (Sandbox Code Playgroud)

调试:

当我显示日志时,我刚看到,我猜它没有更新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')
Run Code Online (Sandbox Code Playgroud)

小智 5

您需要创建静态属性的毛发客户实体,其名称与您创建的字段的名称相同.例如,您的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,
));
Run Code Online (Sandbox Code Playgroud)

如果您需要对此进行说明,可以调试保存过程.