A basic solution seems to be to set the url_key
column to the product name.
This will run through \Mage_Catalog_Model_Attribute_Backend_Urlkey_Abstract::beforeSave
which automatically formats the URL key properly (removing spaces and so on).
I would actually expect \Enterprise_Catalog_Model_Product_Attribute_Backend_Urlkey::beforeSave
to be used during the export, because we are on Enterprise, which is not the case.
Even if the Enteprise-only method would be called during import, this would not work, because it checks the database for duplicate URL keys - which is not yet updated during that stage of the import.
Solution: After importing, detect missing URL keys using:
$urlKeyMissing = Mage::getModel('catalog/product')->getCollection()
->addWebsiteFilter($website)
->addAttributeToFilter('url_key', array('null' => ''), 'left');
and update these products (load, setDataChanged, save).
In addition I am setting the following in the config.xml
of my import module (the standard import-export is disabling the URL key checks)
<global>
<importexport>
<import>
<catalog_product>
<attributes>
<url_key>
<backend_model>enterprise_catalog/product_attribute_backend_urlkey</backend_model>
</url_key>
</attributes>
</catalog_product>
</import>
</importexport>
</global>
Initially My CSV file was in ANSI encoding format. Saving the CSV file to UTF-8 encoding Solved the issue.
But after that when i import, i get errors on other categories. WHICH WAS DUE TO SPACING BETWEEN THE SLASHES SEPARATING THE CATEGORIES.
I Looked for the Case-sensitivity and fixed few and now all the products are imported, Even if my category name contains (-) (") and numbers.
Thank you.
Best Answer
After running the import you need to re-index the
Catalog URL Rewrites
index. This will generate URL's for your products.You can do so through the admin panel:
You can also reindex through a
SSH
session using theindexer.php
file located in/magento_root/shell