How to display products with a particular attribute
Hi,
I would like to create a tab in the top menu to display products with a particular attribute. For instance: The site has these products: Bags (red and blue), wallets (red and green), shoes (red, green, blue) and pants (green and blue). I want to display only the products that have the attribute color='red' but I don't want to create a category 'red'. The tab in the top menu would be "RED PRODUCTS". Any idea how can I do it? Thanks! |
Re: How to display products with a particular attribute
This thread is about kind of what you need:
http://forum.x-cart.com/showthread.php?t=70512 Anyway, here is couple more things to consider: 1) If you want to pull products with attribute Color having value Red and these attributes are product-specific, you would call it like this: PHP Code:
2) If you need the same but for global attributes you would call it like this: PHP Code:
Please, let me know if it helps. |
Re: How to display products with a particular attribute
Hi Tony,
This is what I have done, however it does not work. It doesn't crash but renders a page with no products selected. My site has products which have a global attribute called "Vintage" with 2 possible options: "Yes" and "No", to describe if the particular product is considered vintage or not. What I am trying to do is to create a tab menu "VINTAGE" (target=vintage) to display all products that are Vintage. 1) I followed this tutorial http://kb.x-cart.com/display/XDD/Creating+new+page and created this file in <X-Cart>/classes/XLite/Module/MyID/MyModule/Controller/Customer/Vintage.php PHP Code:
2) I created XLite\Module\MyID\MyModule\Model\Repo\Product.php PHP Code:
3) I created the viewer class: <X-Cart>/classes/XLite/Module/MyID/MyModule/View/Page/Customer/Vintage.php PHP Code:
Any idea what am I doing wrong? Thanks |
Re: How to display products with a particular attribute
Could you please send me your mod packed? I will try to find what is wrong.
|
Re: How to display products with a particular attribute
I feel there is a problem with decorated version of \XLite\Model\Repo\Product class. It should be as follows:
PHP Code:
instead of yours: PHP Code:
As you can see, there are couple of changes: 1) I foreach $result and call getProduct() of each $attribute returned from the database. If you do not do this, your findAllVintage() method will return AttributeValue objects instead of products. 2) I moved constants $name and $value into a method instead of them being a part of class properties. Please, try my code and let me know if it works for you. If it does not, please give me a snapshot of how you set up a vintage attribute for a product. |
Re: How to display products with a particular attribute
Hi Tony,
It works perfectly now. Many thanks, you are a genius. just one small detail: where it says : PHP Code:
should be saying: PHP Code:
|
Re: How to display products with a particular attribute
Oh, yes, sure. You are right. Corrected my code.
|
Re: How to display products with a particular attribute
how to let x-cart gold 4.7.2 have this function?
|
Re: How to display products with a particular attribute
Quote:
Suppose i need attribute value of current product. How can i add condition here ? Please advise. |
Re: How to display products with a particular attribute
Hi my website is homebrandsusa will you please set it's products structure or tell me what should i have to do. For searching the solution on it i recently got an article that how to find the best selling products but really not know about products structure.
|
All times are GMT -8. The time now is 06:14 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.