添加新值在Magento一个属性选项 [英] Add new values to a attribute option in magento

查看:168
本文介绍了添加新值在Magento一个属性选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要添加新值使用脚本,因为我有超过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,我用来执行正是这种任务。创建一个自定义模块(使用 ModuleCreator 作为一种工具),然后创建一个 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();    

在<详细信息文档href=\"http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/installing_custom_attributes_with_your_module\">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一个属性选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