Reputation: 2547
I set the featured module to show 8 products. I loaded 16 products into the featured module. When I disable one of the products that is showing on the webpage, it does not replace it with an enabled product. So there is an empty spot on the webpage.
I am not sure how to fix this. I was looking in the catalog/controller/module/featured.php around line 24:
foreach ($products as $product_id) {
$product_info = $this->model_catalog_product->getProduct($product_id);
I am thinking to wrap this foreach with an if else statement something like:
If ($product is disabled) {
skip to next product
}
else {
foreach ($products as $product_id) {
$product_info = $this->model_catalog_product->getProduct($product_id);
...
...
...
}
I want to try something like this:
if ($product_id['status'] == 0) {
no idea here
}
else{
foreach ($products as $product_id) {
$product_info = $this->model_catalog_product->getProduct($product_id);
...
...
...
}
But again, not sure if if ($product_id['status'] == 0)
is correct, or even what to do with the products inside the if statement if it is.
Thanks.
Upvotes: 2
Views: 1080
Reputation: 1713
I see what you are saying. This is an oversight on the part of whoever wrote this module.
You need to filter disabled products before the limit is set, i.e.: in catalog/controller/module/featured.php
find this line:
$products = array_slice($products, 0, (int)$setting['limit']);
Before, add:
// filter out disabled products befor setting limit
foreach ($products as $k => $v){
$p_info = $this->model_catalog_product->getProduct($v);
if ($p_info['status']==0) {
unset ($products[$k]);
}
}
That's all. Good job on spotting this shortcoming by the way.
Upvotes: 3