View Single Post
  #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,431
 

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