我正在为Magento开发一种定制的运输方式 . 对于此送货方式,我需要设置自定义产品属性(airfreight_allowed) . 送货方法检查所有产品的自定义属性是否设置为true .
我已经使用安装脚本添加了product属性:
$installer->addAttribute('catalog_product', 'airfreight_allowed', array(
'input' => 'select',
'source' => 'eav/entity_attribute_source_boolean'
...
));
在发货模块中,我访问这样的报价项:
foreach ($request->getAllItems() as $item) { /* Mage_Shipping_Model_Rate_request */
if($item->getAirfreightAllowed() != 1)
return false; /* Airfreight not allowed */
}
但报价项目不包含airfreight_allowed属性 . 如何将airfreight_allowed属性添加到报价项?如何确保此属性包含相应产品属性的值?
1 回答
将其添加到模块的config.xml中:
将属性的属性“在产品列表中使用”设置为true .
然后你可以像这样访问属性: