cancel
Showing results for 
Search instead for 
Did you mean: 

Configurable Product Attributes

SOLVED

Configurable Product Attributes

Hi everyone.

 

I try to add configurable product programically, but in some cases i can't make entry in catalog_product_super_attribute table.

 

My code:

 $attributeModel = $this->configurableAttributeFactory->create();
 $linked         = $attributeModel->getCollection()
                                    ->addFieldToFilter('attribute_id', $attributeId)
                                    ->addFieldToFilter('product_id', $configurable->getId())
                                    ->getSize();

if (!$linked) {
    $attributeModel->setData($data);
    $attributeModel->validateBeforeSave();
    $attributeModel->save();
    var_dump($attributeModel->getData());
}

After save var_dump returns primary_key for this entry, but the entry is not exists in the database table.

 

array(5) {
  ["attribute_id"]=> string(3) "146"
  ["product_id"]=> string(5) "98106"
  ["position"]=> int(0)
  ["product_super_attribute_id"]=> string(5) "36407"
  ["id"]=> string(5) "36407"
}

Do you have any suggestons?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Configurable Product Attributes

@Webcode It is recommend to use the Magento RSET API 

 

Fist create Simple product

 

https://devdocs.magento.com/guides/v2.3/rest/tutorials/configurable-product/create-simple-products.html

Then create Configurable product

 

https://devdocs.magento.com/guides/v2.3/rest/tutorials/configurable-product/define-config-product-options.html
Suman Kar(suman.jis@gmail.com) Magento Certified Developer Plus Skype: sumanphptech Problem solved? Please give 'Kudos' and accept 'Answer as Solution'.

View solution in original post

1 REPLY 1

Re: Configurable Product Attributes

@Webcode It is recommend to use the Magento RSET API 

 

Fist create Simple product

 

https://devdocs.magento.com/guides/v2.3/rest/tutorials/configurable-product/create-simple-products.html

Then create Configurable product

 

https://devdocs.magento.com/guides/v2.3/rest/tutorials/configurable-product/define-config-product-options.html
Suman Kar(suman.jis@gmail.com) Magento Certified Developer Plus Skype: sumanphptech Problem solved? Please give 'Kudos' and accept 'Answer as Solution'.