dongquanlin1885 2012-11-27 23:47
浏览 13
已采纳

Magento从product_id(或entity_id)获取salesrule id

We are using Magento Enterprise 1.10 and I need a way to get the salesrule_id for each product on category pages as well as product detailed pages. This is pretty easy when you're using the cart.

Basically all I want to do is something like this --> Pseudo query

SELECT rule_id FROM salesrule WHERE entity_id = <entity_id)

Do you know of any way to do this outside of the cart. Is there a method I can call with a product id that return's a rule_id if it exists for this product?

Any suggestion would greatly help me.

  • 写回答

2条回答 默认 最新

  • dssu33392 2012-11-28 00:19
    关注

    A product does not have sales rules attached to it and there is no inbuilt method to load rules for a given product. On the cart page it is easy because the rule gets applied to the quote and on each item you can get applied_rule_ids which gives you the ids of any matched rules currently applied to the quote item which is not the same as a product object. So for example, you could have multiple sales rules which apply to the same item so applied_sales_rule_ids would give you all the applied rules not just one.

    You could try and load a collection of sales rules and add a filter on the product_ids column and then pass in the entity id of the product. This post here explores this with some code examples and may be of some help.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 在不同的执行界面调用同一个页面
  • ¥20 基于51单片机的数字频率计
  • ¥50 M3T长焦相机如何标定以及正射影像拼接问题
  • ¥15 keepalived的虚拟VIP地址 ping -s 发包测试,只能通过1472字节以下的数据包(相关搜索:静态路由)
  • ¥20 关于#stm32#的问题:STM32串口发送问题,偶校验(even),发送5A 41 FB 20.烧录程序后发现串口助手读到的是5A 41 7B A0
  • ¥15 C++map释放不掉
  • ¥15 Mabatis查询数据
  • ¥15 想知道lingo目标函数中求和公式上标是变量情况如何求解
  • ¥15 关于E22-400T22S的LORA模块的通信问题
  • ¥15 求用二阶有源低通滤波将3khz方波转为正弦波的电路