i wish show module (e.g.: featured products) in empty category page (a category no products available).
i've been looking solution (with php or extension/mod), no success. thanks.
if exists extension or mod this
i never heard of such extension , don't think there extensions of type (anyway, have @ extensions store)
if not, way there enough
basically work 2 files:
category controller file:<oc_root>/catalog/controller/product/category.php
category view file:<oc_root>/catalog/view/theme/xxx/template/product/category.tpl
we need to:
(1) determine load module or not (in controller)
using simple if statement, can check if # of products in current category equals zero, can proceed constructing module, luckily have # of products in line: $product_total = $this->model_catalog_product->gettotalproducts($filter_data);
need check if $product_total == 0
(2) construct module html in proper way (in controller)
if opened controller, notice there line used execute controller , return it's output string, line is:
$this->load->controller('controller route')
can notice in same file:
$data['column_left'] = $this->load->controller('common/column_left');
so need copy line , use load module want (using module route module/featured case), however, modules in oc expect parameters passed index() function , won't work without it, don't panic :d, need open file makes use of modules (such common/column_left.php) , same, copied (with slight modification):
if ($this->config->get($module_code . '_status')) { $data['module_html'] = $this->load->controller('module/' . $module_code); } else { $this->load->model('extension/module'); $setting_info = $this->model_extension_module->getmodule($module_id); if ($setting_info) { $data['module_html'] = $this->load->controller('module/' . $module_code, $setting_info); } } values of $module_id , $module_code can found in table <db_prefix>_module, case be:
$module_id = 28; $module_code = 'featured'; (3) display module in page (in view)
check if value of $module_html set, display in container div
p.s: artice , provides excellent base develop code open cart 1.5.x, can used oc 2.x little modification, luck!
Comments
Post a Comment