Shopping Cart Price Rules For a grouped items - Magento 1.9 [duplicate]
-
09-10-2020 - |
Question
I want to create a price rule for a shopping cart that only to be activated when there are certain SKU placed in the cart.
For example. only if these 4 products sku1
, sku2
, sku3
, sku4
existed in the shopping cart at the same time, then a customer could have a fix amount discount for 100 USD for the whole cart.
Is this possible in Magento?
Solution
This is a bug in Magento core, that was fixed in version 1.9.3. If using an older version, you can try this fix: https://github.com/biotech/Magento1.9-CatalogPriceRulesFix or try this solution:
public function prepareConditionSql()
{
$alias = 'cpf';
$attribute = $this->getAttribute();
$value = $this->getValue();
$operator = $this->correctOperator($this->getOperator(), $this->getInputType());
if ($attribute == 'category_ids') {
$alias = 'ccp';
$attribute = 'category_id';
$value = $this->bindArrayOfIds($value);
}
// Andre Klang: This fixes issue with "is one of" & "is not one of"
if(!is_array($value) && in_array($operator,array('()','!()'))) {
$tmp = explode(',',$value);
foreach($tmp as $trim) $values[] = trim($trim);
$value = $values;
}
/** @var $ruleResource Mage_Rule_Model_Resource_Rule_Condition_SqlBuilder */
$ruleResource = $this->getRuleResourceHelper();
return $ruleResource->getOperatorCondition($alias . '.' . $attribute, $operator, $value);
}
Source: Catalog Price Rule containing several SKU-s doesn't work
Edit: To get a fast solution you can try this, as posted in the linked question:
ANY condition is TRUE
SKU "is one of" sku1
SKU "is one of" sku2
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange