VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Marttyn on January 26, 2018, 12:52:36 PM

Title: [BUG] Hidden category shown on breadcumb
Post by: Marttyn on January 26, 2018, 12:52:36 PM
Hi!
Im experiencing some issue i think it should not be the regular behaviour.
In my store i have "regular" categories, and "hidden" categories. The hidden categories are for backend administration purposes. I have one hidden category for every of my product suppliers. So i may have 5 products that i purchase to "Supplier 1", this 5 products have their regular category, and also the hidden category associated to that supplier. This way i can manage stock more easily. And when i need to purchase to one supplier, i can see all the products i purchase from them and also see the stock. This is the way ive found to manage purchasing.
Everything is correct... this are hidden categories, and dont show up in the frontend
But for example, when i create a stockable variant, the child product has a hidden category associated, but no "regular" category, otherwise the child would be shown in that category listing, and i only want to show the parent in the listing.
The problem is that that child shows the hidden category in the breadcrumb  :o
If i remove all categories from the child product, then its ok, and show the correct breadcumb path (the parent path).
Can anyone test this and see if it only happens to me or if its a bug?
Thanks!
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: Studio 42 on January 27, 2018, 17:22:54 PM
Is the "hiden" category published ?
It's only a bug, iif category is unpublished and not if you dont added links to menu.
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: Marttyn on January 27, 2018, 20:57:35 PM
Sure, my "hidden" categories are unpublished. Otherwise they would show in the categories module.
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: Studio 42 on January 27, 2018, 23:53:21 PM
Have you update VM ?
I dont see your virtuemart release in the post
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: Marttyn on January 28, 2018, 10:40:56 AM
I have v3.2.12
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: aftertaf on January 28, 2018, 10:43:06 AM
i've had this happen too... i changed my backend structure to avoid the issue, in the end...
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: Studio 42 on January 28, 2018, 15:53:49 PM
Here the solution
file JOOMLAROOT/administrator/components/com_virtuemart/models/category.php line 709
$select = 'SELECT '.implode(', ',self::joinLangSelectFields($langFields));
$joins = implode(' ',self::joinLangTables('#__virtuemart_categories','c','virtuemart_category_id','FROM'));

replace with
$select = 'SELECT c.published,'.implode(', ',self::joinLangSelectFields($langFields)) .' FROM #__virtuemart_categories as c ';
$joins = implode(' ',self::joinLangTables('#__virtuemart_categories','c','virtuemart_category_id'));


And
file JOOMLAROOT/components/com_virtuemart/views/productdetails/view.html.php line 210
$pathway->addItem(strip_tags(vmText::_($c->category_name)), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE));

replace with
if($c->published) {
$pathway->addItem(strip_tags(vmText::_($c->category_name)), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE));
}

 
And breacrumb cannot display published categories anymore ;)
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: Marttyn on January 28, 2018, 18:57:34 PM
Thanks friend for taking the time to check this!
Your mod "kind of fix" the problem, but there are still some other things that still remain unfixed. I think the whole multivariant solution its quite buggy and needs some improvement.
This still have problems (look at the picture):
1. Hidden category name still show on the name of the site
2. URL becomes "broken" with 404 in the path
3. The product path in the breadcrumb is now in root, while it should be the parent path
4. Name of the product dont update when changing from one variant to the other

Regards!
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: Studio 42 on January 29, 2018, 02:29:12 AM
I know that you have other problems, what i don't understand is why published categories can be set in front(i have see comment about price rules that can use unpublished categories , but i think this is bad too).
MAx or other from dev teeam, can you fix this ? i don't want give 20 lines of core hack to reapply each Vm updates.

But how you can have 404 in the breadcrumb, if this is not set ?
Perhpas a solution is to use ordering and set your categories to higher level, or in another category not in root ?
Do you tested such tricks, so the canonical category is not the hidden one ?
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: Marttyn on January 29, 2018, 13:47:11 PM
I dont understand what you want me to try.
I have a parent category called "Suppliers", and children categories with the names of my suppliers. Just an example:
Suppliers
|_ Amazon
|_ Ebay
|_ Aliexpress

Both the parent and the children categories are hidden (unpublished). And i only apply one child category to each of my product so i know where to purchase them.
On regular products i also have other published categories added to them, but on child multivariant products i only have the hidden category.
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: Jörgen on January 29, 2018, 13:57:16 PM
I have also seen this issue. In my case using different calculation rules applied to categories. Assigning categories to a Child overrides the categories that otherwise are  inherited from the parent Product. It doesn´t add a new category it replaces the existing ones.

