【问题标题】:Magento individual customer catalog pricing ruleMagento 个人客户目录定价规则
【发布时间】:2015-09-22 14:23:53
【问题描述】:

我正在尝试以编程方式针对每个客户应用目录定价规则,但是我发现目录定价规则基于客户组,而不是单个客户。有谁知道这个问题的解决方案吗?

谢谢

【问题讨论】:

  • 这个模块是可用的,虽然我没有在任何项目上测试过,你可以试试看:magentocommerce.com/magento-connect/…
  • 谢谢,反正看起来是朝着正确方向迈出的一步,我会在代码周围戳一下
  • 嗯,实际上那个模块并没有真正的帮助,不过还是谢谢

标签: magento magento-1.9


【解决方案1】:

虽然您可能会找到一个可以做到这一点的扩展,但有一种方法可以使用 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;
    }
}

您可能必须使用一个表格来存储自定义价格和一个网格来从后端管理它,这是非常标准的,我不会在这里解释,但这应该可以帮助您入门。

【讨论】:

  • 这是我最后使用的方法,在看到这篇文章之前。不过,谢谢,这似乎是最好的答案,无需过度使用或购买插件
猜你喜欢
  • 2011-05-26
  • 1970-01-01
  • 1970-01-01
  • 2014-06-18
  • 1970-01-01
  • 2014-06-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多