Присоединить подчиненный товар к основному

Здравствуйте!
Подскажите как правильно настроить innerJoin для присоединения подчиненного товара к главному по типу как тут реализовано присоединение товара к категории bezumkin.ru/sections/tips_and_tricks/2058/

Стоит условие на вывод только основных товаров, но нужно чтобы вместо pagetitile и uri выводились поля подчиненного товара

[[!mfilter2?
          &element=`msProducts`
          &parents=`2`
          &loadModels=`easycomm`
          &tplOuter=`tpl.catalogWrap`
          &tpl=`catalog.Row`
          &limit=`20`
          &groupRows=`1`
          &aliases=`
             ms|price==price,
             resource|parent==parent,
             ms|vendor==vendor,
             msoption|space==space,
             msoption|width==width,
             msoption|power==power
          `
          &ajaxMode=`button`
          &includeThumbs=`small`
          &filterOptions=`{
          "more_tpl":"<button class=\"standart-button show-more-button btn_more btn w-button\">Показать ещё 20 товаров<\/button>"
          }`
          &showLog=`1`
          &leftJoin=`{
	"ecThread": {
		"class": "ecThread",
		"on": "msProduct.id = ecThread.resource"
	},
	"Link": {
	    "class": "msProductLink",
	    "on": "msProduct.id = Link.slave and Link.link = 5"
	}
}`

&innerJoin=`{
		"msProductSlave": {
		    "class":"msProduct",
		    "alias":"msProductSlave",
		    "on":"msProduct.id = msProductLink.slave AND msProduct.class_key = 'msProduct'"
		}
}`
          &sortAliases=`{
          "ecThread":"ecThread"
          }`
          &sort=`ms|favorite:desc`
          &filters=`
          ms|vendor:vendors,
          ms|price:number,
          parent:categories,
          msoption|cable,
          msoption|space:number,
          msoption|width:number,
          msoption|power:number
          `
          &suggestionsRadio=`vendor:vendors`
          &class=`msProduct`
          &select=`{
          "Link": "slave",
          "msProduct": "*",
          "msProductSlave":"msProduct.id as product_id"
          }`
          &where=`{
          "Link.slave:IS": null
          }`
          &tplFilter.row.price=`tpl.mFilter2.filter.number`
          &tplFilter.outer.price=`tpl.mFilter2.filter.minMax`
          &tplFilter.row.width=`tpl.mFilter2.filter.number`
          &tplFilter.outer.width=`tpl.mFilter2.filter.minMax`
          &tplFilter.row.power=`tpl.mFilter2.filter.number`
          &tplFilter.outer.power=`tpl.mFilter2.filter.minMax`
          &tplFilter.row.space=`tpl.mFilter2.filter.number`
          &tplFilter.outer.space=`tpl.mFilter2.filter.minMax`
          &tplFilter.outer.vendor=`tpl.mfilter2.filter.select`
          &tplFilter.row.vendor=`tpl.mfilter2.filter.option`
          ]]
