×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Jan Janssen
Added: Jun 12, 2014 9:11 AM
Views: 11
Tags: no tags
Loop all products and filter them based in the ruleset parameter
  1. protected function walkRecursiveRuleset($products, $rule, $isFirst = FALSE) {
  2.         if (!$isFirst) {
  3.             $products = $this->doCondition($rule, $products);
  4.         }
  5.         foreach ($rule["children"] as $child) {
  6.             if (!empty($child)) {
  7.                 $childProducts = $this->walkRecursiveRuleset($products, $child);
  8.                 foreach ($childProducts as $product) {
  9.                     $entityId = $product["entity_id"];
  10.                     $products[$entityId]["qty"] = $product["qty"];
  11.                 }
  12.             }
  13.         }
  14.         return $products;
  15.     }