Sometimes you need to redirect from Product pages to Collection pages.
We recently did an ecommerce website migration from WooCommerce to Shopify.
The old WooCommerce website had thousands of products, with many product categories.
On the new Shopify website, they had a few hundred products, with the same product Collections (product categories are called ‘Collections’ in Shopify).
So we decided to create “301 Redirects” from WooCommerce product pages to Shopify Collection pages.
We created a redirect script with this logic:
- On product page, get product’s category
- Find product category ‘slug’ (which is the short url of the category)
- Redirect to new website using category slug
This assumes that the url of Product Categories on old WooCommerce website is the same as the ‘slug’ of the Collection on the new Shopify website.
<?php //setup redirect for product pages - to relevant category page on new website if ( is_product() ){ global $post; $terms = get_the_terms( $post->ID, 'product_cat' ); $product_cat_id; foreach ($terms as $term) { $product_cat_id = $term->term_id; break; } function woocommerceCategorySlug( $id ){ $term = get_term_by('id', $id, 'product_cat', 'ARRAY_A'); return $term['slug']; } $categoryurl = woocommerceCategorySlug($product_cat_id); wp_redirect( 'https://www.yourwebsite.com/collection/' . $categoryurl, 301 ); exit; } ?>
Streamline your eCommerce Website Migration
If you're navigating the complexities of transitioning from WooCommerce to Shopify and need expert assistance, we're here for you!
Contact us now to discuss how our team can efficiently manage your product page redirects, ensuring a seamless transition and improved user experience.
Why Shop Innovator?
- Collaborate with a Team of eCommerce Experts with over two decades of experience.
- Cost-effective eCommerce support tailored to your budget.
- Accelerated e-commerce success with Website Updates, Reviews & Reputation Management, Email Marketing, Search Marketing, Social Media, and Content Creation.
- Scale Your Support as Your Business Grows—No Hassle of Hiring or Managing Additional Staff.
- Validated Results with Countless E-Commerce Brands in the Home and Garden Sector.
Join Us for a Free 30-minute Discovery Call—Let's Work Together to Improve Your Business!