Hi guys,
this one is going to be a challenge:
First some background info:
We're working in a magento2 webshop and every now and then we need to redirect an old page to a new one.
Unfortunately, our magento database contains 10 different webshops and many of the redirects need to be created in every webshop.
The magento tool we are using can only create a redirect for one store at a time.
But there is also an import function that can do the trick at once for all stores.
I'm now looking for a way to quickly generate a redirect import file.
The aim is that the user inputs the breadcrumb (so everything after the main url) of the old and the new url on an imput sheet.
Once he is done adding these breadcrumbs the output needs to be generated.
I will illustrate with screenshots what I plan to do.
Here you see the imput sheet.
The user inputs the breadcrumbs for old and new and then selects in column C the combination of stores these breadcrumbs are valid for.
Workfile.jpg
The user then presses the button to generate the output.
This is where I need code to do the following:
The code needs to:
- find the first row in "Workfile" where columns A, B and C are populated (and C contains integers only) and
- store the values on that row as variables: (column A) "OldUrl", (column B) "NewUrl" in (column C) "StoreSelection" and the rownumber as variable "BreadcrumbRow",
- look up "StoreSelection" on row 1 of the sheet "StoreViews", take the first url underneith that number and store it's value as variable "WebshopUrl".
StoreViews.jpg- activate sheet "NewRedirects" and find the first empty row.
- set value in column A of that row to (concatenate "WebshopUrl" with "OldUrl")
- set value in column B of that row to (concatenate "WebshopUrl" with "NewUrl")
- Go back to "StoreViews" and check if there is another "WebshopUrl". If there is: repeat steps 3-6, if not, go to step 8.
- Go back to "Workfile" and find next row that complies with step 1 conditions. If there is: repeat steps 2-8, if not, end sub.
The following image shows what the output would be in "NewRedirects" if there would only be one line (line 6) in "Workfile"
NewRedirects.jpg
Can anybody help me with that?
Bookmarks