我正在为我们的一个客户配置magento网络商店。他们有颜色码,因此我必须设置可配置的产品。但是,在可配置产品显示在网上商店之前,我需要选择一个属性来分配给它……
现在,如果我必须导入整个+/- 800产品目录,这真的很不方便……
我已经找到了下一个脚本,让它自动,但我不知道该把它放在哪里…我已经尝试过在configurable.php文件中使用它,但不起作用。请帮帮我!
foreach($configAttrCodes as $attrCode){
$super_attribute= Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product',$attrCode->code);
$configurableAtt = Mage::getModel('catalog/product_type_configurable_attribute')->setProductAttribute($super_attribute);
$newAttributes[] = array(
'id' => $configurableAtt->getId(),
'label' => $configurableAtt->getLabel(),
'position' => $super_attribute->getPosition(),
'values' => $configurableAtt->getPrices() ? $configProduct->getPrices() : array(),
'attribute_id' => $super_attribute->getId(),
'attribute_code' => $super_attribute->getAttributeCode(),
'frontend_label' => $super_attribute->getFrontend()->getLabel(),
);
echo "test ";
}
echo "test2 ";
if(empty($existingAtt) && !empty($newAttributes)){
$configProduct->setCanSaveConfigurableAttributes(true);
$configProduct->setConfigurableAttributesData($newAttributes);
$configProduct->save(); 发布于 2013-04-13 03:27:54
此脚本最适合用于将配置属性分配给产品的shell脚本。这不是完整的你。我不得不在这个脚本中添加了很多东西,比如向它提供产品ids的能力,以及与可配置属性一起配置的属性代码。
很难向你展示它遗漏了什么,因为你需要比这个脚本更多的东西来分配属性。我运行一个脚本来获取所有可配置产品的I,然后用它们创建一个缓存文件。我使用另一个脚本将这些I提供给上面的脚本,以便它可以对它们进行配置。所以总共有3个脚本。然后,我使用shell脚本来运行该进程。
这篇文章是由另一个用户发布的,目的是帮助你指明你需要的方向,但这绝不是一个独立的脚本。我可以把我的三个脚本的源文件通过电子邮件发送给你,你可以把它们倒过来看看我做了什么,如果有帮助的话。
https://stackoverflow.com/questions/12319858
复制相似问题