| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Adding product attributes to minicart | |||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||
|
|||||||
![]() How can I list custom product attributes in my minicart? I currently have this code that lists the minicart products:
Code:
I cannot figure out how to list the item's attributes. I have tried the following lines unsuccessfully: Code:
Both {item.getAttributeValuesIds()} and {item.getAttributeValuesPlain()} print "Array" to the page. I know that the products in my cart have attributes. How can I list them? Thanks.
__________________
X-Cart version 5.2 |
|||||||
#2
|
|||||||||
|
|||||||||
![]() Actually, X-Cart already displays so-called "multi-value" product attributes in the minicart (those attributes that need to be chosen by the customer when adding the product to cart) - please see screen shot attached.
However, if you need something else, please clarify in details what are you trying to implemented, and provide your X-Cart store URL. Thank you.
__________________
Sincerely yours, Sergey Fomin X-Cart team Chief support group engineer === Check this out. Totally revamped X-Cart hosting http://www.x-cart.com/hosting.html Follow us: https://twitter.com/x_cart / https://www.facebook.com/xcart / https://www.instagram.com/xcart |
|||||||||
#3
|
|||||||
|
|||||||
![]() Seyfin,
I don't mean those types of multi-value attributes. I mean the attributes you can edit on the product edit page under "Attributes." For example, if I add a brand or a product number to my product, I'd like to be able to get those attributes (by key) in the minicart. I've attached a screenshot of what type of attributes I'm talking about. Thanks for the help!
__________________
X-Cart version 5.2 |
|||||||
#4
|
|||||||||
|
|||||||||
![]() You should iterate over the array returned by getAttributeValues() method and use the getActualValue() and getActualName() methods to get attribute names and values.
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful ![]() Click here to learn how to apply patches X-Cart Extensions |
|||||||||
#5
|
|||||||
|
|||||||
![]() That method, iterating over getAttributeValues(), is not what I need. That lists the product-specific attributes. What I want are the global attributes that are applied to the product.
I have a global field named "Part Number" that I want to have on each product, and I need to be able to programmatically retrieve it.
__________________
X-Cart version 5.2 |
|||||||
#6
|
|||||||||
|
|||||||||
![]() getAttributeValues() should return all attributes, including global attributes as well.
Each attribute should have getAttribute() method that returns \XLite\Model\Attribute model that you can check if it is a global attribute, or a per-class attribute (getProductClass() method), or a product-specific one (getProduct() method).
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful ![]() Click here to learn how to apply patches X-Cart Extensions |
|||||||||
|
#7
|
|||||||
|
|||||||
![]() I have still not been able to figure out how to list product attributes in the minicart.
I have expanded my experimentation to include this code: PHP Code:
However, NO attributes are being printed (global, class, or product-specific). I can call things like {item.getName()} and {item.getURL()}, and they return correct values. Help?
__________________
X-Cart version 5.2 |
|||||||
#8
|
|||||||||
|
|||||||||
![]() I'm not sure why it doesn't print attributes.
As far as I see your template iterates over items returned by \XLite\View\Minicart::getItemsList(). This method returns an array of \XLite\Model\OrderItem object, so you should be able to call any of its methods on "item" in your template. I see the getAttributeValues() and getAttributeValuesIds() methods in that class, but not getAttributesList(). Perhaps you should debug what these methods return to find out why it is empty for you.
__________________
Alex Solovev, Qualiteam --- User manual Video tutorials X-Cart FAQ You are welcome to press "Thanks" button if you find this post useful ![]() Click here to learn how to apply patches X-Cart Extensions |
|||||||||
|
|||
X-Cart forums © 2001-2020
|