Hi @
Soptareanu @Alex,
$model->getAttributeValueS() does not return an empty object. It returns collection of objects, so you should cycle through its child elements and call something like this:
Code:
foreach ($model->getAttributeValueS() as $attributeValue) {
$result = $result . ' ' . $attributeValue->asString();
}
See more in \XLite\Model\AttributeValue\AttributeValueSelect class.
Tony
Quote:
Originally Posted by Soptareanu @Alex
Is there a way to pull all attributes and options of each product-variant in Complex Schema. In order to do this task I use
PHP Code:
public function convertModel(\XLite\Model\AEntity $model, $withAssociations)
{
return array(
'id' => $model->getId(),
'sku' => $model->getSku(),
'productid' => $model->getProduct()->getProductId(),
'url' => $model->getProduct()->getFrontURL(),
'variantid' => $model->getVariantId(),
'disponibilitate' => $model->getDisponibility(),
'amout' => $model->getAvailableAmount(),
'price' => $model->price,
'string' => $model->getSomeString(),
'image' => $model->getProduct()->getImage()->url,
'variant_img' => $model->getImage(), // ??
'options' => $model->getAttributeValueS()
);
}
And the output is
PHP Code:
Array
(
[0] => stdClass Object
(
[id] => 1001
[sku] => SKU664314
[productid] => 12710
[url] => https://www.my-xcart.com/cart.php?target=product&product_id=12710
[variantid] => SKU66431-8c(1l
[disponibilitate] => 5
[amout] => 1
[price] => 0
[string] => Some String
[image] =>
[variant_img] =>
[options] => stdClass Object
(
)
)
As you can see, the getAttributeValueS() returns an empty object.
|