Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Retrieve product hidden attributes
 
Reply
   X-Cart forums > X-Cart 5 > Modifying the design and features (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 03-04-2019, 01:22 AM
 
amarquis amarquis is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 57
 

Default Retrieve product hidden attributes

In X-Cart 5, I can create hidden attributes for any product.

I have found this page https://devs.x-cart.com/basics/basics-of-working-with-product-attributes.html which explains how to retrieve product attributes. How can I retrieve hidden attributes for a given product? Everything I tried failed and I am unsure what to use. Thanks.
__________________
5.3.5.8
Reply With Quote
  #2  
Old 03-05-2019, 04:57 AM
 
amarquis amarquis is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 57
 

Default Re: Retrieve product hidden attributes

I would have the same question for global attributes too in fact as they don't seem to be returned either by the method described in the documentation. Would be nice to get an answer...
__________________
5.3.5.8
Reply With Quote
  #3  
Old 03-08-2019, 01:55 AM
 
amarquis amarquis is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 57
 

Default Re: Retrieve product hidden attributes

Thanks a lot for your contributions. Much appreciated!
__________________
5.3.5.8
Reply With Quote
  #4  
Old 04-24-2019, 04:01 AM
  tony_sologubov's Avatar 
tony_sologubov tony_sologubov is offline
 

X-Cart team
  
Join Date: Jan 2009
Posts: 2,417
 

Default Re: Retrieve product hidden attributes

Hi amarquis,

If you need to pull hidden attributes, you need to add the \XLite\Model\Attribute::TYPE_HIDDEN type to the following array mentioned in the https://devs.x-cart.com/basics/basics-of-working-with-product-attributes.html article

Code:
array( \XLite\Model\Attribute::TYPE_CHECKBOX, \XLite\Model\Attribute::TYPE_TEXT )

so it would become:

Code:
array( \XLite\Model\Attribute::TYPE_CHECKBOX, \XLite\Model\Attribute::TYPE_TEXT, \XLite\Model\Attribute::TYPE_HIDDEN )

As for global attributes, you need to write a function that would return such attribute values. If you plan on extending \XLite\Model\Product class, this function can look like this:

Code:
public function getGlobalAttributes() { $cnd = new \XLite\Core\CommonCell; $cnd->product = $this->getProductId(); $attributeValues = \XLite\Core\Database::getRepo('XLite\Model\AttributeValue\AttributeValueSelect')->search($cnd); $return = []; foreach ($attributeValues as $attributeValue) { if (is_null($attributeValue->getAttribute()->getProduct())) { $return[] = $attributeValue->asString(); } } return $return; }

Tony
__________________
Found a bug in X-Cart? Post it to our bug tracker!
Know how to make X-Cart better? Suggest an idea!
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Modifying the design and features (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 11:16 AM.

   

 
X-Cart forums © 2001-2018