Developer forum

Forum » PIM » Exporting Product URLs for Redirects to New Categories in DynamicWeb

Exporting Product URLs for Redirects to New Categories in DynamicWeb

Alex Guo
Reply

Hi everyone,

I'm currently working on an project with DynamicWeb as an intern, and I need to export product URLs for redirects to new categories. I've created a feed that transforms the data into CSV format, but I've run into a bit of a challenge.

It seems that the product URL is generated dynamically and can't be selected directly from the database by default. Does anyone have experience with this or know how to retrieve these URLs for the export?

Any help would be appreciated!


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Alex

A product does not have one URL - it can have several if the product is published multiple times on multiple websites - which is why they are not stored on the product

In your feed code from yesterday, you where looping through products and had a product viewmodel inside the loop. There is an extension method for the product viewmodel called GetProductLink() that takes a pageid.

Dynamicweb uses a page to publish your products - that page has an ID. Many Dynamicweb installations have more than one page where the products can be published to. Find the page in the content tree where your products are published, and get the ID:

This is DW10 - it is something similar in DW9.

The on your product you can do product.GetProductLink(149) and get back the link.

Ensure to add a @using Dynamicweb.Ecommerce.ProductCatalog in the top of the feed template to make the extension method available

 

You must be logged in to post in the forum