Hello,cheeseus wrote:Just adding that VettelS' code also works for OpenCart 2.0.2.0 and 2.0.3.1.
The only thing you need to be careful with is placing the code NOT immediately after the foreach loop opens, but after the second line of code inside it:This is necessary because the code uses the $product_info['product_id'] array element which isn't declared if the line above comes after the addition, which will trigger an error.Code: Select all
$product_info = $this->model_catalog_product->getProduct($product_id);
This is how your foreach loop should look:
Thank you, VettelS!Code: Select all
foreach ($products as $product_id) { $product_info = $this->model_catalog_product->getProduct($product_id); // Hack to create full path in the breadcrumbs for featured products $cat = $this->model_catalog_product->getCategories($product_id); if(!empty($cat)) { $cat_trace = array($cat[0]['category_id']); $i = 0; $stop = false; while(!$stop) { $arr = $this->model_catalog_category->getCategory($cat_trace[$i++]); if($arr['parent_id'] != 0) $cat_trace[] = $arr['parent_id']; else $stop = true; } $cat_trace = implode('_', array_reverse($cat_trace)); $link = $this->url->link('product/product', 'path=' . $cat_trace . '&product_id=' . $product_info['product_id']); } else { $link = $this->url->link('product/product', 'product_id=' . $product_info['product_id']); } // end hack if ($product_info) { .......
I've just tried this solution on version 2.0.3.1 however I'm getting the error
Code: Select all
Fatal error: Call to a member function getCategddories() on a non-object in C:\xampp\htdocs\opencart\catalog\controller\module\featured.php on line 39
Thanks,
Tom