私は何度もmagentoを使ってきましたが、これは究極の挑戦です。私は、400,000 を超える製品を持つ magento ストアに取り組んでおり、それぞれに独自のバリエーション / 製品オプションがあります。マスター ストア (カスタム ショッピング カート システムに基づいており、MSSQL で実行されます) では、毎日何百もの商品が追加および削除されます。
すべてのカテゴリ、製品、テキスト、説明、価格、バリエーションなどを取得し、その場で動的に製品ページを作成するように magento を構成しました ( http://www.offices-furniture.co.uk/pp?prod=mercury-受付ユニット.html
問題は、バックエンドに物理的に存在することなく、これらの製品をショッピング カートに追加できるようにする必要があることです。バックエンドに 1 つの製品を追加し、これを GENERAL テンプレート タイプの製品として使用する予定です。そのため、常にこの製品 (そのバリエーション) がカートに追加されます。
http://www.offices-furniture.co.uk/frodo.phpしかし、私は一生、価格を変更することはできません.... grrrr ..
フロントエンドでHTMLまたはPHPを介して価格を変更し、バックエンドで価格を変更せずにショッピングカートに投稿する方法について、誰かが私を正しい方向に向けることができれば
よろしくお願いします…</p>
価格を変更するために使用しようとしたコードは次のとおりです。
<?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{
?>