让我澄清一下上下文:
查看 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/