| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
Product Filters - only show values for products in current category | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
Product Filters - only show values for products in current category
Hello,
When on a category page, is it possible to only show those attributes in the filter list which have products in the currently displayed category. This would avoid a long list of attribute values being shown, which will return a null result if selecetd (quite annoying for the customer). (perhaps in a similar way to the way the All Brands page only shows brands with products). Thanks, Jan
__________________
Jan Beesley (Currently Xcart 5 Previously XCart Gold from 3.5....) |
|||||||
#2
|
|||||||||
|
|||||||||
Re: Product Filters - only show values for products in current category
You can use the following option:
http://awesomescreenshot.com/0a73ueu62e on the category details page in admin area. Please, let me know if it works for you.
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
#3
|
|||||||
|
|||||||
Re: Product Filters - only show values for products in current category
Thanks Tony,
I am using that option but the problem is this: I have a global Product Class called Brands. Lets say there are 50 brands listed. If I have a category, let's say Lighting. The products in Lighting are from say, 5 brands. In the brands filter I only want to see 5 brands (ie the ones attached to products in this category). At the moment it lists all the brands, which is not what I want. It's not a true filter of what is on the page... I feel this must be possible, but not sure how. Thanks, Jan PS. The Brands class needs to be global as each brand may have products in multiple categories. I can view all Brand products via the Brand page (courtesy of the ShopByBrand module).
__________________
Jan Beesley (Currently Xcart 5 Previously XCart Gold from 3.5....) |
|||||||
#4
|
|||||||||
|
|||||||||
Re: Product Filters - only show values for products in current category
I see. In this case, there is indeed a mod needed.
The method that returns widgets of product attributes is getAttributesList() in the \XLite\Module\XC\ProductFilter\View\Filter\AFilter \AttributeList class. You need to decorate this one, or better prepareAttributesList() that prepares widgets to display. In this method you will be able to sort attributes so that it displays only meaningful options. Please, let me know if it helps.
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
#5
|
|||||||
|
|||||||
Re: Product Filters - only show values for products in current category
Hello,
Sorry for delay in replying .... got drawn into something else ... can you give me a steer on how I can extract a product count for each attribute ... then I can decorate the class as you suggest to exclude those with a product count of zero. I have been looking at the code but am getting a bit befuddled. Thanks, Jan
__________________
Jan Beesley (Currently Xcart 5 Previously XCart Gold from 3.5....) |
|||||||
#6
|
|||||||||
|
|||||||||
Re: Product Filters - only show values for products in current category
Well, I would be happy to give you a hand in this task, but I need some time to deal with other dev docs. Will it be OK for you to wait for ~month, so I could describe the process in dev docs and then share it with you?
Tony.
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
#7
|
|||||||
|
|||||||
Re: Product Filters - only show values for products in current category
Thanks for your reply ... I need to crack this one this week sadly.
I am thinking of looking at the way the category filter works and see if I can use any of that code to basically find out if each attribute option has any products in the given category. Any suggestions gratefully received.... Jan
__________________
Jan Beesley (Currently Xcart 5 Previously XCart Gold from 3.5....) |
|||||||
#8
|
|||||||
|
|||||||
Re: Product Filters - only show values for products in current category
What I am basically trying to do is run this SQL query for each attribute option ... passing in the
category id (of the page we are on, example = 13) Attribute_option_id (of the option in question, example = 99) Code:
This query would return the number of products in this category for this attribute option (quite a handy thing to have anyway). I am guessing the best place of the code is as part of the getOptions() function in \XLite\Module\XC\ProductFilter\View\FormField\Sele ct\Attribute.php, but I'm not sure how this will get access to the category id, and also how to build that query in the new x-cart architecture ... Would really appreciate some help on this Tony if you can spare a few moments .... Jan
__________________
Jan Beesley (Currently Xcart 5 Previously XCart Gold from 3.5....) |
|||||||
#9
|
|||||||||
|
|||||||||
Re: Product Filters - only show values for products in current category
Hi Jan!
OK, here is an example of how to pull number of products based on the attribute_option_id and category: Code:
I assume that you will add this code to some .PHP script inside X-Cart folder. Please, try this out and let me know if it suits your needs. Tony.
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
#10
|
|||||||
|
|||||||
Re: Product Filters - only show values for products in current category
Thank you for this ..... I am just wondering where I should put it?
maybe in XLite\Module\XC\ProductFilter\View\Filter\Attribut eList, or at a lower level in \XLite\Module\XC\ProductFilter\View\FormField\Sele ct\Attribute (decorated versions obviously). Also, while I can get the option id, I'm not sure how to pass the category id through.... it exists as part of the Filter class, but when I've tried to access it at a lower level I get an error ... .... Thanks in advance .... Jan PS. I think this should be aprt of the core Product Filter functionality as otherwise it's not really filtering what's on the page .... if I come up with a solution (with your help!) I will publish it here for others to use..
__________________
Jan Beesley (Currently Xcart 5 Previously XCart Gold from 3.5....) |
|||||||
|
|||
X-Cart forums © 2001-2020
|