Я пытаюсь создать программный продукт с программируемым программным обеспечением. У меня проблема только с ценой за каждый атрибут размера. pricing_value всегда пуст в админ-панели. Вот та же проблема, но нет ответа Creating configurable products programmatically - pricing_value not saved Я использую Magento Community 1.9.1Программируемое создание настраиваемых продуктов/price_value empty
try {
$configProduct = new Mage_Catalog_Model_Product();
$configProduct->setSku('dp_' . strtotime('now'))
->setAttributeSetId(9)
->setTypeId('configurable')
->setName('Some cool product name')
->setCategoryIds(array(3))
->setWebsiteIDs(array(1))
->setDescription('Full description here')
->setShortDescription('Short description here')
->setPrice(39.99)
->setWeight(1.0000)
->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
->setStatus(1)
->setTaxClassId(0)
->setMediaGallery (array('images' => array(), 'values' => array()))
->addImageToMediaGallery($path, $mediaAttribute, false, false)
->setStockData(array(
'is_in_stock' => 1,
'qty' => 999,
'use_config_manage_stock' => 1,
'is_salable' => 1
))
->setCreatedAt(strtotime('now'));
$configProduct->setCanSaveConfigurableAttributes(true);
$configProduct->setCanSaveCustomOptions(true);
$configProduct->getTypeInstance()->setUsedProductAttributeIds(array(132)); //attribute ID of attribute 'size' in my store
$configurableAttributesData = $configProduct->getTypeInstance()->getConfigurableAttributesAsArray();
$configProduct->setConfigurableAttributesData($configurableAttributesData);
$configurableProductsData = array();
$configurableProductsData['10'] = array(
'0' => array(
'label' => (string)Mage::getModel('catalog/product')->load(10)->getName(),
'attribute_id' => '132', //attribute ID of attribute 'size' in my store
'value_index' => '3', //value of 'X' index of the attribute 'size'
'is_percent' => false, //fixed/percent price for this option
'pricing_value' => '21.00' //value for the pricing
)
);
$configurableProductsData['11'] = array(
'0' => array(
'label' => (string)Mage::getModel('catalog/product')->load(11)->getName(),
'attribute_id' => '132', //attribute ID of attribute 'size' in my store
'value_index' => '4', //value of 'XL' index of the attribute 'size'
'is_percent' => false, //fixed/percent price for this option
'pricing_value' => '21.00' //value for the pricing
)
);
$configProduct->setConfigurableProductsData($configurableProductsData);
$configProduct->save();
$createdProductUrl = Mage::getModel('catalog/product')->loadByAttribute('sku', $configProduct->getSku())->getUrlPath();
echo json_encode(array("createdProductUrl"=>"http://magento.dev/index.php/test/" . $createdProductUrl));
} catch (Exception $ex) {
echo $ex->getMessage();
}
может быть необходимо определить базовую валюту? – user3162709