catalogProductCreate in Magento API returning SQL error for configurable product

In: Feeling guru|Techie Daw

2 Nov 2016

It is common for companies with a huge product database to always have an ERP that manages their product updates. With an external service, it normally utilises the built-in Magento API. Calling the method catalogProductCreate using a SOAP service, one of the possible issues that may arise is the one below:

catalogProductCreate Error:

SQLSTATE23000: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`db`.`catalog_product_super_link`, CONSTRAINT `FK_CAT_PRD_SPR_LNK_PRD_ID_CAT_PRD_ENTT_ENTT_ID` FOREIGN KEY (`product_id`) REFERENCES `catalog_product_entity` (`entity_id`) ON DELETE CASCADE)

An empty url_key value causes the above issue. To fix it, make sure that the configurable product being created has a valid url_key. This is required for any product that is available on both catalog and search listings as shown below:

url_key field in catalogProductCreate SOAP request

Do not forget that a url_key needs to be unique because this is used to generate the hyperlink of the product.

About the author

Richard Feraro is a Magento Enterprise Certified developer from Manila, Philippines with 14 years of solid open-source development experience using Linux, Apache, MySQL & PHP.

Comment Form

About my blog

This blog is targeted towards all levels of developers and also designers. Various topics are discussed such as Magento, PHP & MySQL, jQuery, WordPress, CSS and HTML.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 5,249 other subscribers

WordPress + Magento



All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer or my mom.