msGallery перебивает msProducts - почему?
Задача: вывести в каталоге товары с 2-мя полными галереями (одна с превьюшками 15x15 в одном месте, а другая с крупными превьюшками в другом месте того же чанка товара).
Проблема: при добавлении вызова msGallery в чанк товара с указанием id этого товара сама выборка всех товаров стопорится и выводит только 1 товар.
Подробнее:
Выборка товаров:
Почему так происходит?
Судя по логам, при подключении галереи в чанке, вызов msProducts превращается в вызов msGallery????
Проблема: при добавлении вызова msGallery в чанк товара с указанием id этого товара сама выборка всех товаров стопорится и выводит только 1 товар.
Подробнее:
Выборка товаров:
{'!msProducts'|snippet:[
'tpl' => 'tpl.msProducts.row.card',
'limit' => 20,
'sortby' => 'menuindex',
'showLog' => 1,
]}вызов галереи в чанке{'!msGallery'|snippet:[
'product' => $id,
]}showLog без подключения галереи:0.0007920: pdoTools loaded.
0.0000911: Conditions prepared
0.0000272: xPDO query object created
0.0000930: leftJoined msProductData as Data
0.0000629: leftJoined msVendor as Vendor
0.0000010: Grouped by msProduct.id
0.0000181: 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`, `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.0000091: Added selection of msProductData: `article`, `price`, `old_price`, `weight`, `image`, `thumb`, `vendor`, `made_in`, `new`, `popular`, `favorite`, `tags`, `color`, `size`, `source`
0.0000069: 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.0003569: Processed additional conditions
0.0004601: Added where condition: class_key=msProduct, msProduct.parent:IN(1,3,4,5,2,6,7), msProduct.published=1, msProduct.deleted=0
0.0000300: Sorted by msProduct.menuindex, ASC
0.0000010: Limited to 20, offset 0
0.0001862: 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`.`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` FROM `1z6fJ8nTV9NY_site_content` AS `msProduct` LEFT JOIN `1z6fJ8nTV9NY_ms2_products` `Data` ON `msProduct`.`id` = `Data`.`id` LEFT JOIN `1z6fJ8nTV9NY_ms2_vendors` `Vendor` ON Data.vendor=Vendor.id WHERE ( `msProduct`.`class_key` = 'msProduct' AND `msProduct`.`parent` IN (1,3,4,5,2,6,7) AND `msProduct`.`published` = 1 AND `msProduct`.`deleted` = 0 ) GROUP BY msProduct.id ORDER BY msProduct.menuindex ASC LIMIT 20 "
0.0005751: SQL executed
0.0000861: Total rows: 6
0.0000260: Rows fetched
0.0000632: Returning raw data
0.0002558: Checked the active modifiers
0.0008931: Loaded "modChunk" with name "tpl.msProducts.row.card"
0.0009580: Compiled Fenom chunk with name "modchunk/22"
0.0019603: Time to load products options
0.0735221: Total time
6 291 456: Memory usageshowLog с галереей:0.0004411: pdoTools loaded.
0.0004699: Conditions prepared
0.0000119: xPDO query object created
0.0000250: Added selection of msProductFile: SQL_CALC_FOUND_ROWS `id`, `product_id`, `source`, `parent`, `name`, `description`, `path`, `file`, `type`, `createdon`, `createdby`, `rank`, `url`, `properties`, `hash`
0.0000381: Added where condition: product_id=3, parent=0
0.0000210: Sorted by msProductFile.rank, ASC
0.0000730: SQL prepared "SELECT SQL_CALC_FOUND_ROWS `msProductFile`.`id`, `msProductFile`.`product_id`, `msProductFile`.`source`, `msProductFile`.`parent`, `msProductFile`.`name`, `msProductFile`.`description`, `msProductFile`.`path`, `msProductFile`.`file`, `msProductFile`.`type`, `msProductFile`.`createdon`, `msProductFile`.`createdby`, `msProductFile`.`rank`, `msProductFile`.`url`, `msProductFile`.`properties`, `msProductFile`.`hash` FROM `1z6fJ8nTV9NY_ms2_product_files` AS `msProductFile` WHERE ( `msProductFile`.`product_id` = 3 AND `msProductFile`.`parent` = 0 ) ORDER BY msProductFile.rank ASC "
0.0000260: SQL executed
0.0000372: Total rows: 3
0.0000069: Rows fetched
0.0000150: Returning raw data
0.0000010: Fetching thumbnails
0.0011487: Time to load products options
0.0603931: Total time
6 291 456: Memory usageПочему так происходит?
Судя по логам, при подключении галереи в чанке, вызов msProducts превращается в вызов msGallery????
Комментарии: 12
Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
Пришлось вызовы галерей переписать на modx-теги
Подскажите решение, если есть, пожалуйста.
Если нужно быстрое решение, придётся просто написать свой сниппет для выборки нужных картинок — типа такого:
В то время как ms2Gallery делает умнее:
То есть, создаёт свой экземпляр и никому не мешает.
Кому не лень — проверьте, пожалуйста, и пришлите PR в репозиторий ms2.
Видимо я просто забыл про этот нюанс при рефакторинге.