How to do I stop product URLs changing each time I delete and re-import? Kickstart 2. I'm importing products using Feeds Importer. Every time I delete a product and re-import I get a sequential number appended to the end of the product's URL. For instance, I import MyProduct and its URL is mysite.com/products/MyProduct. I delete that product and import again and now the URL is mysite.com/products/MyProduct-0. Next time -1, etc.

I tested removing all products, truncating the commerce_product and commerce_product_revision tables and that didn't help.

So, how do I keep the URLs from changing? I'd prefer to fix the actual problem, not just use PathAuto or some other process afterwards to change the URLs.

Thanks.
There are two ways:


Don't delete them. Import them and let Feeds update them.
If you can't use above (for example no proper UUID on them), after node deletion, go to http://example.com/admin/config/search/path/delete_bulk and delete old aliases as well - that will free addresses for reuse.


Flipping "published" on and off is the way Drupal is designed to work, not deleting and re-uploading.
On the other hand, path module implements hook_node_delete() - hook called for each node deletion by node_delete_multiple() and node_delete() to delete aliases of deleted nodes. If it isn't, it's a core bug , or incompatibility between modules. You can fight to have it fixed, or try to implement hook_node_delete() on your own. Code of original implementation is very simple:

function path_node_delete($node) {
  // Delete all aliases associated with this node.
  path_delete(array('source' =&gt; 'node/' . $node-&gt;nid));
}


Of course to get it to work you may need to use some code from inside path_delete() to get query work properly, or to omit call to hook_path_delete() if one of it's implementation is buggy.