我已经多次使用过magento,但这是最终的挑战。我正在一家拥有400,000多种产品的magento商店工作,每个商店都有自己的变体/产品选项。我们的主商店(基于自定义购物车系统并在MSSQL上运行)每天添加和移除数百种产品。Magento - 动态产品/动态定价/即时创建产品
我已经配置的Magento抓住所有的类别,产品,文本,DESCRIPTIO,价格变化等,并在飞行中如http://www.offices-furniture.co.uk/pp?prod=mercury-reception-unit.html
的问题是我现在需要能够添加动态创建的产品页面这些产品到购物车没有他们物理存在的后端。我已经添加了一个产品到后端,并计划使用这个作为一个通用模板类型的产品,所以它总是将这个产品(变体)添加到购物车中,例如
http://www.offices-furniture.co.uk/frodo.php但我不能为我得到的价格改变.... grrrr ..
如果任何人都可以指出我在正确的方向如何通过前端的HTML或PHP更改价格,并将其张贴到购物车而不更改价格在后端
在此先感谢所有...
这里是我试过全光照的代码g改变价格;
<?php
require_once ("app/Mage.php");
umask(0);
Mage::app("default");
Mage::getSingleton("core/session", array("name" => "frontend"));
// get the current Magento cart
$cart = Mage::getSingleton('checkout/cart');
$product = Mage::getModel('catalog/product');
$product->setCustomPrice(99);
$product->setOriginalCustomPrice(99);
$product->getProduct()->setIsSuperMode(true);
$product->setTypeId('configurable');
$product->setTaxClassId(1); //none
$product->setSku(ereg_replace("\n","","videoTest2.2"));
$product->setName(ereg_replace("\n","","videoTest2.2"));
$product->setDescription("videoTest2.2");
$product->setPrice("129.95");
$product->setShortDescription(ereg_replace("\n","","videoTest2.2"));
$cart->save();
if(isset($_POST['submit'])){
// call the Magento catalog/product model
$product = Mage::getModel('catalog/product')
// set the current store ID
->setStoreId(Mage::app()->getStore()->getId())
// load the product object
->load($_POST['product']);
*/
////////////////////////////
// get the current Magento cart
$cart = Mage::getSingleton('checkout/cart');
$product = Mage::getModel('catalog/product')
// set the current store ID
->setStoreId(Mage::app()->getStore()->getId())
// load the product object
->load($_POST['product']);
$product->setCustomPrice(99);
$product->setOriginalCustomPrice(99);
$product->getProduct()->setIsSuperMode(true);
$product->setTypeId('configurable');
$product->setTaxClassId(1); //none
$product->setSku(ereg_replace("\n","","videoTest2.2"));
$product->setName(ereg_replace("\n","","videoTest2.2"));
$product->setDescription("videoTest2.2");
$product->setPrice("129.95");
$product->setShortDescription(ereg_replace("\n","","videoTest2.2"));
$cart->save();
/////////////////////////////////////
// start adding the product
// format: addProduct(<product id>, array(
// 'qty' => <quantity>,
// 'super_attribute' => array(<attribute id> => <option id>)
//)
//)
$cart->addProduct($product, array(
'qty' => $_POST['qty'],
'price' => 50,
'super_attribute' => array(key($_POST['super_attribute']) => $_POST['super_attribute'][525])
)
);
// save the cart
$cart->save();
// very straightforward, set the cart as updated
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
// redirect to index.php
header("Location: frodo.php");
}else{
?>
我不认为你可以改变价格这种方式......看看http://stackoverflow.com/questions/9721583/changing-the-price-in-quote-while-adding-product-到购物车,Magento的 –