我注意到,将商品从客户购物篮(左侧)移至订单(在“管理”区域->“管理>销售>新订单”中)时,产品价格不会超过客户组价格。因此,如果产品在客户购物篮中的价格为10.00英镑(这是特定的团体价格),而管理员将其移至订单上,则不会结转这10.00英镑的价格。篮子里的价格现在是15.00英镑(原价)
我在想解决此问题的最佳方法是创建事件观察器并在价格移至订单时更新价格?
答案 0 :(得分:0)
我设法通过为'sales_quote_add_item'adminhtml事件创建观察者来解决此问题。请看下面。希望这对某人有帮助
<?xml version="1.0"?>
<config>
<modules>
<Companyname_Extensionname>
<version>0.0.1</version>
</Companyname_Extensionname>
</modules>
<global>
<models>
<Companyname_Extensionname>
<class>Companyname_Extensionname_Model_Observer</class>
</Companyname_Extensionname>
</models>
</global>
<adminhtml>
<events>
<sales_quote_add_item>
<observers>
<companyname_extensionname>
<class>companyname_extensionname/observer</class>
<method>carttoorder</method>
</companyname_extensionname>
</observers>
</sales_quote_add_item>
</events>
</adminhtml>
</config>
<?php
class Companyname_Extensionname_Model_Observer {
public function carttoorder(Varien_Event_Observer $observer) {
$event = $observer->getEvent();
$quote_item = $event->getQuoteItem();
$product_sku = $quote_item->getSku();
$sessionquoteId = Mage::getSingleton('adminhtml/session_quote')->getQuote()->getId();
$sessionCustomerId = Mage::getModel('sales/quote')->loadByIdWithoutStore($sessionquoteId)->getCustomerId();
$customerData = Mage::getModel('customer/customer')->load($sessionCustomerId);
$customerId = $customerData->getGroupId();
$_product = Mage::getModel('catalog/product');
$_product->load($_product->getIdBySku($product_sku));
$groupPrices = $_product->getData('group_price');
if (!is_null($groupPrices) || is_array($groupPrices)) {
foreach ($groupPrices as $groupPrice) {
if($groupPrice['cust_group'] == $customerId){
$group_price = $groupPrice['website_price'];
break;
}
}
}
$quote_item->setOriginalCustomPrice($group_price);
$quote_item->getProduct()->setIsSuperMode(true);
}
}