安装程序中有部分代码:
//this will set data of your custom attribute for root category
Mage::getModel('catalog/category')
->load(1)
->setImportedCatId(0)
->setInitialSetupFlag(true)
->save();
//this will set data of your custom attribute for default category
Mage::getModel('catalog/category')
->load(2)
->setImportedCatId(0)
->setInitialSetupFlag(true)
->save();
Run Code Online (Sandbox Code Playgroud)
这里有两个问题:
函数加载有一个参数.这是身份证.应该使用哪个表?
什么是setImportedCatId?这是它的制定者,但我没有说明它是什么.
Magento类别仍然使用EAV表结构,因此您感兴趣的表是
catalog_category_entity
Run Code Online (Sandbox Code Playgroud)
但是,您将无法在此处看到类别名称.类别对象的大多数数据都是持久化的
catalog_category_entity_varchar
Run Code Online (Sandbox Code Playgroud)
索引回到catalog_category_entity表中entity_id.
我在现代源代码树周围徘徊,它似乎是数据属性 imported_cat_id(这是setter可以设置的),但基于Magento系统中其他地方使用的模式,我的猜测是某些版本的Magento在类别保存树中有代码查找imported_cat_id,如果设置,新类别数据将基于旧类别.换句话说,它允许您快速复制类别并保存其所有元数据.通过将其设置为0,Inchoo代码告诉Magento这是一个新类别.
这只是猜测,但这不是我担心的事情.