function insertTreeProducts($category, $view, $focus) { $bean = new oqc_Product(); // get all products of the desired category // $products = $bean->get_full_list("", "relatedcategory_id='{$category->id}' and publish_state = 'published' and oqc_product.active=1 and is_latest=1 and is_option=0"); //1.7.6 extra conditions active and is_latest since produst are not deleted $products = $bean->get_full_list("", "relatedcategory_id='{$category->id}' and publish_state = 'published' and oqc_product.active=1 and is_latest=1 and is_option=0"); //2.2RC1 options as products causes logic troubles $productitems = array(); if (!empty($products)) { $productsArray = array(); $counter = range('a', chr(ord('a') + count($products) - 1)); foreach ($products as $product) { $productsArray[] = $product->toArray(true); } usort($productsArray, 'oqc_compare_catalog_position'); foreach ($productsArray as $productArray) { $optionitems = array(); if (!empty($productArray['optionssequence'])) { $options = get_all_linked_product_options_for_catalog($productArray['optionssequence']); $option_counter = range('1', count($options)); foreach ($options as $option) { $counter_string = $category->number . '.' . current($counter) . '.' . current($option_counter); $children = oqc_getOptionsArray($option->optionssequence, $counter_string, $view, $focus); $optionitems[] = array('key' => $option->id, 'title' => $view === 'DetailView' ? $counter_string . ' ' . $option->name : $option->name, 'children' => $children, 'isProduct' => false, 'isOption' => true, 'isFolder' => !empty($children) ? true : false, 'icon' => empty($children) ? 'Option_empty.gif' : 'Option_notempty.gif', 'description' => from_html($option->description), 'href' => $view === 'DetailView' ? oqc_getProductLink($option->id) : oqc_getProductEditLink($option->id, $focus)); next($option_counter); } } $productitems[] = array('key' => $productArray['id'], 'title' => $view === 'DetailView' ? $category->number . '.' . current($counter) . ' ' . $productArray['name'] : $productArray['name'], 'children' => $optionitems, 'isProduct' => true, 'isOption' => false, 'description' => from_html($productArray['description']), 'isFolder' => !empty($optionitems) ? true : false, 'icon' => empty($productArray['optionssequence']) ? 'Product_empty.gif' : 'Product_notempty.gif', 'href' => $view === 'DetailView' ? oqc_getProductLink($productArray['id']) : oqc_getProductEditLink($productArray['id'], $focus)); // $GLOBALS['log']->error("product catalog: ". var_export($productitems,true)); next($counter); } } return $productitems; }
function insertProducts(&$categories) { foreach ($categories as &$category) { $bean = new oqc_Product(); // $products = $bean->get_full_list("", "relatedcategory_id='{$category['id']}' and publish_state = 'published' and oqc_product.active=1 and is_latest=1 and is_option=0"); //1.7.6-2.0 extra conditions active and is_latest since produst are not deleted $products = $bean->get_full_list("", "relatedcategory_id='{$category['id']}' and publish_state = 'published' and oqc_product.active=1 and is_latest=1"); //2.1RC1 Options are shown in pdf file //2.0 arrange beans according catalog_position field if (!empty($products)) { usort($products, array('oqc_Product', 'oqc_product_compare_catalog_position')); } $category['products'] = $this->beansToArrayWithAttachements($products); $this->insertProducts($category['subCategories']); } }