gpt4 book ai didi

magento:从前端添加产品

转载 作者:行者123 更新时间:2023-12-02 13:47:20 25 4
gpt4 key购买 nike

任何人都可以帮助我了解如何从前端添加具有 Magento 中产品的大部分属性的产品吗?

提前致谢。

最佳答案

//$product = Mage::getModel('catalog/product');
$product = new Mage_Catalog_Model_Product();
//echo time();
// Build the product
$product->setAttributeSetId(9);// #4 is for default
$product->setTypeId('simple');

$product->setName('Some cool product name');
$product->setDescription('Full description here');
$product->setShortDescription('Short description here');
$product->setSku(time());
$product->setWeight(4.0000);
$product->setStatus(1);
$product->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);//4
//print_r(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH);

$product->setPrice(39.99);// # Set some price
$product->setTaxClassId(0);// # default tax class

$product->setStockData(array(
'is_in_stock' => 1,
'qty' => 99999
));

$product->setCategoryIds(array(27));// # some cat id's,

$product->setWebsiteIDs(array(1));// # Website id, 1 is default

//Default Magento attribute

$product->setCreatedAt(strtotime('now'));


//print_r($product);
try {
$product->save();
echo "Product Created";
}
catch (Exception $ex) {
//Handle the error
echo "Product Creation Failed";
}

我用过这个,效果很好。我也从一个网站找到了这个,但忘记了链接:(

关于magento:从前端添加产品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6675867/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com