<?php require_once dirname(dirname(__FILE__)).'/getdata.class.php'; class modWebCatalogProductsModelGetdataProcessor extends modWebCatalogProductsGetdataProcessor{ public function initialize(){ $this->setDefaultProperties(array( 'model' => false, )); return parent::initialize(); } public function prepareQueryBeforeCount(xPDOQuery $c) { $c = parent::prepareQueryBeforeCount($c); $c->innerJoin('ShopmodxProduct', 'Product'); if($this->getProperty('model')){ $c->innerJoin('modTemplateVarResource', 'model', "model.contentid = {$this->classKey}.id AND model.tmplvarid = 10 AND model.value='$this->getProperty('model')'"); } return $c; } } return 'modWebCatalogProductsModelGetdataProcessor';
{assign var=params value=[ "model" => $modx->resource->pagetitle ]} {processor action="web/catalog/products/model/getdata" ns="modxsite" params=$params assign=result} <div style="overflow:hidden;"> {if $result.success && count($result.object)} {foreach $result.object as $object} {assign var=image value=$object.image|default:$object.imageDefault} <div class="goodItem left"> <img src='{snippet name="phpthumbon" params="input=`{$image}`&options=`w=238&h=170&zc=1`"}' width="238" height="170"> <h2>{$object.pagetitle}</h2> <p>{$object.introtext}</p> <span class="block">{$object.sm_price|number_format:0:" ,":" "} грн.</span> <a class="block" href="{$object.uri}">Подробнее</a> </div> {/foreach} {else} <h2 class="notGoods">Категория пуста</h2> {/if} </div> [[+page.nav]]
if($model = $this->getProperty('model')){ $c->innerJoin('modTemplateVarResource', 'model', "model.contentid = {$this->classKey}.id AND model.tmplvarid = 10 AND model.value='{model}'"); }
<?php /* Получаем новинки */ require_once dirname(dirname(__FILE__)).'/getdata.class.php'; class modWebCatalogProductsModelGetdataProcessor extends modWebCatalogProductsGetdataProcessor{ public function initialize(){ if(!(int)$this->getProperty('model')){ return 'Не была указана марка'; } return parent::initialize(); } public function prepareCountQuery(xPDOQuery & $query){ $query = parent::prepareCountQuery($query); if($model = (int)$this->getProperty('model')){ $query->innerJoin('modTemplateVarResource', 'model', "model.contentid = {$this->classKey}.id AND model.tmplvarid = 10 AND model.value='{$model}'"); } return $query; } } return 'modWebCatalogProductsModelGetdataProcessor';
{assign var=params value=[ "model" => $modx->resource->id, "limit" => 9, "getPage" => true, 'cache' => true ]} {processor action="web/catalog/products/model/getdata" ns="modxsite" params=$params assign=result} <div style="overflow:hidden;"> {if $result.success && count($result.object)} {foreach $result.object as $object} {assign var=image value=$object.image|default:$object.imageDefault} <div class="goodItem left"> <img src='{snippet name="phpthumbon" params="input=`{$image}`&options=`w=238&h=170&zc=1`"}' width="238" height="170"> <h2>{$object.pagetitle}</h2> <p>{$object.introtext}</p> <span class="block">{$object.sm_price|number_format:0:",":" "} грн.</span> <a class="block" href="{$object.uri}">Подробнее</a> </div> {/foreach} {else} <h2 class="notGoods">Категория пуста</h2> {/if} </div> [[+page.nav]]
if($this->getProperty('model')){ $c->innerJoin('modTemplateVarResource', 'model', "model.contentid = {$this->classKey}.id AND model.tmplvarid = 10 AND model.value='$this->getProperty('model')'"); } if($color = $this->getProperty('color')){ $c->innerJoin('modTemplateVarResource', 'color_tv', "color_tv.contentid = {$this->classKey}.id AND color_tv.tmplvarid = 11 AND color_tv.value='{$color}'"); }
$this->setDefaultProperties(array( "sort" => "if(find_in_set('{$value}', column) 1, 0)", "dir" => "DESC", ));
$c->innerJoin('modTemplateVarResource', "tv_categories", "tv_categories.contentid = {$this->classKey}.id AND tv_categories.tmplvarid = {$tv_id} AND find_in_set('{$value}', tv_categories.value)");
$c->innerJoin('modTemplateVarResource', "tematic", "tematic.contentid = {$this->classKey}.id AND tematic.tmplvarid = 14 AND find_in_set('{$tematic}', '{str_replace('||', ',', tematic.value)}' )");
2015-05-01 17:37:37] (ERROR @ /index.php) modSiteWebGetlistProcessor [2015-05-01 17:37:37] (ERROR @ /index.php) Array ( [0] => 42000 [1] => 1064 [2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE ( `modResource`.`deleted` = 0 AND `modResource`.`hidemenu` = 0 AND `modRe' at line 1 ) [2015-05-01 17:37:37] (ERROR @ /index.php) SELECT COUNT(DISTINCT `modResource`.`id`) FROM `modx_site_content` AS `modResource` JOIN `modx_shopmodx_products` `Product` ON `modResource`.`id` = `Product`.`resource_id` JOIN `modx_site_tmplvar_contentvalues` `tematic` ON WHERE ( `modResource`.`deleted` = 0 AND `modResource`.`hidemenu` = 0 AND `modResource`.`published` = 1 )
if($tematic = (int)$this->getProperty('tematic')){ $query->innerJoin('modTemplateVarResource', 'tematic', "tematic.contentid = {$this->classKey}.id AND tematic.tmplvarid = 14 AND find_in_set('{$tematic}', replace(tematic.value, '||', ',') )"); }
Я вижу пока только тот вариант, что описал — нужно наличие поля, в котором значения разделены запятой.