阅读晋升规则条件-Magento [英] Read promotion rule condition - Magento

查看:56
本文介绍了阅读晋升规则条件-Magento的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要以编程方式阅读magento中购物车价格规则的条件.

I need to read the condition of a shopping cart price rule in magento programatically.

Mage_SalesRule_Model_Rule的方法getConditionsSerialized()确实提供了条件,但以一种隐秘的方式,至少可以说如下:

Mage_SalesRule_Model_Rule has a method getConditionsSerialized() which does provide the conditions but in a cryptic manner to say the least such as the following:

a:7:{s:4:"type";s:32:"salesrule/rule_condition_combine";s:9:"attribute";N;s:8:"operator";N;s:5:"value";s:1:"1";s:18:"is_value_processed";N;s:10:"aggregator";s:3:"all";s:10:"conditions";a:1:{i:0;a:5:{s:4:"type";s:32:"salesrule/rule_condition_address";s:9:"attribute";s:13:"base_subtotal";s:8:"operator";s:2:">=";s:5:"value";s:1:"1";s:18:"is_value_processed";b:0;}}}

有人知道如何以更人性化的方式阅读病情吗?我希望能够读取某些属性.

Does anyone know how to read the condition in a more humane way plz? I'd like to be able to read certain attributes.

感谢一堆!

马耳他(Krt_Malta)

Krt_Malta

推荐答案

您可以使用php的 unserialize 函数将其转换为可行的数组.

You can use php's unserialize function to convert this to a workable array.

尝试一下:

$conditions = unserialize($rule->getConditionsSerialized());
print_r($conditions);

我以前写过关于这些方法是如何工作的,尽管我的帖子是关于创建规则的,但仍在一定程度上说明了您如何理解条件.

I've blogged before about how these work, and while my post is about creating rules, it still explains a bit about how you might come to understand conditions.

这是我的帖子

希望有帮助!

这篇关于阅读晋升规则条件-Magento的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