но получаю ошибку
0.0000160: Loaded model "easycomm" from "/core/components/easycomm/model/"
0.0000212: pdoTools loaded.
0.0000708: Conditions prepared
0.0000129: Loaded model "easycomm" from "/core/components/easycomm/model/"
0.0000119: xPDO query object created
0.0000479: innerJoined msProduct as msProductSlave
0.0000551: leftJoined msProductData as Data
0.0000379: leftJoined msVendor as Vendor
0.0000379: leftJoined msProductFile as small
0.0000372: leftJoined ecThread as ecThread
0.0000370: leftJoined msProductLink as Link
0.0000019: Grouped by msProduct.id, `small`.url
0.0000448: Added selection of msProduct: SQL_CALC_FOUND_ROWS `id`, `type`, `contentType`, `pagetitle`, `longtitle`, `description`, `alias`, `link_attributes`, `published`, `pub_date`, `unpub_date`, `parent`, `isfolder`, `introtext`, `content`, `richtext`, `template`, `menuindex`, `searchable`, `cacheable`, `createdby`, `createdon`, `editedby`, `editedon`, `deleted`, `deletedon`, `deletedby`, `publishedon`, `publishedby`, `menutitle`, `donthit`, `privateweb`, `privatemgr`, `content_dispo`, `hidemenu`, `class_key`, `context_key`, `content_type`, `uri`, `uri_override`, `hide_children_in_tree`, `show_in_tree`, `properties`
0.0000060: Added selection of msProductData: `article`, `price`, `old_price`, `weight`, `image`, `thumb`, `vendor`, `made_in`, `new`, `popular`, `favorite`, `tags`, `color`, `size`, `source`
0.0000050: Added selection of msVendor: `name` AS `vendor.name`, `resource` AS `vendor.resource`, `country` AS `vendor.country`, `logo` AS `vendor.logo`, `address` AS `vendor.address`, `phone` AS `vendor.phone`, `fax` AS `vendor.fax`, `email` AS `vendor.email`, `description` AS `vendor.description`, `properties` AS `vendor.properties`
0.0000029: Added selection of msProductFile: url as `small`
0.0000360: Added selection of msProductLink: `slave`
0.0000191: Added selection of msProduct: msProduct.id as product_id
0.0000172: Processed additional conditions
0.0000839: Added where condition: class_key=msProduct, Link.slave:IS=, msProduct.id:IN(11,17,24,28,12,13,23,32,19,20,21,22,18,25,11,17,24,28,12,13,23,32,19,20,21,22,18,25), msProduct.published=1, msProduct.deleted=0
0.0000160: Sorted by `favorite` desc, 
0.0000010: Limited to 20, offset 0
0.0000999: SQL prepared "SELECT SQL_CALC_FOUND_ROWS `msProduct`.`id`, `msProduct`.`type`, `msProduct`.`contentType`, `msProduct`.`pagetitle`, `msProduct`.`longtitle`, `msProduct`.`description`, `msProduct`.`alias`, `msProduct`.`link_attributes`, `msProduct`.`published`, `msProduct`.`pub_date`, `msProduct`.`unpub_date`, `msProduct`.`parent`, `msProduct`.`isfolder`, `msProduct`.`introtext`, `msProduct`.`content`, `msProduct`.`richtext`, `msProduct`.`template`, `msProduct`.`menuindex`, `msProduct`.`searchable`, `msProduct`.`cacheable`, `msProduct`.`createdby`, `msProduct`.`createdon`, `msProduct`.`editedby`, `msProduct`.`editedon`, `msProduct`.`deleted`, `msProduct`.`deletedon`, `msProduct`.`deletedby`, `msProduct`.`publishedon`, `msProduct`.`publishedby`, `msProduct`.`menutitle`, `msProduct`.`donthit`, `msProduct`.`privateweb`, `msProduct`.`privatemgr`, `msProduct`.`content_dispo`, `msProduct`.`hidemenu`, `msProduct`.`class_key`, `msProduct`.`context_key`, `msProduct`.`content_type`, `msProduct`.`uri`, `msProduct`.`uri_override`, `msProduct`.`hide_children_in_tree`, `msProduct`.`show_in_tree`, `msProduct`.`properties`, `Data`.`article`, `Data`.`price`, `Data`.`old_price`, `Data`.`weight`, `Data`.`image`, `Data`.`thumb`, `Data`.`vendor`, `Data`.`made_in`, `Data`.`new`, `Data`.`popular`, `Data`.`favorite`, `Data`.`tags`, `Data`.`color`, `Data`.`size`, `Data`.`source`, `Vendor`.`name` AS `vendor.name`, `Vendor`.`resource` AS `vendor.resource`, `Vendor`.`country` AS `vendor.country`, `Vendor`.`logo` AS `vendor.logo`, `Vendor`.`address` AS `vendor.address`, `Vendor`.`phone` AS `vendor.phone`, `Vendor`.`fax` AS `vendor.fax`, `Vendor`.`email` AS `vendor.email`, `Vendor`.`description` AS `vendor.description`, `Vendor`.`properties` AS `vendor.properties`, `small`.url as `small`, `Link`.`slave`, msProduct.id as product_id FROM `modx_site_content` AS `msProduct` JOIN `modx_site_content` `msProductSlave` ON msProduct.id = msProductLink.slave AND msProduct.class_key = 'msProduct' LEFT JOIN `modx_ms2_products` `Data` ON `msProduct`.`id` =  `Data`.`id` LEFT JOIN `modx_ms2_vendors` `Vendor` ON Data.vendor=Vendor.id LEFT JOIN `modx_ms2_product_files` `small` ON `small`.product_id = msProduct.id AND `small`.rank = 0 AND `small`.path LIKE '%/small/%' LEFT JOIN `modx_ec_threads` `ecThread` ON msProduct.id = ecThread.resource LEFT JOIN `modx_ms2_product_links` `Link` ON msProduct.id = Link.slave and Link.link = 5 WHERE  ( `msProduct`.`class_key` = 'msProduct' AND `Link`.`slave` IS NULL AND `msProduct`.`id` IN (11,17,24,28,12,13,23,32,19,20,21,22,18,25,11,17,24,28,12,13,23,32,19,20,21,22,18,25) AND `msProduct`.`published` = 1 AND `msProduct`.`deleted` = 0 )  GROUP BY msProduct.id, `small`.url ORDER BY `favorite` desc LIMIT 20 "
0.0002861: Could not process query, error #1054: Unknown column 'msProductLink.slave' in 'on clause'
0.0010769: Total time
6 291 456: Memory usage
подскажите как правильно, заранее спасибо!
Вячеслав Варов
07 октября 2018, 15:06
modx.pro
1
1 128
0

