Has anyone tried importing products from another store and keeping the same ID? I'm not sure how to do identity inserts with Magento. I'm sure there has to be a way.

  • I don't think there is a way.. Can I ask you why you want to do this in the first place? – Erfan Feb 1 '13 at 3:25
  • Well, it'll make what I have to do a whole lot easier since I'll be pushing data between two systems. – jstrez77 Feb 1 '13 at 3:27
  • How are you currently planning on importing the products? Also I am assuming you are referring to the product_id. Are the foreign ids compatible with Magento's database column that stores the id (catalog_product_entity::entity_id), in other words is the ID always an integer of up to 10 digits? – Kristof at Fooman Feb 1 '13 at 8:26

This is specifically why SKU exists, so you don't rely on the autoincrement, primary key to do syncs between databases.

If you have no other way of identifying the products in the second database(aka non-magento one), you can use the ID from it as a SKU in the magento database.

But I don't think there are product databases that don't use sku's for identification of products.

PS: You can load/filter products by SKU just as easily as you can with ids.

// for example, to load a product with the sku "custom_sku"
$product = Mage::getModel('catalog/product')->load('custom_sku', 'sku');
  • I agree. Why would you need the increment_id to be the same? – ProxiBlue Feb 2 '13 at 18:52

It is possible - but the side-effects are not desirable. Basically, there are many afterSave() methods called after a new product is created (read: not updated). It is these functions that set up the required additional information in the DB (stocking, attribute, child/parent association, category assignation).

It is actually possible to set the product ID - and even make it look like it completed without error - but the reality is that further down the line; there'll be errors that cannot be explained - and it will fall on the initial import itself.

The ID really is merely for the database - not for the end user, this is why the SKU exists. You can easily keep stores in sync using the SKU - using any recognised method:

  1. Magento Dataflow (standard import/export utility)
  2. Magento SOAP API
  3. Magento REST API
  4. Aftermarket solutions (eg. uRapidFlow)

A good example is if you attempt the same process with categories; by programatically creating them and setting the ID simultaneously. The children_count parameter is overridden (event if explicitly set) by an afterSave() method.

Which allows the import to complete and for everything to see okay - but later breaks the conditional promotional rules category display. So then you are forced to run a MySQL fix to rectify it.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.