設定可能な製品の設定可能な属性を設定する際に問題があります。
設定可能でシンプルな製品が管理者側に表示されています。
しかし、私は、構成製品をクリックしたとき、私はこの
Magento PHP:設定可能な属性を製品に設定するにはどうすればよいですか?
を参照してください私は
Magento 'Select Configurable Attributes' with PHP を採掘に似て、この質問を見つけましたが、私はまだ私のconfig製品が正しく設定されて得ることができません。
私は私のクラスのMagentoProductを呼び出して、私の「setConfigurableAttributesData」メソッドに私の属性コードとして「color_of_product」を渡しています。
後で "save()"を呼び出して商品を保存します。
class MagentoProduct {
private $product;
public function __construct () {
Mage::init();
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$this->product = Mage::getModel('catalog/product');
}
...
...
...
public function setConfigurableAttributesData($attribute_code){
$super_attribute= Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product',$attribute_code);
$configurableAtt = Mage::getModel('catalog/product_type_configurable_attribute')->setProductAttribute($super_attribute);
$newAttributes[] = array(
'id' => $configurableAtt->getId(),
'label' => $configurableAtt->getLabel(),
'position' => $super_attribute->getPosition(),
//not 100% if values is correct, what do I set this to?
'values' => $configurableAtt->getPrices() ? $this->product->getPrices() : array(),
'attribute_id' => $super_attribute->getId(),
'attribute_code' => $super_attribute->getAttributeCode(),
'frontend_label' => $super_attribute->getFrontend()->getLabel(),
);
echo $configurableAtt->getId()."\n";
echo $configurableAtt->getLabel()."\n";
echo $super_attribute->getPosition()."\n";
//not 100% if values is correct, what do I set this to?
$temp = $configurableAtt->getPrices() ? $this->product->getPrices() : array();
echo $temp."\n";
echo $super_attribute->getId()."\n";
echo $super_attribute->getAttributeCode()."\n";
echo $super_attribute->getFrontend()->getLabel()."\n";
$this->product->setCanSaveConfigurableAttributes(true);
$this->product->setConfigurableAttributesData($newAttributes);
}
...
...
public function save(){
try{
$this->product->save();
}catch(Exception $e){
echo $e->getMessage();
Mage::log($e->getMessage());
}
}
}
私setConfigurableAttributesData機能でエコーが印刷されている:
カラー
アレイ
color_of_product
を色
私は間違っていますか?
私はこれを何時間もデバッグしようとしてきましたが、それを理解することはできません。