【问题标题】:Magento: Apply Catalog Price Rule based on customer attributeMagento:根据客户属性应用目录价格规则
【发布时间】:2014-10-21 16:50:32
【问题描述】:

我搜索了自定义模块、事件和 CatalogRule 的代码库,但我不知道如何根据客户属性为产品设置价格。

唯一可用于过滤的客户属性是组,但是对于每个客户都有不同的规则,我需要为每个客户创建一个组...这不是一个好主意。

有没有办法做到这一点?除了产品属性之外,还要使用客户属性吗?

【问题讨论】:

  • 使用您自己的条件和客户属性以编程方式添加规则。如果这一切条件都满足,那么规则将被应用。看一看。 blog.chapagain.com.np/…
  • 抱歉,我不知道如何使用 catalogrule/rule 或 catalogrule/rule_condition_product 模型过滤客户属性。你能说得更具体点吗?

标签: magento attributes


【解决方案1】:

聚会很晚了,但无论如何我都会分享。这归结为遵守规则,然后注入条件。这是调度我们想要的事件的方法:

Mage_SalesRule_Model_Rule_Condition_Combine::getNewChildSelectOptions

事件……

Mage::dispatchEvent('salesrule_rule_condition_combine', array('additional' => $additional));

之后,您的观察者会注入一个新的 rule_condition 模型。

public function updateSalesRulesConditionsForCustomerAttributes(Varien_Event_Observer $observer)
{
    $customerCondition = Mage::getModel('company/rule_condition_customer');
    $customerAttributes = $customerCondition->loadAttributeOptions()->getAttributeOption();

    $attributes = array();

    foreach ($customerAttributes as $code=>$label) {
        $attributes[] = array('value'=>'company/rule_condition_customer|'.$code, 'label'=>$label);
    }

    $additional = $observer->getAdditional();
    $conditions = array(
        array('label'=>'Customer Attribute', 'value'=>$attributes)
    );

    $additional->setConditions($conditions);

    return $additional;
}

我写了一篇文章,展示了更多细节,包括规则模型和如何指定属性。看看:https://www.peakcollective.com/magento-1-9-sales-rule-condition-customer-attribute/

【讨论】:

  • 欢迎提供解决方案链接,但请确保您的答案在没有它的情况下有用:add context around the link 这样您的其他用户就会知道它是什么以及为什么会出现,然后引用最相关的您链接到的页面的一部分,以防目标页面不可用。 Answers that are little more than a link may be deleted.
  • 感谢您的提示。更新以提供更多详细信息和上下文。
  • 永远不会太晚...我不记得我是如何解决这个问题的,但我知道我从来没有找到像这样的真正解决方案。非常感谢。
猜你喜欢
  • 2014-06-18
  • 1970-01-01
  • 2011-05-26
  • 1970-01-01
  • 2014-06-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多