Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Product Check On Status Disabled Or Active Rate Topic   - - - - -

 

Posted 09 December 2019 - 12:21 PM #1

Hi guys,

 

For a client we made a small adjustment in CS-Cart. We show in the subcategories overview the number of products from the category. See our code:

<ul>
        <li>
            {assign var="item_url" value="categories.view&category_id=`$item.category_id`"|fn_url}
                <a {if $item_url} href="{$item_url}"{/if} >
                {$item.category_id|fn_get_category_product_count}{$item.$name}  {if $addons.category_count.show_product_count} {/if}
                </a>    
        </li>
</ul>

Unfortunately now he shows the number of all products in the category. We also have products that are disabled. Is there a simple check for this?

 

Many Thanks!



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19982 posts

Posted 09 December 2019 - 01:37 PM #2

Please provide us with the code of the fn_get_category_product_count function


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)

 

Posted 16 December 2019 - 07:59 AM #3

Sorry for my late response. This is the function:

function fn_get_category_product_count($category_id)
{
    $count = db_get_field('select count(product_id) from ?:products_categories p inner join ?:categories c on p.category_id = c.category_id where c.id_path like ?s', '%' . $category_id . '%');

 



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 19982 posts

Posted 16 December 2019 - 01:10 PM #4

You should join ?:products table and add condition ?:products.status = 'A'


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 345     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 775     CS-Cart + YOUPI      USD 545      Multi-Vendor Ultimate       USD 7500 (6000)