【发布时间】:2014-05-09 10:10:43
【问题描述】:
我使用下面的 Magento 安装程序脚本创建了一个自定义属性:
$installer = new Mage_Eav_Model_Entity_Setup();
$installer->startSetup();
$installer->addAttribute('customer', 'organisation_id', array(
'input' => 'select', //or select or whatever you like
'type' => 'int', //or varchar or anything you want it
'label' => 'Organisation ID',
'visible' => 1,
'required' => 0, //mandatory? then 1
'user_defined' => 1,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
));
$installer->endSetup();
在单页结帐屏幕上,我有一个下拉菜单,客户从下拉菜单中选择一个组织 - 一旦他们点击“继续”按钮,它就会发布一个 ajax 请求并进入下一步“计费”,例如发布请求看起来像这样..
org[organisation_id] - 12345
org[name] - ACME Inc
我处理此问题的函数如下 - 任何人都可以帮助如何将其添加到客户和订单对象中?
public function saveOrgAction()
{
if ($this->_expireAjax()) {
return;
}
if ($this->getRequest()->isPost()) {
$data = $this->getRequest()->getPost('org', array());
// todo:hook up saving the org id passed here to customer & order object
// UPDATE... I believe this is correct?
$customer = Mage::getSingleton('customer/session')->getCustomer(); // get customer object
$customer->setOrganisationId($org_id)->save();
if (!isset($result['error'])) {
$result['goto_section'] = 'billing';
}
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}
}
将此“organisation_id”属性添加到客户对象的最佳方法是什么(注意我使用的是 Magento 1.7.2)
【问题讨论】:
-
点击此链接可能对您有所帮助indiestechtips.wordpress.com/2011/07/30/…
-
我用我认为可能有用的东西进行了编辑
标签: magento model-view-controller frameworks e-commerce