Incorrect "number of products"

  • Posts: 8
  • Thank you received: 0
12 years 7 months ago #47519

Hi,

Joomla version: 2.5.4
HikaShop version: 1.5.7

Here is the catalogue structure I use:

Category 1
-- Category 1.1
-- Category 1.1.1 (5 products here)
-- Category 1.1.2 (5 products here)
-- Category 1.2
-- Category 2.1.1 (5 products here)
-- Category 2.1.2 (5 products here)

I got an incorrect number of products at the first level (I'm talking about a category listing), I got this:

Category 1 (0)
-- Category 1.1 (0)
-- Category 1.2 (0)

Finally, at a second level, I got correct results:

Category 1.1 (10)
-- Category 1.1.1 (5)
-- Category 1.1.2 (5)

How can I change the query to make that the number of products across the categories is correct?

Sry for ma bad language,

Thx in advance

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 7 months ago #47681

Hi,

Try to download again the package from our website and install it again over your current hikashop. We made some changes which should avoid that.
If that doesn't solve the problem, please provide more information on how to reproduce the problem like screenshots of the options of your module/menu.

Please Log in or Create an account to join the conversation.

  • Posts: 8
  • Thank you received: 0
12 years 7 months ago #47822

Ok, thank you for your attention but my pb isn't solved.

In attachment #1 there is my products structure, there is no product in "POS" or "Industriel" but there are some products in "Câblé" or "Sans fil"

attachments #2 & #3 are what I currently see in front end





Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 7 months ago #47940

Please change the file administrator/components/com_hikashop/classes/category.php by the one in the archive enclosed and it should solve the problem.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 8
  • Thank you received: 0
12 years 7 months ago #47981

First, thx a lot for your help, the pb still not resolved :unsure:

Here is the reality in the back end:

Category 1: 0 object
Category 1.1: 0 object
Category 1.1.1: 1 object
Category 1.1.2: 2 objects
Category 1.2: 0 object
Category 1.2.1: 18 objects
Category 1.2.2: 8 objects
Category 2: 15 objects
Category 2.1: 4 objects

With the version 1 of category.php I had these results in the front end:

First level:
Category 1: 0 object (wrong)
Category 1.1: 0 object (wrong)
Category 1.2: 0 object (wrong)
Category 2: 19 objects (correct)
Category 2.1: 4 objects (correct)

Second levels are fine.

With the version 2 of category.php I had these results:

First level:
Category 1: 0 object (wrong)
Category 2: 19 objects (correct)
Category 2.1: 4 objects (correct)

Second levels are fine.

I want:

First level:
Category 1: 29 objects (count of all products in sub categories...)
Category 1.1: 3 object
Category 1.2: 26 object
Category 2: 19 objects
Category 2.1: 4 objects

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 7 months ago #48031

Sure I understand what you want. We don't have the problem anymore on our end with that file.
Are you sure that you uploaded it properly on your website ?

Please Log in or Create an account to join the conversation.

  • Posts: 8
  • Thank you received: 0
12 years 6 months ago #49136

Yeah I'm pretty sure :)

Can u tell me what modifications you made?

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 6 months ago #49209

I changed the code:

foreach($element as $k => $v){
					$element[$k]=(int)$v;
				}

				$filters[] = 'a.category_parent_id IN ('.implode(',',$element).')';
				$this->type=0;
to:
if($all){
					$this->database->setQuery('SELECT category_left,category_right FROM '.hikashop_table('category').' WHERE category_id IN ('.implode(',',$element).')');
					$leafs = $this->database->loadObjectList();
					$conditions = array();
					foreach($leafs as $v){
						$conditions[] = '(a.category_left > '.$v->category_left.' AND a.category_right < '.$v->category_right.')';
					}
					$filters[] = '('.implode(' OR ',$conditions).')';
					$this->type=0;
				}else{
					foreach($element as $k => $v){
						$element[$k]=(int)$v;
					}

					$filters[] = 'a.category_parent_id IN ('.implode(',',$element).')';
					$this->type=0;
				}
in that file.

Please Log in or Create an account to join the conversation.

  • Posts: 8
  • Thank you received: 0
12 years 6 months ago #49419

In category / listing_img_title.php

<span class="hikashop_category_name">
  <a href="<?php echo $link;?>">
    <?php
    echo $this->row->category_name;
    if($this->params->get('number_of_products',0)){
      echo ' (error here for category #33'.$this->row->number_of_products.')';
    }
    ?>
  </a>
</span>

What Defines number_of_products? Where is it defined?

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
12 years 6 months ago #49457

$this->params->get('number_of_products',0) comes from the option "Show the number of products" of the listing module.
$this->row->number_of_products is calculated in the file
omponents/com_hikashop/views/category/view.html.php

Please Log in or Create an account to join the conversation.

  • Posts: 8
  • Thank you received: 0
12 years 6 months ago #49468

SELECT count(a.product_id) AS number_of_products,a.category_id FROM #__hikashop_product_category AS a INNER JOIN #__hikashop_product AS b ON a.product_id=b.product_id AND b.product_published>0 WHERE a.category_id IN (29,30,31,32,33,35,46,47) GROUP BY a.category_id

Here is the result in mysql:
number_of_products	category_id
6	29
2	30
2	32
1	33
15	35
1	46
4	47

I debugged the file components/com_hikashop/views/category/view.html.php line #183 - #187

Note: in the id's, #47 is a sub category of #35 and results are fine but #31 has two sub categories (#38 & #39) and the results are going wrong (0)


Attachments:
Last edit: 12 years 6 months ago by pjaaar.

Please Log in or Create an account to join the conversation.

  • Posts: 8
  • Thank you received: 0
12 years 6 months ago #49472

So, I gave up.

I moved all the products in a new set of categories (the same structure as the first one :S ) & it works.

But thx for your time

Last edit: 12 years 6 months ago by pjaaar.

Please Log in or Create an account to join the conversation.

Time to create page: 0.097 seconds
Powered by Kunena Forum