顧客が選択したオプションに基づいて価格を計算したい。たとえば、構成可能な属性が 2 つあります。length,width
商品をカートに入れる前に、選択した長さと幅に基づいて価格を変更したい
$finalPrice=$rrp+($length*$width)
これを達成するために利用できるイベントはありますか?
を参照してください。catalog_product_get_final_price使用例については、 を参照してくださいMage_CatalogRule_Model_Observer::processFrontFinalPrice()。オプションベースの価格設定は、このイベントの後に処理されることに注意してください。とを参照Mage_Catalog_Model_Product_Type_Price::getFinalPrice()してくださいMage_Catalog_Model_Product_Type_Configurable_Price::getFinalPrice()。
この機能をカスタマイズするには、さまざまな見積もりの状態、顧客の状態、製品タイプなどで多くのテストを行う必要があることに注意してください。たとえば、初めてカートに追加された製品をカートから更新するとします。 . 多くの場合、すべての順列を処理するために、いくつかのメソッド/オブザーバーにロジックを実装する必要があります。
顧客がログインしていない場合、新しいカート、単純な製品の場合に CE1.7 で発生するイベントの完全なリスト:
controller_front_init_routers
Mage_Cms_Controller_Router::initControllerRouters()controller_action_predispatch
Mage_Log_Model_Visitor::initByRequest()Mage_PageCache_Model_Observer::processPreDispatch()Mage_Persistent_Model_Observer::emulateQuote()Mage_Persistent_Model_Observer_Session::renewCookie()Mage_Persistent_Model_Observer::checkExpirePersistentQuote()Mage_Persistent_Model_Observer::emulateCustomer()catalog_product_load_after
Mage_CatalogInventory_Model_Observer::addInventoryData()custom_quote_process
Mage_Persistent_Model_Observer::setLoadPersistentQuote()sales_quote_config_get_product_attributes
Mage_SalesRule_Model_Observer::addProductAttributes()prepare_catalog_product_collection_prices
Mage_CatalogRule_Model_Observer::prepareCatalogProductCollectionPrices()sales_quote_item_collection_products_after_load
Mage_CatalogInventory_Model_Observer::addInventoryDataToCollection()sales_quote_item_qty_set_after
Mage_CatalogInventory_Model_Observer::checkQuoteItemQty()sales_quote_collect_totals_before
Mage_Tax_Model_Observer::quoteCollectTotalsBefore()sales_quote_address_collect_totals_before
Mage_Sales_Model_Observer::changeQuoteCustomerGroupId()sales_quote_address_collect_totals_after
Mage_Sales_Model_Observer::restoreQuoteCustomerGroupId()sales_quote_address_collect_totals_before
Mage_Sales_Model_Observer::changeQuoteCustomerGroupId()catalog_product_get_final_price
Mage_CatalogRule_Model_Observer::processFrontFinalPrice()sales_quote_address_collect_totals_after
Mage_Sales_Model_Observer::restoreQuoteCustomerGroupId()sales_quote_collect_totals_after
Mage_Sales_Model_Observer::setQuoteCanApplyMsrp()sales_quote_save_before
Mage_Persistent_Model_Observer::setQuotePersistentData()sales_quote_save_after
Mage_Checkout_Model_Observer::salesQuoteSaveAfter()Mage_Log_Model_Visitor::bindQuoteCreate()sales_quote_item_save_before
Mage_Reports_Model_Event_Observer::checkoutCartAddProduct()checkout_cart_add_product_complete
Mage_Wishlist_Model_Observer::processAddToCart()controller_action_postdispatch
Mage_Log_Model_Visitor::saveByRequest()controller_front_send_response_after
Mage_Persistent_Model_Observer_Session::synchronizePersistentInfo()