我正在寻找在magento admin中添加类别下的新标签页,它会加载类别网格。想法是将多个类别关联到一个类别,并且在前端,当您单击该特定类别时,它应显示来自所有关联类别的产品。 有没有更好的解决方案然后创建一个带有类别网格的新标签页?
EDITTED
是的......我已经意识到我可以使用安装脚本在类别中添加新字段。现在在我的安装脚本中,我正在做这样的事情:
public function getDefaultEntities()
{
return array(
'catalog_category' => array(
'entity_model' => 'catalog/category',
'attribute_model' => 'catalog/resource_eav_attribute',
'table' => 'catalog/category',
'additional_attribute_table' => 'catalog/eav_attribute',
'entity_attribute_collection' => 'catalog/category_attribute_collection',
'attributes' => array(
'men_categories' => array(
'type' => 'int',
'backend' => '',
'frontend' => '',
'label' => 'Men Categories',
'input' => 'select',
'class' => '',
'source' => 'pushon_config/config_source',
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
'visible' => true,
'required' => false,
'user_defined' => true,
'default' => 0,
'searchable' => false,
'filterable' => false,
'comparable' => false,
'visible_on_front' => false,
'unique' => false,
'group' => 'Associated Categories',
),
),
),
);
}
在我的source.php中执行此操作:
class PushOn_Config_Model_Config_Source extends Mage_Eav_Model_Entity_Attribute_Source_Abstract
{ protected $ _options = array();
public function getAllOptions($withEmpty = true, $defaultValues = false)
{
$option = Mage::getResourceModel('catalog/category_collection');
foreach($option as $id){
$this->_options[] = array('value'=> $id->getData('entity_id'), 'label' => $id->getData('name'));
}
return $this->_options;
}
}
现在,当我运行它时,它会显示错误消息:
a:5:{i:0;s:163:"Error in file: "C:\wamp\www\vhosts\staging.domainname.com\httpdocs\app\code\local\PushOn\Config\sql\pushon_config_setup\mysql4-install-0.1.0.php" - Wrong entity ID.";i:1;s:1148:"#0 C:\wamp\www\vhosts\staging.domainname.com\httpdocs\app\code\core\Mage\Core\Model\Resource\Setup.php(390): Mage::exception('Mage_Core', 'Error in file: ...')
我只想加载所有类别。知道为什么会这样吗?