Couldn´t You assign a custom field that is hidden in the front end callied supplier ? You can create a nice drop down of suppliers to choose from.

regards

Jörgen @ Kreativ Fotografi
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: Studio 42 on January 29, 2018, 16:07:30 PM
@Jörgen, i think that he only want use this as filter in back-end, not front, currently VM have only filter category or manufacturer (and vendors).

It seems that VM do not override categories, if some are set in children because it not check if this are unpublished or not.
My trick was to remove the bug, but the problem is that product model do not check for unpublished categories set it in child(and perhaps in parent to ?) and not override it.

A solution, is to use vendor, but you have to manually modify all your products in shop and can give other issues in your case.

Title: Re: [BUG] Hidden category shown on breadcumb
Post by: Marttyn on January 29, 2018, 16:35:19 PM
Quote from: Jörgen on January 29, 2018, 13:57:16 PM
Couldn´t You assign a custom field that is hidden in the front end callied supplier ? You can create a nice drop down of suppliers to choose from.
In my case, a custom field will not give me a filter on the BE. I use the categories to group all the products from the same supplier. And when i have to order parts to one supplier, i can see all products from that supplier at the same time, and see the stocks for them, and also order other products that have low stock.

Quote from: Studio 42 on January 29, 2018, 16:07:30 PM
A solution, is to use vendor, but you have to manually modify all your products in shop and can give other issues in your case.
It wont be a problem to manually change all the vendors from my products if that solve the problem. And i wasnt doing it that way because my older template was showing the Vendor in the productdetails view. But my new template now doesnt show it, so maybe i can do that! Thanks Patrick!  :D

In any case, although i could solve the problem this way, the bug is still there.

Regards!
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: Milbo on January 29, 2018, 19:58:16 PM
The solution is to fix the problem, of course. But it is not soo easy to replicate it. I just tried and had no success. VM recognises the unpublished categories, except in some circumstances. I know I could reproduce the problem of Jörgen.

So in your case the problem is that the parent category is completly unpublished, or? btw, buying membership helps me to pay the time for the fix https://extensions.virtuemart.net/support/virtuemart-supporter-membership-silver-detail I looked already into it for Jörg, I also found some, but was not able todo the final fix, yet. There is imho no fast quickndirty solution.
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: Milbo on February 01, 2018, 11:43:08 AM
Please test this patch http://dev.virtuemart.net/projects/virtuemart/repository/diff?utf8=%E2%9C%93&rev=9755&rev_to=9754
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: Marttyn on February 05, 2018, 18:33:05 PM
Thanks Milbo!
I will consider a membership.
But unfortunately, when i saw the bug and no quick solution, i opted for the suggested method of giving a manufacturer to all of my products.
Anyway, i "recreated" a similar category structure, and all problems seems to dissapear except for this:
-unpublished category name appended to the page/tab name
-breadcrumb of the product is under root instead of the parent category
-SEF url has the same problem as the breadcrumb

The first problem can be solved changing /components/com_virtuemart/views/productdetails/view.html.php :
$document->setTitle(strip_tags(html_entity_decode(($category->category_name ? (vmText::_($category->category_name) . ' : ') : '') . $product->product_name,ENT_QUOTES)));
to this:
$document->setTitle(strip_tags(html_entity_decode(($category->category_name ? ($category->published ? (vmText::_($category->category_name) . ' : ') : '') : '') . $product->product_name,ENT_QUOTES)));

And I think the two last are not really problems, its the regular behaviour, as the product in fact dont have any published category... anyway, it would be better to keep the category of the parent for both the URL and the breadcrumb. Just a suggestion.
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: Milbo on February 06, 2018, 16:59:31 PM
I use now

$category = '';
if($category->published and !empty($category->category_name)){
$category = $category->category_name.': ';
}
$document->setTitle(strip_tags(html_entity_decode($category . $product->product_name,ENT_QUOTES)));


is nicer to read. The others are not really a problem and yes, there is imho even a method to get the prior category, but ... only when the product is in more than one category. We cannot list the product below the wrong category.
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: Marttyn on February 06, 2018, 17:24:19 PM
nice
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: aftertaf on February 06, 2018, 22:45:46 PM
hi,
will this make it into the next version in that case ? :)
Title: Re: [BUG] Hidden category shown on breadcumb
Post by: Studio 42 on February 06, 2018, 23:56:30 PM
Note that if you use shorten url, in product details the breadcrumb is empty and dont use the last visited category(nothing to do with this bug, but with breadcrumb).