1

クライアントの 1 つで magento ウェブショップを構成しています。それらにはカラーコードがあり、そのため、構成可能な製品をセットアップする必要があります。ただし、構成可能な製品が Web ショップに表示される前に、それに割り当てる属性を選択する必要があります...

+/- 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(); 
4

1 に答える 1