我需要以编程方式读取 magento 中购物车价格规则的条件。
Mage_SalesRule_Model_Rule
有一个方法getConditionsSerialized()
它确实提供了条件,但至少以一种神秘的方式,如下所示:
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;}}}
有谁知道如何以更人性化的方式解读病情?我希望能够读取某些属性。
非常感谢!
Krt_马耳他
你可以使用php的反序列化 http://php.net/manual/en/function.unserialize.php函数将其转换为可用的数组。
尝试这个:
$conditions = unserialize($rule->getConditionsSerialized());
print_r($conditions);
我之前曾在博客中介绍过这些是如何工作的,虽然我的帖子是关于creating规则,它仍然解释了一些关于如何理解条件的信息。
这是我的帖子 http://mikebywaters.wordpress.com/2011/12/18/programmatically-create-shopping-cart-price-rules-with-conditions-and-actions/
希望能帮助到你!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)