Magento 个人客户目录定价规则
Magento individual customer catalog pricing rule
我正在尝试以编程方式在每个客户的基础上应用目录定价规则,但我发现目录定价规则是基于客户组,而不是单个客户。有谁知道解决这个问题的方法吗?
谢谢
虽然您可能会找到执行此操作的扩展程序,但有一种方法可以使用 Magento 观察器来执行此操作。可能还有其他方法可以做到这一点,但这个方法在某种程度上相当简单。
创建一个模块,首先在config.xml配置一个abserver :
</global>
<events>
<catalog_product_load_after>
<observers>
<productloadhandle>
<type>singleton</type>
<class>Yourcompany_Customprices_Model_Observer</class>
<method>getCustomPrice</method>
</productloadhandle>
</observers>
</catalog_product_load_after>
<catalog_product_get_final_price>
<observers>
<getfinalpricehandle>
<type>singleton</type>
<class>Yourcompany_Customprices_Model_Observer</class>
<method>getCustomPrice</method>
</getfinalpricehandle>
</observers>
</catalog_product_get_final_price>
</events>
</global>
然后创建将实现 getCustomPrice
方法的观察者模型。
class Yourcompany_Customprices_Model_Observer extends Mage_Core_Model_Abstract
{
public function getCustomPrice($observer)
{
// If not logged in just get outta here
if (! Mage::getSingleton('customer/session')->isLoggedIn()) {
return;
}
$event = $observer->getEvent();
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
// THis is where you will want to have your price mechanism going on.
if (Mage::getSingleton('customer/session')->getCustomer()->getId() == $someIdFromCustomModuleTable) {
$product = $event->getProduct();
if ($product && null != $product->getSku()) {
// This is where you can tweak product price, using setPrice or setFinal
$product->setFinalPrice($customerPrice);
}
}
}
return $this;
}
}
您可能必须使用 table 来实现模块的其余部分以存储自定义价格,并使用网格从后端管理它,这是非常标准的,我不会在这里解释,但应该得到你开始了。
我正在尝试以编程方式在每个客户的基础上应用目录定价规则,但我发现目录定价规则是基于客户组,而不是单个客户。有谁知道解决这个问题的方法吗?
谢谢
虽然您可能会找到执行此操作的扩展程序,但有一种方法可以使用 Magento 观察器来执行此操作。可能还有其他方法可以做到这一点,但这个方法在某种程度上相当简单。
创建一个模块,首先在config.xml配置一个abserver :
</global>
<events>
<catalog_product_load_after>
<observers>
<productloadhandle>
<type>singleton</type>
<class>Yourcompany_Customprices_Model_Observer</class>
<method>getCustomPrice</method>
</productloadhandle>
</observers>
</catalog_product_load_after>
<catalog_product_get_final_price>
<observers>
<getfinalpricehandle>
<type>singleton</type>
<class>Yourcompany_Customprices_Model_Observer</class>
<method>getCustomPrice</method>
</getfinalpricehandle>
</observers>
</catalog_product_get_final_price>
</events>
</global>
然后创建将实现 getCustomPrice
方法的观察者模型。
class Yourcompany_Customprices_Model_Observer extends Mage_Core_Model_Abstract
{
public function getCustomPrice($observer)
{
// If not logged in just get outta here
if (! Mage::getSingleton('customer/session')->isLoggedIn()) {
return;
}
$event = $observer->getEvent();
if (Mage::getSingleton('customer/session')->isLoggedIn()) {
// THis is where you will want to have your price mechanism going on.
if (Mage::getSingleton('customer/session')->getCustomer()->getId() == $someIdFromCustomModuleTable) {
$product = $event->getProduct();
if ($product && null != $product->getSku()) {
// This is where you can tweak product price, using setPrice or setFinal
$product->setFinalPrice($customerPrice);
}
}
}
return $this;
}
}
您可能必须使用 table 来实现模块的其余部分以存储自定义价格,并使用网格从后端管理它,这是非常标准的,我不会在这里解释,但应该得到你开始了。