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.
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');
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:
- Magento Dataflow (standard import/export utility)
- Magento SOAP API
- Magento REST API
- 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
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.