我已經多次使用過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的 –