| ||||||||||
Shopping cart software Solutions for online shops and malls | ||||||||||
|
X-Cart Home | FAQ | Forum rules | Calendar | User manuals | Login |
How to display products with a particular attribute | ||||
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
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!
__________________
X-Cart Business 5.0.12 |
|||||||
#2
|
|||||||||
|
|||||||||
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.
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
|
#3
|
|||||||
|
|||||||
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
__________________
X-Cart Business 5.0.12 |
|||||||
#4
|
|||||||||
|
|||||||||
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.
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
|
#5
|
|||||||||
|
|||||||||
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.
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! Last edited by tony_sologubov : 12-18-2014 at 03:48 AM. |
|||||||||
|
#6
|
|||||||
|
|||||||
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:
__________________
X-Cart Business 5.0.12 |
|||||||
|
#7
|
|||||||||
|
|||||||||
Re: How to display products with a particular attribute
Oh, yes, sure. You are right. Corrected my code.
__________________
Found a bug in X-Cart? Post it to our bug tracker! Know how to make X-Cart better? Suggest an idea! |
|||||||||
#8
|
|||||||
|
|||||||
Re: How to display products with a particular attribute
how to let x-cart gold 4.7.2 have this function?
__________________
x-cart gold 4.7.12 http://www.prescriptionglasses123.com/ http://www.glassespeople.com http://www.loupesusa.com http://www.eyeglassesclub.com |
|||||||
#9
|
|||||||
|
|||||||
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.
__________________
xcart 4.7 |
|||||||
#10
|
|||||||
|
|||||||
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.
__________________
https://www.ustradeent.com/ |
|||||||
|
|||
X-Cart forums © 2001-2020
|