1
我有這樣的代碼:magento自動產品添加工程,但如何添加下拉菜單值?
require_once('app/Mage.php');
Mage::app();
$product = Mage::getModel('catalog/product');
$product->setSku("productSKU");
$product->setAttributeSetId(9);
$product->setTypeId('simple');
$product->setName("Product name");
$product->setCategoryIds("2,3,4,5,6");
$product->setWebsiteIDs(array(0,1));
$product->setDescription("Mydesc");
$product->setShortDescription("mydesc2");
$product->setPrice(100);
$product->setWeight(5.00);
$product->setVisibility(4);
$product->setStatus(1);
$product->setTaxClassId(1);
$product->setStockData(array(
'is_in_stock' => 1,
'qty' => 10
));
$product->setCreatedAt(strtotime('now'));
$product->save();
和工作完美。
對接,現在我需要在這裏添加一個屬性,稱爲「tyretype」。 我在該屬性中添加了幾行下拉菜單,例如「100」,「101」,「102」。
現在,如果產品有tyretype = 101,我如何在該代碼中添加該值?
請幫忙,謝謝。
而我用magento 1.7運行。