Magelia Orchard : configuring the URLs for catalogs and categories

Jan 4, 2013 at 7:59 AM
Edited Jan 4, 2013 at 8:12 AM

In Magelia for Orchard plugin, one of the widget displays catalogs and categories. The widget is alright, except that it always produce a productlist URL built from the current one. Here is an example where this behaviour is an issue :

1. You're on YourSite.com/, you see the product list ans the Catalog and Caterogies display

2. You click on "View details", you go to YourSite.com/product?sku=..., where you could have set the Catalog and Categories widget too

3. If you click on a link of the Catalog and Categories widget, you will be taken a Product List URL built from your current URL : YourSite.com/product?catalog=...&product=...&x_chx_target=...&x_chw_action=select&x_chw_path=... which is not a Product List, but still a Product Page

To correct that, I need to determine the URL building. I have seen thant, in the admin view, there is a configuration for "Catalog hierarchy settings" : is there a way to configure a more consistent URL via this config ?

Jan 4, 2013 at 11:03 AM

Hi Boris,

the "catalogs and categories" widget actualy implements two behaviours :

The first one allows the user to stay on the same page and triggers the update of "products list" widgets that are configured to display products according to a "catalogs and categories" widget selection.

The second one allows you to specify the way you want to generate URLs for catalogs and categories. This behaviour is available by checking the "Generate URLs for catalogs and categories" checkbox in the configuration screen of the widget and specifying URL patterns like ~/MyPath/{Code} or ~/MyPath/{Name} to redirect the user on specific pages according to the selected item.
You have access to every members of the current catalog or category in URL patterns : {ATTRIBUTE_NAME} will be replaced by the value of the specified attribute.

If I've understand your needs you want that your "catalogs and categories" widget generates two kinds of URLs.

_ in the products list page, URLs to update "products list" widget.
_ in the product details page, URLs to go back to products list page while triggering the update of the "products list" widget.

To implement this scenario, I invite you to use the same "catalogs and categories" widget on both pages and by overriding the views "CatalogItem.cshtml" and "CategoryItem.cshtml" in your theme to perform a check on the current page URL to prepend generated URL with products list page URL when the widget is displayed by the product details page.

Let us know if this solution is what you need. Thanks again for your feedbacks.

Aloys

Jan 8, 2013 at 11:15 AM

Hi Aloys,

As I waited for a possible solution by configuration, I implemented the modification in "CatalogItem.cshtml" and "CategoryItem.cshtml" and it works. Thanks.

Regards,

Boris

Apr 17, 2013 at 5:26 PM
Hi,
I have a similar problem :
I want to have the "Categorie" Widget in my layer "default" and a page "Catalog" with the "ProductList" Widget...

I have checked in "Catalog hierarchy settings" of my Widget "Categories" the check-box "Generate URLs for catalogs and categories"
and i have tested to configure with this :
Catalog URL pattern : ~/Catalogue?catalog={Catalog.Code}
Category URL pattern : ~/Catalogue?catalog={Catalog.Code}&category={Code}

But the problem is that the productList displays all the products whatever the category selected.

When i go in the Widget ProductList after to have checked the checkbox, in the part "Product list settings", there isn't anymore "categories" widget in the list "Magelia WebStore Catalogs and Categories component"...

how did you change your CategoryItem.cshtml or CatalogItem.cshtml to solve the problem ?
Coordinator
Apr 20, 2013 at 6:09 PM
Hi,

In order to display a “Catalogs and Categories” widget on a default layer of your Orchard instance and to redirect to another page (for example “~/Catalog”) displaying the “Product List” widget, I invite you to overwrite the views: “/Modules/Magelia.WebStore/Views/CategoryItem.cshtml” and “/Modules/Magelia.WebStore/Views/CatalogItem.cshtml” to prefix the URLs generated by the path of your page.

For the “Product List” widget to automatically filter products in function of the selected category in the “Catalogs and Categories” widget, you must first configure the “Catalogs and Categories” widget without checking “General URLs for catalogs and categories,” then the “Product List” widget by checking “Automatically display a list of products based on the choice of a catalog or category in the Magelia WebStore Catalogs and Categories component,” and by choosing the “Catalogs and Categories” widget in the dropdownlist that will be displayed.

You will find an overwriting example of the view “CategoryItem.cshtml” in the running theme (Themes/TheThemeMachine/Views/CategoryItem.cshtml)
You will find an example of the configuration in two pages on an Orchard instance at this address: http://www.magelia.org/Media/Default/Codeplex/orchard_sample_3.zip

Best Regards,

Adinsx + yaligault