0

I am rewriting an import logic and figuring an ongoing issue where the data is not correctly stored alongside the configurable data. I'm trying to create/update products accordingly to the given data and save it into the database.

I'm iterating over previously generated data like this:

            $product->getTypeInstance()->setUsedProductAttributeIds([$this->getConfigurableAttributeId()]);

            $configAttribute = $product->getTypeInstance()->getConfigurableAttributesAsArray();
            foreach ($this->getConfigProductData() as $pId => $identifier) {
                $configAttribute[0]['values'][] = $identifier;
            }

            $product->setConfigurableAttributesData($configAttribute);
            $product->setConfigurableProductsData($this->getConfigProductData());
            $product->setCanSaveConfigurableAttributes(true);
            $product->setCanSaveCustomOptions(true);

After that, I do set other data, like Stock Data. Then I proceed to save the Configurable Product with $product->getResource()->save($product).

However, the product does not store the data at all. It does not even store the Attribute Id ($this->getConfigurableAttributeId() returns my attribute ID for the configurable product).

If I try to store it via $product->save() the same amount of data is stored (none). The product I'm trying to save has been loaded from a collection, not with a direct Magento Product, yet the same occours if I try to handle a product that I load directly via its ID.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.