View Single Post
  #1  
Old 07-11-2018, 05:56 AM
 
Soptareanu @Alex Soptareanu @Alex is offline
 

Advanced Member
  
Join Date: Apr 2018
Posts: 39
 

Default Pull product-variant attributes

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.
__________________
Soptareanu Alex
Reply With Quote