Forum

Thread tagged as: Problem, Runway, Shop

perch_shop_products category filtering

Hi,

I am filtering by category in perch_shop_products, and am getting items included that are not in the category. I have two categories:

watch-family/cube
watch-family/cubeline

When I do the following I get only products in the cubeline category, as expected:

perch_shop_products([
  'template' => 'products/category_grid',
  'category' => 'watch-family/cubeline',
]);

But if I do this then I get all the products in both the cube and the cubeline categories:

perch_shop_products([
  'template' => 'products/category_grid',
  'category' => 'watch-family/cube',
]);

I guess this is a matching issue, but I can't see where I can address it? Below are my diagnostics, and the debug from the page which is showing from both categories in error.

Thanks for any help

Mike

DEBUG

Time    Δ   Debug Message
0.3476  0   [41] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM trade_pages p LEFT JOIN trade_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC, p.pagePath ASC
0.3495  0.002   Matched route: shop-watches
0.3496  0.0001  Using master page: /templates/pages/shop.php
0.3497  0   Page arguments:
Array
(
    [0] => /shop-watches
)
0.3573  0.0076  [1] SELECT * FROM trade_members_sessions WHERE sessionID='3337414b6b3774d014cb3741ca7b25f420c86e3c' AND sessionHttpFootprint='b3a58872d9f3b39b7bf0db22a5bdc9b0ff7f2596' AND sessionExpires>'2017-02-13 11:23:46' LIMIT 1
0.3614  0.0041  User is logged in
0.3705  0.0091  [1] SELECT * FROM trade_pages WHERE pagePath='/shop' LIMIT 1
0.4 0.0295  [1] SELECT * FROM trade_shop_cart WHERE cartID=94769
0.4006  0.0006  [1] SELECT * FROM trade_shop_cart WHERE cartID=94769
0.448   0.0474  UPDATE trade_shop_cart SET cartPricing='trade' WHERE cartID='94769'
0.4488  0.0008  ------------------------------ Calculating cart ------------------------------
0.4489  0.0001  [1] SELECT * FROM trade_shop_cart WHERE cartID=94769
0.4814  0.0325  [1] SELECT * FROM trade_shop_cart WHERE cartID=94769
0.4888  0.0074  [1] SELECT * FROM trade_shop_tax_locations WHERE locationID=1 AND locationDeleted IS NULL LIMIT 1
0.4893  0.0005  [1] SELECT locationID FROM trade_shop_tax_locations WHERE locationIsHome=1 LIMIT 1
0.4897  0.0004  [1] SELECT * FROM trade_shop_tax_locations WHERE locationID=1 AND locationDeleted IS NULL LIMIT 1
0.4901  0.0005  [1] SELECT * FROM trade_shop_customers WHERE memberID=2319
0.4976  0.0075  [1] SELECT * FROM trade_shop_currencies WHERE currencyID=47 LIMIT 1
0.498   0.0004  [1] SELECT COUNT(productID) AS product_count, SUM(itemQty) AS item_count FROM trade_shop_cart_items WHERE cartID=94769
0.4984  0.0004  [41] SELECT DISTINCT settingID, settingValue FROM trade_settings WHERE userID=0
0.5036  0.0053  Tax mode: exc
0.5069  0.0032  [nil] SELECT * FROM trade_shop_cart_items WHERE cartID=94769 ORDER BY itemID ASC
0.5119  0.0051  UPDATE trade_shop_cart SET cartTotalItems=NULL, cartTotalProducts='0', cartTotalWithTax='0.00', cartTotalWithoutTax='0.00' WHERE cartID='94769'
0.5129  0.0009  [1] SELECT * FROM trade_shop_currencies WHERE currencyActive=1 AND currencyCode='GBP' LIMIT 1
0.5134  0.0006  UPDATE trade_shop_cart SET currencyID='47' WHERE cartID='94769'
0.514   0.0005  ------------------------------ Calculating cart ------------------------------
0.514   0.0001  [1] SELECT * FROM trade_shop_cart WHERE cartID=94769
0.5146  0.0005  [1] SELECT * FROM trade_shop_cart WHERE cartID=94769
0.5149  0.0003  [1] SELECT * FROM trade_shop_tax_locations WHERE locationID=1 AND locationDeleted IS NULL LIMIT 1
0.5152  0.0003  [1] SELECT locationID FROM trade_shop_tax_locations WHERE locationIsHome=1 LIMIT 1
0.5155  0.0003  [1] SELECT * FROM trade_shop_tax_locations WHERE locationID=1 AND locationDeleted IS NULL LIMIT 1
0.5158  0.0003  [1] SELECT * FROM trade_shop_customers WHERE memberID=2319
0.5162  0.0004  [1] SELECT * FROM trade_shop_currencies WHERE currencyID=47 LIMIT 1
0.5164  0.0003  [1] SELECT COUNT(productID) AS product_count, SUM(itemQty) AS item_count FROM trade_shop_cart_items WHERE cartID=94769
0.5167  0.0003  Tax mode: exc
0.5168  0   [nil] SELECT * FROM trade_shop_cart_items WHERE cartID=94769 ORDER BY itemID ASC
0.5173  0.0005  UPDATE trade_shop_cart SET cartTotalItems=NULL, cartTotalProducts='0', cartTotalWithTax='0.00', cartTotalWithoutTax='0.00' WHERE cartID='94769'
0.5189  0.0016  Using template: /templates/pages/attributes/default.html
0.5458  0.0269  [1] SELECT setID FROM trade_category_sets WHERE setSlug='clock-type' LIMIT 1
0.5463  0.0005  [3] SELECT main.* FROM trade_categories main WHERE 1=1 AND setID=10 ORDER BY catTreePosition ASC
0.5506  0.0043  [3] Using template: /templates/categories/category-select.html
0.554   0.0034  [1] SELECT setID FROM trade_category_sets WHERE setSlug='clock-family' LIMIT 1
0.5545  0.0005  [30] SELECT main.* FROM trade_categories main WHERE 1=1 AND setID=8 ORDER BY catTreePosition ASC
0.5563  0.0018  [30] Using template: /templates/categories/category-select-checkbox.html
0.5716  0.0154  [1] SELECT setID FROM trade_category_sets WHERE setSlug='clock-category' LIMIT 1
0.5722  0.0006  [15] SELECT main.* FROM trade_categories main WHERE 1=1 AND setID=9 ORDER BY catTreePosition ASC
0.5732  0.001   [15] Using template: /templates/categories/category-select.html
0.5889  0.0157  [1] SELECT setID FROM trade_category_sets WHERE setSlug='watch-family' LIMIT 1
0.5895  0.0006  [10] SELECT main.* FROM trade_categories main WHERE 1=1 AND setID=6 ORDER BY catTreePosition ASC
0.5915  0.002   [10] Using template: /templates/categories/category-select-checkbox.html
0.5983  0.0067  [1] SELECT setID FROM trade_category_sets WHERE setSlug='watch-strap' LIMIT 1
0.5988  0.0005  [6] SELECT main.* FROM trade_categories main WHERE 1=1 AND setID=5 ORDER BY catTreePosition ASC
0.5995  0.0007  [6] Using template: /templates/categories/category-select.html
0.6027  0.0032  [1] SELECT setID FROM trade_category_sets WHERE setSlug='watch-case-finish' LIMIT 1
0.6032  0.0005  [9] SELECT main.* FROM trade_categories main WHERE 1=1 AND setID=7 ORDER BY catTreePosition ASC
0.6042  0.001   [9] Using template: /templates/categories/category-select.html
0.6115  0.0073  [4] SELECT regionKey, regionHTML FROM trade_content_regions WHERE regionPage='/shop' OR regionPage='*' ORDER BY regionPage DESC
0.6157  0.0042  [1] SELECT setID FROM trade_category_sets WHERE setSlug='watch-family' LIMIT 1
0.6162  0.0005  [10] SELECT main.* FROM trade_categories main WHERE 1=1 AND setID=6 ORDER BY catTreePosition ASC
0.6175  0.0013  [10] Using template: /templates/categories/watch_families_nav.html
0.6232  0.0057  [1] SELECT setID FROM trade_category_sets WHERE setSlug='clock-type' LIMIT 1
0.6237  0.0005  [3] SELECT main.* FROM trade_categories main WHERE 1=1 AND setID=10 ORDER BY catTreePosition ASC
0.6242  0.0006  [3] Using template: /templates/categories/clock_types_nav.html
0.6272  0.0029  [1] SELECT pageID, pageParentID, pageDepth, pageTreePosition FROM trade_pages WHERE pagePath='/information' OR pageSortPath='/information' LIMIT 1
0.6277  0.0005  [4] SELECT * FROM trade_pages WHERE pageNew=0 AND pageHidden=0 AND pageTreePosition LIKE '000-008%' AND pageDepth >=1 AND pageDepth<=2 ORDER BY pageTreePosition ASC
0.6283  0.0006  [1] SELECT pageTreePosition FROM trade_pages WHERE pagePath='/shop' LIMIT 1
0.6286  0.0003  [1] SELECT pageID FROM trade_pages WHERE pageTreePosition IN ('000-003', '000') ORDER BY pageTreePosition DESC
0.629   0.0004  [3] Using template: /templates/navigation/dropdown-item.html
0.6327  0.0037  Using template: /templates/search/search-form.html
0.6465  0.0138  Using template: /templates/forms/sort.html
0.6522  0.0057  [12] SELECT DISTINCT idx.itemID FROM trade_shop_index idx JOIN trade_shop_products main ON idx.itemID=main.productID AND idx.itemKey='productID' AND ((idx.indexKey='_category' AND idx.indexValue LIKE 'products/watches%' OR idx.indexKey='_category' AND idx.indexValue='products/watches') OR (idx.indexKey='_category' AND idx.indexValue LIKE 'country/uk%' OR idx.indexKey='_category' AND idx.indexValue='country/uk') OR (idx.indexKey='_category' AND idx.indexValue LIKE 'watch-family/cube%' OR idx.indexKey='_category' AND idx.indexValue='watch-family/cube')) GROUP BY idx.itemID HAVING COUNT(idx.itemID)=3
0.6694  0.0172  [12] SELECT SQL_CALC_FOUND_ROWS DISTINCT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM trade_shop_index idx JOIN trade_shop_products main ON idx.itemID=main.productID AND idx.itemKey='productID' JOIN trade_shop_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='productID' AND idx2.indexKey='priority' AND idx.itemID IN ('382', '383', '384', '385', '386', '437', '515', '516', '517', '518', '519', '520') WHERE 1=1 AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey ) as tbl WHERE (productDeleted IS NULL AND productStatus=1 AND parentID IS NULL) GROUP BY itemID, sortval ORDER BY sortval * 1 ASC LIMIT 0, 24
1.758   1.0886  [1] SELECT FOUND_ROWS() AS `count`
1.7635  0.0055  [3] Using template: /templates/shop/products/category_grid.html
1.8497  0.0862  [0] SELECT setID FROM trade_category_sets WHERE setSlug='' LIMIT 1
1.8503  0.0005  [1] SELECT main.* FROM trade_categories main WHERE 1=1 AND (catPath='watch-family/cube/') ORDER BY catTreePosition ASC
1.851   0.0007  [3] Using template: /templates/categories/video.html
1.9014  0.0505  Request time: 1.9013
1.9015  0.0001  Process time: 1.8895
1.9016  0   Memory: 5.0907

DIAGNOSTICS

SUMMARY INFORMATION

Perch Runway: 2.8.34, PHP: 7.0.13, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: 241ae00989d1995ffcbbf63d579943635faf9972 $, with PDO
Server OS: Darwin, apache2handler
Installed apps: content (2.8.34), assets (2.8.34), categories (2.8.34), perch_forms (1.8.3), perch_shop_orders (1.0.11), perch_shop_products (1.0.11), perch_shop (1.0.11), perch_members (1.5), perch_mailchimp (3.0.1)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_forms', 'perch_mailchimp', 'perch_members', 'perch_shop' );
PERCH_LOGINPATH: /admin
PERCH_PATH: /Volumes/Data/g Websites/newgatetrade/newgate-trade/admin
PERCH_CORE: /Volumes/Data/g Websites/newgatetrade/newgate-trade/admin/core
PERCH_RESFILEPATH: /Volumes/Data/g Websites/newgatetrade/newgate-trade/admin/resources
Image manipulation: GD
PHP limits: Max upload 32M, Max POST 32M, Memory: 128M, Total max file upload: 32M
F1: 6a33f95eca3667f9e0c39bf5ca2980fe
Resource folder writeable: Yes
HTTP_HOST: newgatetrade.dev
DOCUMENT_ROOT: /Volumes/Data/g Websites/newgatetrade/newgate-trade
REQUEST_URI: /admin/core/settings/diagnostics/
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
Mike Harrison

Mike Harrison 37 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What happens when you include the trailing slash?

'category' => 'watch-family/cube/',

That fixes it - thanks. I didn't think that was necessary but does the trick!