Created
May 31, 2020 16:13
-
-
Save Sentinel-7/26c2b565714bb9e272c38d1493004f81 to your computer and use it in GitHub Desktop.
Собираем поля опций товара для mFilter2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[[!mFilter2? | |
&parents=`[[*id]]` | |
&class=`msProduct` | |
&element=`msProducts` | |
&hideContainers=`1` | |
&limit=`18` | |
&pageLimit=`5` | |
&includeThumbs =`middle` | |
&includeTVs =`discount,status` | |
&suggestionsMaxResults=`3000` | |
&tpl=`tplProduct` | |
&tplOuter=`tplFilterOuter` | |
&tplFilter.outer.default=`tplFilterFilterOuter` | |
&filters=` | |
ms|price:number, | |
tv|status, | |
ms|vendor:vendors, | |
[[!OptionsCat]] | |
` | |
&sort=` | |
ms_product|pagetitle:asc` | |
&tplFilter.outer.ms|vendor=`tpl.mFilter2.filter.outer` | |
&tplFilter.outer.ms|price=`tpl.mFilter2.filter.slider` | |
&tplFilter.row.ms|price=`tpl.mFilter2.filter.number` | |
]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (empty($options)) {$options='caption';}; | |
$rez=''; | |
$query = $modx->prepare("SELECT {$field} FROM {$modx->getTableName('msOption')} WHERE `key`= '".$input."'"); | |
$query->execute(); | |
$item = $query->fetch(PDO::FETCH_ASSOC); | |
if ($item[$options] != ''){ | |
$rez=$item[$options]; | |
} | |
return $rez; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$catid = array($modx->resource->id); | |
$in_id = implode(",", $catid) ; | |
$sql = "SELECT msc.category_id, msc.option_id, mso.key, mso.type | |
FROM {$modx->getTableName('msCategoryOption')} msc | |
LEFT JOIN {$modx->getTableName('msOption')} mso ON msc.option_id = mso.id | |
WHERE msc.category_id IN ($in_id) AND mso.filtr=1 ORDER BY mso.category, mso.id ASC"; | |
$q = $modx->prepare($sql); | |
$q->execute(); | |
$options = $q->fetchAll(PDO::FETCH_ASSOC); | |
$_options = ''; | |
foreach ($options as $option) { | |
$type="default"; | |
if ($option['type'] == 'combo-boolean'){$type = 'boolean';} | |
$_options .= ',msoption|'.$option['key'].":".$type; | |
} | |
return $_options; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<fieldset id="mse2_[[+table]][[+delimeter]][[+filter]]"> | |
<h4 class="filter_title">[[+filter:nameFilter]]</h4> | |
[[+rows]] | |
</fieldset> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment