Skip to content
Snippets Groups Projects
Commit 9211f997 authored by Reinhold Kainhofer's avatar Reinhold Kainhofer
Browse files

Finish evaluate_for_subcategories function

parent 46207f14
No related branches found
No related tags found
No related merge requests found
......@@ -336,6 +336,23 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework {
JPluginHelper::importPlugin('vmshipmentrules');
JDispatcher::getInstance()->trigger('onVmShippingRulesGetCartValues',array(&$values, $cart, $products, $method));
}
protected function getCategoryTreeRecursive($catmodel, $parent_category_id, &$categories) {
if ($catmodel->hasChildren($parent_category_id)){
// We need to call getCategories with vendorID=1, because the
// default "" will cause VM to check the current user for superuser
// access, which he usually does not have, and thus no child
// categories would be displayed.
$childCats = $catmodel->getCategories(/*$onlyPublished*/false,
$parent_category_id, /*child id*/false, /*$keyword*/"",
/*VendorID*/1);
foreach ($childCats as $key => $category) {
$categories[] = $category->virtuemart_category_id;
$this->getCategoryTreeRecursive($catmodel, $category->virtuemart_category_id, $categories);
}
}
}
/** Filter the given array of products and return only those that belong to the categories, manufacturers,
* vendors or products given in the $filter_conditions. The $filter_conditions is an array of the form:
......@@ -352,15 +369,9 @@ class RulesShippingFrameworkJoomla extends RulesShippingFramework {
$catmodel = VmModel::getModel('category');
foreach ($filter_conditions['subcategories'] as $catid) {
$subcategories[] = $catid;
// Get all child categories from the category model
$categories = $catmodel->getCategoryTree($catid,0,/*onlyPublished=*/false);
foreach ($categories as $subcat) {
$subcategories[] = $subcat->virtuemart_category_id;
}
$categories = $this->getCategoryTreeRecursive($catmodel, $catid, $subcategories);
}
$subcategories = array_unique($subcategories);
JFactory::getApplication()->enqueueMessage("<pre>Subcategories: ".print_r($subcategories,1)."</pre>", 'error');
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment