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.


  • 1
    Why are you deleting the product, rather than updating it? – mpdonadio Jul 11 '13 at 2:50
  • In my case, we had to re-do the entire product database many times as we had trouble with Tamper, etc. I suppose I could have destructively re-imported, but it seemed like, "Hey, let's start from scratch" should have been the safer solution. So much for that. At this point, I think it works so we can just re-import/update. – djoyce Jul 12 '13 at 14:58

There are two ways:

  1. Don't delete them. Import them and let Feeds update them.

  2. 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' => 'node/' . $node->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.

  • I'll give this a try. You may be onto something. Here's my problem: the customer will, i'm afraid, periodically delete products then re-add them on import. Is there a way to stop this from happening? And, is there a way for me to remove and then recreate the aliases for only one Product (content?) type? – djoyce Jul 12 '13 at 2:25
  • This worked. Well, it worked halfway. I did as you said and removed all aliases for my content. Next I had to use Bulk Update (admin/config/search/path/update_bulk) to re-generate them. WAHOO! Thank you so much. If only I could vote up your answer, but alas, I'm too new. Now, is there a way to stop this from happening if the client deletes then re-imports a product? If not, I'll just tell them not to do it and only to flip the "Inactive" bit. – djoyce Jul 12 '13 at 2:33
  • @user19109 Well, updated my answer. And when it'll work for you, you can flip "accepted" flag. Worth more than upvote in terms of reputation, but also shows other users it actually worked so don't accept to fast. – Mołot Jul 12 '13 at 7:00
  • Marking as accepted as it gives a very good workaround and possibly a full solution. Gladly, I haven't had this trouble again, so maybe it was some bug that worked out? I'm not skilled enough to test your solution involving those hooks, so I'll have to bring someone in to do so if I cross this again. Thank you again. – djoyce Jul 12 '13 at 14:57

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.