VirtueMart Forum

VirtueMart 1.1.x [ Old version - no longer supported ] => Questions VM 1.1 ( the only active board for the old version) => Topic started by: 1gna753 on November 19, 2011, 15:41:51 pm

Title: Navigation class issue
Post by: 1gna753 on November 19, 2011, 15:41:51 pm
Hello World! :)

I am new at virtuemart so forgive basic questions.

Currently, I'm improving a Joomla site using Virtuemart.

On home page you can choose product categories on top menu and extra product filters on the left menu.
However, sometimes filtered results show differences between the amount of displayed products and the page navigation bar (1 | 2 | 3 | Next...)

(I'm still analyzing data base schema...but)
It seems it has 3 main tables to manage products and articles

Tables:
products --> stores product details
categories --> stores category details
product_categories_xref --> stores relationship between them

Here is the issue.
Current Template has a maximum of 4 rows by 4 columns (16) of displayed articles.
If you select a category and a filter from the left menu, like this:

Category = 1
Brand = X

It does not display any article (because there are non category 1 and brand X matches) BUT the page navigation bar shows 3 "blank" pages (1 | 2 | 3 | Next).
Why?
I think, it is because brand X matches 46 articles in general (not category 1; result of data base query), and navigation bar interprets that they must be organized in 3 pages.
It seams the query used to display articles is not the same to display navigation bar. ¿?

uff :-\

I got to the file --> ...\administrator\components\com_virtuemart\classes\pageNavigation.class.php

But again, it seems vmPageNav class receives the amount of articles to organized from somewhere where it is used.

Has anyone come accross with something like this?

Could you tell me if it is a good approach?

Joomla Version 1.5.14
VirtueMart 1.1.4

Thank you in advance.

1gna753
Title: Re: Navigation class issue
Post by: MikeUK on November 21, 2011, 17:56:01 pm
I think i have seen threads (or a thread) about the issue of article vs product display in Joomla / VM. I recommend seeing if you can find any other relevant  threads because you may need someone who has already experienced and solved this.
Title: Re: Navigation class issue
Post by: 1gna753 on November 23, 2011, 03:23:56 am
Thank MikeUK for your response.  :)

I analyzed a little bit more while I searched in threats, as you suggested.

I find out what is happening. Although is not fix yet... :(

when a category is selected from top_menu, the site shows all articles that match that category (good). BUT, when a filter belonging to that category is selected from the left_menu, the differences between pageNav and displayed articles begin (bad).

e.g. brand

You have brand "A" not only in category "1", but also in "2" and "3".

So if being at category "1", brand "A" filter is selected, where_clause is generated like this --> SELECT ... WHERE brand_id = 'A'
This returns all brand "A" matches (no category discrimination). That is why pageNav shows more pages because it shows ALL categories

I was able to find queries at shop_browse_queries.php file included in the shop.browse.php file.

The variables that keep queries are:

$list --> all articles data
$count --> number of query-result rows

Now, the thing is both queries have the same where clause.  :-\

My idea is that somewhere (in template code?) it is decided what articles to show/hide (based on something).
Would it  be enough to add same logic to $count (parameter to vmPage constructor as $total_rows)?

I will keep looking and re post.

Any ideas?

Thank you in advance.



Title: Re: Navigation class issue
Post by: 1gna753 on November 23, 2011, 16:02:00 pm
Hi again!  :)

The hypothesis was correct.

Finally, I found where it is the failure.

First, Data Base schema :

category table --> stores not only information about product type, but also product material, product brand, product color, etc...

( Is VirtueMart data base schema organized like this? ) ???

So, if a category and brand (or material, color, etc) filters are selected, a double query should be made.
First, all registers matching category and then, from result, all registers matching brand.

At shop.browse.php file where it starts to printing out all products, it is a while loop:

Code: [Select]
while ($db_browse->next_record())
{
   /* EACH PRODUCT */
   ...
}


Somewhere at while loop, a single-product-query returning all categories association is made.

If parent category ($cheat_cat) does not match any of them, a continue instruction is reached. (a loop jump)

This explains why pageNav shows several blank pages.


Two Issues:
1. Blank spaces generated for these loop jumps (where products go) should be avoided.

2. PageNav should show the right amount of pages.

Now, how can it be fixed?

Any ideas?

Thank you.

Greetings
Title: Re: Navigation class issue
Post by: 1gna753 on November 30, 2011, 22:45:02 pm
=== SOLVED ===  :)

I added a sub query (when it is necessary) to general-product query indicating that parent category ID should also be matched.

This automatically adjusted pageNave and blank spaces generated by loop jumps.

Regards.