[英]Magento product getFinalPrice for customer in custom script
对于某些客户群,我有一些目录价格规则。 以登录客户的身份查看产品时,价格会正确显示。 我想创建一个清单文件,可以将其发送给具有此折扣价的客户。 我该怎么做?
我尝试过的
在获取产品集合之前,为客户启动会话(使用Mage::getSingleton('customer/session')->loginById($customerId)
),但这似乎并没有影响$product->getFinalPrice()
。
编辑:我也应该说,我已经通过从会话中回显客户组ID来确认会话正常工作。
将产品添加到为该客户创建的sales/quote
,然后将价格从quote_item
但这也不起作用。
我跟随Mage_Catalog_Model_Product::getFinalPrice()
并找到了两个事件观察器Mage_CatalogRule_Model_Observer::processFrontFinalPrice()
和processAdminFinalPrice()
。 看来我应该能够在产品上设置客户组ID,所以我也尝试过这样做...祝您好运。 在processFrontFinalPrice()
确定客户组ID的逻辑如下所示:
if ($observer->hasCustomerGroupId()) { $gId = $observer->getEvent()->getCustomerGroupId(); } elseif ($product->hasCustomerGroupId()) { $gId = $product->getCustomerGroupId(); } else { $gId = Mage::getSingleton('customer/session')->getCustomerGroupId(); }
您检查方法头了吗? public function login($username, $password)
。 您不能将login()与customerId一起使用。
但是还有:
Mage::getSingleton('customer/session')->loginById($customerId);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.