问题描述
我想要添加新值使用脚本,因为我有超过2000 manufactuers加快进程属性选项在Magento
I am trying to add new values to attribute option in magento using a script to speed up the process since I have over 2,000 manufactuers
推荐答案
下面是一块code,我用来执行正是这种任务。创建一个自定义模块(使用作为一种工具),然后创建一个 mysql4安装-0.1.0.php
下的SQL / modulename_setup文件夹中。它应该包含以下(改编当然你自己的数据!)。
Here is a piece of code that I used to perform exactly this task. Create a custom module (using ModuleCreator as a tool) and then create a mysql4-install-0.1.0.php
under the sql/modulename_setup folder. It should contain the following (adapted to your own data, of course!).
$installer = new Mage_Eav_Model_Entity_Setup('core_setup');
$installer->startSetup();
$aManufacturers = array('Sony','Philips','Samsung','LG','Panasonic','Fujitsu','Daewoo','Grundig','Hitachi','JVC','Pioneer','Teac','Bose','Toshiba','Denon','Onkyo','Sharp','Yamaha','Jamo');
$iProductEntityTypeId = Mage::getModel('catalog/product')->getResource()->getTypeId();
$aOption = array();
$aOption['attribute_id'] = $installer->getAttributeId($iProductEntityTypeId, 'manufacturer');
for($iCount=0;$iCount<sizeof($aManufacturers);$iCount++){
$aOption['value']['option'.$iCount][0] = $aManufacturers[$iCount];
}
$installer->addAttributeOption($aOption);
$installer->endSetup();
在Magento如果你想维基。
如果你不想做一个自定义模块,你可以只创建一个开头一个php文件:
If you don't want to do it in a custom module, you could just create a php file that starts with:
require_once 'app/Mage.php';
umask(0);
Mage::app('default');
这篇关于添加新值在Magento一个属性选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!