Skip to content
  1. Extras
  2. miniShop2
  3. Snippets
  4. msProducts

msProducts

The product display snippet.

Parameters

ParameterBy defaultDescription
tpltpl.msProducts.rowChunk for a result formatting
limit10Sample result limit
offsetSkip results from the beginning of the sample
depth10Depth of searching goods of every parent.
sortbyidSample sorting. To sort by item fields the prefix "Data" should be added, for example: "&sortby=Data.price"
sortbyOptionsIndicates how and by what options to sort among listed in &sortby. Passed by a line, for example, "optionkey:integer,optionkey2:datetime"
sortdirASCSorting direction
toPlaceholderIf filled, snippet will store all data in placeholder with this name, instead of displaying.
toSeparatePlaceholdersIf a word is indicated in this parameter, ALL results will be in different placeholders, beginning with this word and end in sequence number of the line, from zero. For example, if "myPl" is in the parameter, the placeholders will be [[+myPl0]], [[+myPl1]] etc.
parentsThe category list separated by commas for result searching. The sample is limited by default to current parent. If 0 is indicated- the sample is not limited.
resourcesThe list of goods separated by commas for result display. If goods id begins with minus it is excluded from sample.
includeContentTo select"content" field of goods.
includeTVsThe list of TV sample parameters separated by commas. For example: "action,time" is given by placeholders [[+action]] and [[+time]].
includeThumbsThe list of sample preview dimensions separated by commas. For example: "120x90,360x240" are given by placeholders [[+120x90]] and [[+360x240]]. The pictures should be pre-generated in item gallery.
optionFiltersGoods option filters. Transmitted by JSON line, for example,
whereJSON-coded line with additional sample conditions.
linkGoods link Id, which is automatically assigned in settings when new link is created.
masterMaster item Id. If both "master" and "slave" are indicated the sampling will follow master.
slaveId of affiliated item. If "master" is set this option will be ignored.
tvPrefixA prefix for TV placeholders, for example "tv." Empty by default.
outputSeparator\nOptional line for results separation.
returnIdsTo return goods id line, instead of formatted chunks.
showUnpublishedTo display non-published goods.
showDeletedTo display deleted goods.
showHidden1To display goods, hidden in menu.
showZeroPrice1To display goods with zero price.
wrapIfEmpty1Switch on the display of wrapper chunk (tplWrapper) even if there are no results.
showLogTo show additional information of snippet operation. For authorized in context "mgr" only.

Tip

Another pdoTools general parameters may be used.

Features

msProducts snippet, as all snippets of miniShop2, works using pdoTools. Because of this all its main parameters coincide with pdoResources, but some peculiarities exist.

Multicategory support

The MS2 item is physically in single category. However, it may «virtually» exist in several sections. This is taken into account through msProducts.

Picture deriving

Snippet can select pictures from the item gallery through the &includeThumbs parameter. Simply list preview separated by commas:

modx
[[!msProducts?
  &parents=`0`
  &includeThumbs=`120x90,360x270`
]]

and you will obtain[[+120x90]] and [[+360x270]] in chunk.

You may display &link parameter and required&master or &slave,thus selecting linked goods:

modx
[[!msProducts?
  &parents=`0`
  &link=`1`
  &master=`15`
]]

This call will obtain all goods connected by link 1 with master item 15.

Work with options

msProducts automatically switches on and transfers all goods options in kind of [[+key_options]] placeholder.

The special parameter &optionFilters connects the necessary tables and complements the &where parameter, thus permitting to filter goods by their options.

modx
[[!msProducts?
  &parents=`0`
  &optionFilters=`{"core_count:>":4}`
]]

This call displays all goods with core_count option if it exceeds 4.

The parameter &sortbyOptions is used for sorting. The required characteristics and their type are indicated in it , separated by commas.

modx
&sortbyOptions=`core_count:number`
&sortby=`{"pagetitle":"ASC", "core_count":"DESC"}`

Sorting order is indicated as in &sort parameter.

Aliases

msProducts snippet immediately attaches several linked item tables allowing you to receive data from them without unnecessary inquiries.

This is the main class. The rest are listed below:

  • msProduct - the main class of a sample, descendant ofmodResource.
  • Data - Class of msProductData. The price, vendor code and other item characteristics are here.
  • Vendor - Class of item manufacturermsVendor. Its name, country, logo, etc. are here.

Placeholders

If you simply do not indicate formatting chunk then all available placeholders may be seen:

modx
<pre>
[[!msProducts?
  &parents=`0`
  &tpl=``
]]
</pre>

Examples

Display all goods of 15 category:

modx
[[!msProducts?
  &parents=`15`
]]

Display with page layout:

modx
[[!pdoPage?
  &element=`msProducts`
  &parents=`15`
]]
[[!+page.nav]]

Display all goods more expensive than 1000 rubles:

modx
[[!pdoPage?
  &element=`msProducts`
  &parents=`0`
  &where=`{"Data.price:>":1000}`
]]
[[!+page.nav]]

Display Sony products:

modx
[[!pdoPage?
  &element=`msProducts`
  &parents=`0`
  &where=`{"Vendor.name":"Sony"}`
]]
[[!+page.nav]]

Sorting by vendor code:

modx
[[!pdoPage?
  &element=`msProducts`
  &parents=`0`
  &sortby=`Data.article`
  &sortdir=`asc`
]]
[[!+page.nav]]