Community

How to set up a product catalogue on shop page in MODX

Hi There, I just want to know how to set up a products catalog in a shop page that lists all the products plus some sorting options on top and filtering options in sidebar. Right now my page looks like this …

http://adco.site/products/.

The blocks you see there are the categories blocks. I want the products right there and then sort them out and filter them out as I want. I checked a lot online but seriously MODX lacks clear sources and documentation on such an important and easy topic. I do not see any direct function to get and list products… strange !!

I tried to use this plugin https://modx.com/extras/package/getproducts but strangely it always gets downloaded corrupted in my pc and I see absolutely no documentation for it.
Can anyone help me set this up finally.

Thanks in advance,
Ronak S

I think getResources may be what you need, but let’s see what others have to say.

Now on your sample page, are those intended to be items or categories?

I think one important issue is whether the items are going to be resources (pages), or simply items in a list with attached characteristics.

I believe that making the items as resources can help with SEO, because you’ve got everything there with keywords and so on. Not entirely sure about that, and it might not be the best way for you.

These resources (pages) can also be delivered to the user in a lightbox, over a list of products, rather than having a separate page that the user must go to, or not, depending on various factors like whether you want to associate more info with the item.

That extra looks pretty old, here is a newer one from the same author that looks better supported

https://modx.com/extras/package/shopkeeper3
As for the criticism, it is valid. Things are improving now with this new forum and sort of a clean slate to re-assemble all the critical info. I do think one difficulty with users applying Modx is the simple fact that there are so many ways to do nearly everything.

We are trying to build a bunch of common pathways so people can get up and running quickly with ‘basic’ functionality (an idea itself which has changed over time).

One tough issue is that the higher level devs are earning money off of their solutions, and so its taken a bit of time for the critical basic solutions to get out to the userbase. If I make a great new mousetrap I definitely would like to profit from it for a bit before making it public.

Today a lot of users are willing to put up their custom snippets so that basic functionality is easier. Its amazing what a touch of php can do.

Is this just a static catalogue or are you intending to sell products themselves? If it is just a static catalog with no functionality required other than listing products and going to their page for details then look at getResources or pdoResources (preferred) to fetch resource data and sort.

If you need something more complex, a fully fledged ecommerce system, then take a look at the premium extra Commerce from modmore.com.

1 Like

Also minishop2

https://modx.com/extras/package/minishop2

Try Commerce, you’ll be amazed.

1 Like

Hi, finally got the solution …

                    [[getPage?
                    &element=`getResources`
                    &parents=`7, 23, 24, 25, 49, 51, 52, 113`
                    &limit=`4`
                    &includeTVs=`1`
                    &processTVs=`1`
                    &sortby=`menuindex`
                    &sortdir=`ASC`
                    &tpl=`product-list`
                    &totalVar=`total`
                    &pagePrevTpl=`<li class="pagination-prev"><a href="[[++site_url]][[+href]]"><span class="zn_icon" data-zniconfam="glyphicons_halflingsregular" data-zn_icon=""></span></a></li>`
                    &pageNextTpl=`<li class="pagination-next"><a href="[[++site_url]][[+href]]"><span class="zn_icon" data-zniconfam="glyphicons_halflingsregular" data-zn_icon=""></span></a></li>`
                    &pageActiveTpl=`<li class="active" class="page-[[+pageNo]]"><span style="display: inline-block;">[[+pageNo]]</span></li>`
                    &pageNavTpl=`<li><a href="[[+href]]"><span>[[+pageNo]]</span></a></li>`
                    &pageNavOuterTpl=`[[+prev]][[+pages]][[+next]]`
					&pageNavVar=`page.nav`
					&toPlaceholder=`products`
                    ]]




                [[+products:neq=``:then=`
                    <ul class="products">
                        [[+products]]
                    </ul>
                    <ul class="pagination">
                        [[!+page.nav]]
                    </ul>
                `:else=`
                    [[*product_category_countdown_text]]
                    <div class="countdown"></div>
                `]]

The hack was below two lines …

  1. &parents=7, 23, 24, 25, 49, 51, 52, 113 and
  2. &pageNavVar=page.nav

due to first line, got the list of products of all these categories. Strangely in the official docs of the getPage snippet ( @https://docs.modx.com/extras/revo/getpage ) it is no where written as how to pass multiple parents in the snippet call, so I was passing 7, 23 and etc. But in the getResources documentation, it was bit clear but still without any example of passing multiple categories.

Secondly, the second line I pointed above was missing from the snippet call I used from the previous work so [[+prodcuts:neq and everything was not working, it taken a lot to discover this. But finally working.

There is still one problem in this call and is that the [[+pages]] is giving me duplicate slugs in the url as http://adco.site/products/products/?page=3 which is goingto 404. I know its basics and its related to permalinks but I do not know how to resolve this. Can anyone help ?

I tried the .htaccess way but not to go with it and also not working. I tried to find out the source of [[+page]] to solve this but still not able to. I need help in this …

Thanks in advance,
Ronak