Tags/topics: 
4
Answers
Vote up!
0
Vote down!

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.

Asked by: abiconsulting
on July 10, 2013

4 Answers

Vote up!
1
Vote down!

If I read you right, you're only deleting products and recreating them, right? It sounds to me like the product display node that referenced these deleted products is not itself being deleted, so a new node gets created on re-import that has a duplicate URL - which is the reason Pathauto would increment a number at the end of a URL.

Check on that and see if you shouldn't be deleting both products and product display nodes before re-importing.

Ryan Szrama
Answer by: Ryan Szrama
Posted: Jul 17, 2013
Vote up!
1
Vote down!

Hi Ryan,

How timely. I was running into the same issue. I tested a few things to confirm what you wrote and exactly how it was corrected. This is what I am doing, step-by-step.

1. All my products (I have thousands) have been imported, not manually created one-by-one. First the product variation import, followed by the product node import.

2. I delete the imported product nodes. This appears to also delete the product variations, because if I go to my product variation import after running the delete for my product nodes, a message displays "There are no Commerce Products to be deleted."

3. After making the fixes to my csv file, I then run my product variation import. A message displays, "Created 1000 commerce products.'

4. I run my product node import. A message displays, "Created 1000 nodes."

5. I checked my items and the last integer in the product URL has increased by "1".

6. Then I tried it in reverse. I deleted the product variations. When done, I deleted the product nodes (using the delete feature of the import user interface).

7. I re-ran my product variation import, followed by my product node import.

8. I checked my items and the last integer in the product URL did not change this time.

My issue now is that I've run this so many times, that the integer "3" is appearing after the dash. I can't seem to get back to "-0". Basically, I need to be able to delete ALL product variations and ALL product nodes for the category I am working with.

Any suggestions?

Thank you for your help on this!

Tom

Answer by: Thomas Isabelle
Posted: Jul 31, 2013
Vote up!
1
Vote down!

To clarify: Item # 6 "(using the delete feature of the import user interface for both product variation and product nodes)."

Tom

Answer by: Thomas Isabelle
Posted: Jul 31, 2013
Vote up!
1
Vote down!

I will volunteer the answer I discovered to my own question.

1. I deleted my products via http://mysite.com/admin/commerce/products/variations

2. I deleted all "content type" url aliases http://mysite.com/admin/config/search/path/delete_bulk

3. I re-generated the "content paths" at http://mysite.com/admin/config/search/path/update_bulk for all my non-product content.

4. I imported my products (product variations then product nodes).

5. Success! No '-integers' following my urls!

Tom

Answer by: Thomas Isabelle
Posted: Jul 31, 2013