perch_shop_product_variants() returning not returning anything...

  • Hi,


    I have some code:


    Code
    1. PerchUtil::mark('A');
    2. //get array of variants - needed to get exact prices as they are set per variant
    3. $variants_array = perch_shop_product_variants('201920-season-series', [
    4. 'skip-template' => 'true',
    5. 'sort-order' => 'ASC'
    6. ], true);
    7. PerchUtil::mark('B');

    I expect that would return an array. But I'm getting nothing back from it.



    Here's what debug shows:


    Code
    1. 0.4842 0.0064 ------------------------------ A ------------------------------
    2. 0.4842 0 [1] SELECT * FROM perch2_shop_products WHERE productSlug='201920-season-series' AND productDeleted IS NULL LIMIT 1
    3. 0.4894 0.0052 [276] SELECT DISTINCT idx.itemID FROM perch2_shop_index idx JOIN perch2_shop_products main ON idx.itemID=main.productID AND idx.itemKey='productID' AND ((idx.indexKey='status' AND idx.indexValue='1')) GROUP BY idx.itemID HAVING COUNT(idx.itemID)=1
    4. 0.4963 0.0069 [38] SELECT DISTINCT idx.itemID FROM perch2_shop_index idx JOIN perch2_shop_products main ON idx.itemID=main.productID AND idx.itemKey='productID' AND ((idx.indexKey='parentID' AND idx.indexValue='')) GROUP BY idx.itemID HAVING COUNT(idx.itemID)=1
    5. 0.4974 0.0011 [nil] SELECT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM perch2_shop_index idx JOIN perch2_shop_products main ON idx.itemID=main.productID AND idx.itemKey='productID' JOIN perch2_shop_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='productID' AND idx2.indexKey='title' AND idx.itemID IN ('110', '141', '142', '143', '144', '145', '146', '147', '148', '170', '171', '172', '173', '174', '175', '176', '177', '178', '179', '180', '181', '183', '184', '185', '186', '187', '188', '189', '190', '191', '192', '193', '194', '195', '196', '197', '198', '199', '200', '201', '202', '203', '204', '205', '206', '225', '226', '227', '228', '229', '230', '231', '232', '233', '234', '235', '236', '237', '238', '239', '240', '241', '242', '243', '244', '245', '246', '247', '248', '249', '250', '251', '252', '253', '254', '255', '256', '257', '258', '259', '260', '261', '262', '263', '264', '265', '266', '267', '268', '269', '270', '271', '272', '273', '274', '275', '276', '277', '278', '279', '280', '281', '282', '283', '284', '285', '286', '287', '288', '289', '290', '291', '292', '293', '294', '295', '296', '297', '298', '299', '300', '301', '302', '303', '304', '305', '306', '307', '308', '309', '310', '311', '312', '313', '314', '315', '316', '317', '318', '319', '320', '321', '322', '323', '324', '325', '326', '327', '328', '329', '330', '331', '332', '333', '334', '335', '336', '337', '338', '339', '340', '341', '342', '343', '344', '345', '346', '347', '348', '349', '350', '351', '352', '353', '354', '355', '356', '357', '358', '359', '360', '361', '362', '363', '364', '365', '366', '367', '368', '369', '370', '371', '372', '373', '374', '375', '376', '377', '378', '379', '380', '381', '382', '383', '384', '385', '386', '387', '388', '389', '390', '391', '392', '393', '394', '395', '396', '397', '398', '399', '400', '401', '402', '403', '404', '405', '406', '407', '408', '409', '410', '411', '412', '413', '414', '415', '416', '417', '418', '419', '420', '421', '422', '423', '424', '425', '426', '427', '428', '429', '430', '431', '432', '433', '436', '439', '440', '441', '442', '443', '444', '445', '446', '447', '448', '449', '450', '451', '464', '471', '484', '489', '536', '541', '550', '563') AND idx.itemID NOT IN ('102', '106', '110', '170', '207', '217', '224', '228', '229', '230', '231', '232', '233', '314', '333', '358', '359', '408', '415', '428', '433', '436', '439', '448', '449', '450', '451', '464', '471', '484', '489', '536', '541', '550', '563', '59', '84', '95') WHERE 1=1 AND ((idx.indexKey='parentID' AND idx.indexValue=451)) AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID, idx2.indexValue, productID ) as tbl WHERE (productDeleted IS NULL) GROUP BY itemID, sortval ORDER BY sortval ASC
    6. 0.5097 0.0123 Using template: /templates/shop/products/variant_list.html
    7. 0.5098 0 ------------------------------ B ------------------------------

    When I change the product slug to last year's product:

    Code
    1. PerchUtil::mark('A');
    2. //get array of variants - needed to get exact prices as they are set per variant
    3. $variants_array = perch_shop_product_variants('201819-season-series', [
    4. 'skip-template' => 'true',
    5. 'sort-order' => 'ASC'
    6. ], true);
    7. PerchUtil::mark('B');

    I correctly get an array back:

    Code
    1. 0.5419 0.0071 ------------------------------ A ------------------------------
    2. 0.542 0.0001 [1] SELECT * FROM perch2_shop_products WHERE productSlug='201920-season-series' AND productDeleted IS NULL LIMIT 1
    3. 0.547 0.005 [276] SELECT DISTINCT idx.itemID FROM perch2_shop_index idx JOIN perch2_shop_products main ON idx.itemID=main.productID AND idx.itemKey='productID' AND ((idx.indexKey='status' AND idx.indexValue='1')) GROUP BY idx.itemID HAVING COUNT(idx.itemID)=1
    4. 0.5538 0.0068 [38] SELECT DISTINCT idx.itemID FROM perch2_shop_index idx JOIN perch2_shop_products main ON idx.itemID=main.productID AND idx.itemKey='productID' AND ((idx.indexKey='parentID' AND idx.indexValue='')) GROUP BY idx.itemID HAVING COUNT(idx.itemID)=1
    5. 0.555 0.0012 [nil] SELECT tbl.* FROM ( SELECT idx.itemID, main.*, idx2.indexValue as sortval FROM perch2_shop_index idx JOIN perch2_shop_products main ON idx.itemID=main.productID AND idx.itemKey='productID' JOIN perch2_shop_index idx2 ON idx.itemID=idx2.itemID AND idx.itemKey='productID' AND idx2.indexKey='title' AND idx.itemID IN ('110', '141', '142', '143', '144', '145', '146', '147', '148', '170', '171', '172', '173', '174', '175', '176', '177', '178', '179', '180', '181', '183', '184', '185', '186', '187', '188', '189', '190', '191', '192', '193', '194', '195', '196', '197', '198', '199', '200', '201', '202', '203', '204', '205', '206', '225', '226', '227', '228', '229', '230', '231', '232', '233', '234', '235', '236', '237', '238', '239', '240', '241', '242', '243', '244', '245', '246', '247', '248', '249', '250', '251', '252', '253', '254', '255', '256', '257', '258', '259', '260', '261', '262', '263', '264', '265', '266', '267', '268', '269', '270', '271', '272', '273', '274', '275', '276', '277', '278', '279', '280', '281', '282', '283', '284', '285', '286', '287', '288', '289', '290', '291', '292', '293', '294', '295', '296', '297', '298', '299', '300', '301', '302', '303', '304', '305', '306', '307', '308', '309', '310', '311', '312', '313', '314', '315', '316', '317', '318', '319', '320', '321', '322', '323', '324', '325', '326', '327', '328', '329', '330', '331', '332', '333', '334', '335', '336', '337', '338', '339', '340', '341', '342', '343', '344', '345', '346', '347', '348', '349', '350', '351', '352', '353', '354', '355', '356', '357', '358', '359', '360', '361', '362', '363', '364', '365', '366', '367', '368', '369', '370', '371', '372', '373', '374', '375', '376', '377', '378', '379', '380', '381', '382', '383', '384', '385', '386', '387', '388', '389', '390', '391', '392', '393', '394', '395', '396', '397', '398', '399', '400', '401', '402', '403', '404', '405', '406', '407', '408', '409', '410', '411', '412', '413', '414', '415', '416', '417', '418', '419', '420', '421', '422', '423', '424', '425', '426', '427', '428', '429', '430', '431', '432', '433', '436', '439', '440', '441', '442', '443', '444', '445', '446', '447', '448', '449', '450', '451', '464', '471', '484', '489', '536', '541', '550', '563') AND idx.itemID NOT IN ('102', '106', '110', '170', '207', '217', '224', '228', '229', '230', '231', '232', '233', '314', '333', '358', '359', '408', '415', '428', '433', '436', '439', '448', '449', '450', '451', '464', '471', '484', '489', '536', '541', '550', '563', '59', '84', '95') WHERE 1=1 AND ((idx.indexKey='parentID' AND idx.indexValue=451)) AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey GROUP BY idx.itemID, idx2.indexValue, productID ) as tbl WHERE (productDeleted IS NULL) GROUP BY itemID, sortval ORDER BY sortval ASC
    6. 0.5663 0.0113 Using template: /templates/shop/products/variant_list.html
    7. 0.5664 0 ------------------------------ B ------------------------------

    When I switch to another product slug, I get an array returned as expected (too long to include debug here).



    When accessing the product for the slug '201920-season-series' elsewhere, everything about the product and it's variants seems correct. Was wondering if this was similar to this issue discussed on the old blog: http://forum.grabaperch.com/forum/01-04-2017-perch-variants


    Running Shop 1.2.6 and Perch Runway 3.1.2


    Thanks!