我们在某些订单限制下提供免费产品,超过Magento CE 1.7。
为了鼓励客户去购买更多,我们必须在购物车的页面上显示通知/警报,并在购物车上应用最近的促销活动。
我找到了一个类似的帖子,但这似乎是一个详尽的过程,因为它需要迭代所有购物车促销规则才能找到合适的规则:Read promotion rule condition - Magento
期待知道是否有任何可用的过滤器,以简化这一过程。
发布于 2013-05-29 01:06:56
发现几个过滤器,并在前面提到的解决方案之上构建:
$attr_match = sprintf('%%%s%%', substr(serialize(array('attribute' => 'base_subtotal')), 5, -1));
$type_match = sprintf('%%%s%%', substr(serialize(array('type' => 'salesrule/rule_condition_address')), 5, -1));
$opr_grt_match = sprintf('%%%s%%', substr(serialize(array('operator' => '>')), 5, -1));
$opr_grteq_match = sprintf('%%%s%%', substr(serialize(array('operator' => '>=')), 5, -1));
$collection = Mage::getResourceModel('salesrule/rule_collection')
->addWebsiteGroupDateFilter(Mage::app()->getWebsite()->getId(), $group_id)
->addFieldToFilter('main_table.coupon_type', Mage_SalesRule_Model_Rule::COUPON_TYPE_NO_COUPON)
->addFieldToFilter('main_table.conditions_serialized', array(
'like' => $attr_match,
))
->addFieldToFilter('main_table.conditions_serialized', array(
'like' => $type_match,
))
->addFieldToFilter('main_table.conditions_serialized', array(array(
'like' => $opr_grt_match
),array(
'like' => $opr_grteq_match
)))
;
$quote = Mage::getSingleton('checkout/session')->getQuote();
$applied_rules = $quote->getAppliedRuleIds();
if($applied_rules) {
$collection->addFieldToFilter('main_table.rule_id',array(
'nin' => explode(",", $applied_rules),
));
}
$rules = $collection->setOrder('main_table.sort_order', Varien_Data_Collection::SORT_ORDER_ASC)->load();期待评论,即兴发挥吧。
在我的博客上添加了一篇文章,提供了一个更具描述性的解决方案:Magento – Closest Promo Rule
https://stackoverflow.com/questions/16778341
复制相似问题