更新时间:2023-11-29 21:23:46
的这里是你如何创建自定义选项的产品属性的例子。它的工作原理相同的类别。
Here is an example of how you can create a product attribute with custom options. It works the same for categories.
只要改变这一点:
$this->addAttribute('catalog_product', 'provider', array(
这样:
$this->addAttribute('catalog_category', 'provider', array(
主要的想法是让该属性是与返回所有选项的方法的模型的自定义源。
The main idea is to give the attribute a custom source that is a model with a method that returns all the options.
要获得品牌属性的所有选项,这样做:
TO get all the options of brand attribute, do this:
$options = Mage::getModel('eav/config')->getAttribute('catalog_product', 'brand')->getSource()->getAllOptions();