Комментарии: 2

Вячеслав Варов
07 октября 2018, 18:06
0
У меня получилось объединить, НО теперь выводятся только Мастер товары, а нужно чтобы выводились все включая товары вообще без связи кроме подчиненных товаров

[[!mfilter2?
          &element=`msProducts`
          &parents=`2`
          &loadModels=`easycomm`
          &tplOuter=`tpl.catalogWrap`
          &tpl=`catalog.Row`
          &limit=`20`
          &groupRows=`1`
          &aliases=`
             ms|price==price,
             resource|parent==parent,
             ms|vendor==vendor,
             msoption|space==space,
             msoption|width==width,
             msoption|power==power
          `
          &ajaxMode=`button`
          &includeThumbs=`small`
          &filterOptions=`{
          "more_tpl":"<button class=\"standart-button show-more-button btn_more btn w-button\">Показать ещё 20 товаров<\/button>"
          }`
          &showLog=`1`
          &leftJoin=`{
	"ecThread": {
		"class": "ecThread",
		"on": "msProduct.id = ecThread.resource"
	},
	"Link": {
	    "class": "msProductLink",
	    "on": "msProduct.id = Link.slave and Link.link = 5"
	}
}`

&innerJoin=`{
		"msProductSlave": {
		    "class":"msProductLink",
		    "alias":"msProductSlave",
		    "on":"msProduct.id = msProductSlave.master"
		}
}`
          &sortAliases=`{
          "ecThread":"ecThread"
          }`
          &sort=`ms|favorite:desc`
          &filters=`
          ms|vendor:vendors,
          ms|price:number,
          parent:categories,
          msoption|cable,
          msoption|space:number,
          msoption|width:number,
          msoption|power:number
          `
          &suggestionsRadio=`vendor:vendors`
          &class=`msProduct`
          &select=`{
          "Link": "slave",
          "msProduct": "*",
          "msProductSlave":"msProductSlave.slave as product_id"
          }`
          &where=`{
          "Link.slave:IS": null
          }`
          &tplFilter.row.price=`tpl.mFilter2.filter.number`
          &tplFilter.outer.price=`tpl.mFilter2.filter.minMax`
          &tplFilter.row.width=`tpl.mFilter2.filter.number`
          &tplFilter.outer.width=`tpl.mFilter2.filter.minMax`
          &tplFilter.row.power=`tpl.mFilter2.filter.number`
          &tplFilter.outer.power=`tpl.mFilter2.filter.minMax`
          &tplFilter.row.space=`tpl.mFilter2.filter.number`
          &tplFilter.outer.space=`tpl.mFilter2.filter.minMax`
          &tplFilter.outer.vendor=`tpl.mfilter2.filter.select`
          &tplFilter.row.vendor=`tpl.mfilter2.filter.option`
          ]]
    Вячеслав Варов
    07 октября 2018, 18:50
    0
    Проблема решена, все оказалось проще, нужно вместо innerJoin использовать leftJoin
    Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
    2