我必须创建一个简单的Magento 1.6.x导入代理,以便创建/更新产品及其图像。有人能告诉我如何添加产品图像,而不必使用magento API?Magento以编程方式添加产品图像
API执行原来是非常差,我开始有点沮丧.. :-(
我发现关于这个问题的一些其他问题,但他们都不与添加图像涉及。产品
这是我想出了:
$product->setIsMassupdate(true)
->setExcludeUrlRewrite(true)
->setManufacturer($this->addManufacturers(utf8_encode($record[4])))
->setSku($record[3])
->setAttributeSetId($this->attribute_set)# 9 is for default
->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)
->setName(utf8_encode($record[5]))
->setCategoryIds($this->getCategories(array($record[0], $record[1], $record[2]))) # some cat id's,
->setWebsiteIDs(array(1)) # Website id, 1 is default
->setDescription(utf8_encode($record[6]))
->setShortDescription($this->shortText(utf8_encode($record[6]), 150))
->setPrice($price) # Set some price
->setSpecialPrice($special_price)
->setWeight($record[12])
->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)
->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)
->setTaxClassId(2) // default tax class
->setPixmaniaimg($record[10])
->setStockData(array('is_in_stock' => $inStock, 'qty' => $qty))
->setCreatedAt(strtotime('now'));
有人可以帮我直接添加图像,而不必将API
谢谢
Lukas
哪个版本的Magento? – benmarks
Magento 1.6 - 对不起,在我原来的评论中忽略.. – Bery
对于Magento 2:http://magento.stackexchange.com/questions/140612/magento-2-save-all-product-data-outside-magento-with -images –