Forum

Thread tagged as: Question, Error, Shop

Perch Shop and Slugs

I'm trying to set up a page that I can then use to display separate product items when linked to.

Here is what I have in my product page (ink-item.php):

<?php
        perch_shop_products([
          'template' => 'products/full-product.html',
          'filter' => 'slug',
          'match' => 'eq',
          'value' => perch_get('product'),
          'count' => 1,
        ]);
?>

In my routes for the page I have used:

order/[slug:s]

I'm getting a 404 error. What am I doing wrong?

Here is my Degbug Code:

Debug Message
[30] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID ORDER BY pr.routeOrder ASC, p.pagePath ASC
Using master page: /templates/pages/errors/404.php
[1] SELECT * FROM perch2_pages WHERE pagePath='/errors/404' LIMIT 1
[34] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
[1] SELECT locationID FROM perch2_shop_tax_locations WHERE locationIsHome=1 LIMIT 1
INSERT INTO perch2_shop_cart(memberID,locationID,currencyID,cartPricing,cartProperties) VALUES(NULL,'1',47,'standard','[]')
[1] SELECT * FROM perch2_shop_cart WHERE cartID=9
[1] SELECT * FROM perch2_shop_cart WHERE cartID=9
Using template: /templates/pages/attributes/default.html
Using sub-template: /templates/pages/attributes/seo.html
Using sub-template: /templates/pages/attributes/facebook.html
Using sub-template: /templates/pages/attributes/twitter.html
Using sub-template: /templates/pages/attributes/article.html
[1] SELECT collectionID, collectionTemplate FROM perch2_collections WHERE collectionKey='Technology'
[1] SELECT * FROM ( SELECT idx.itemID, ci.collectionID, ci.itemJSON, idx2.indexValue as sortval FROM perch2_collection_index idx JOIN perch2_collection_items ci ON idx.itemID=ci.itemID AND idx.itemRev=ci.itemRev AND idx.collectionID=ci.collectionID JOIN perch2_collection_revisions cr ON idx.itemID=cr.itemID AND idx.itemRev=cr.itemRev AND idx.collectionID=ci.collectionID JOIN perch2_collection_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='title' WHERE (idx.collectionID=3) AND ((idx.indexKey='hide' AND idx.indexValue != 'true')) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, itemJSON, sortval ORDER BY sortval ASC
[1] Using template: /templates/content/tech/_tech_menu.html
[2] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/errors/404' OR regionPage='*' ORDER BY regionPage DESC
[1] SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Feedback' AND (regionPage='/errors/404' OR regionPage='*')
[1] SELECT * FROM ( SELECT idx.itemID, c.regionID, idx.pageID, c.itemJSON, idx2.indexValue as sortval FROM perch2_content_index idx JOIN perch2_content_items c ON idx.itemID=c.itemID AND idx.itemRev=c.itemRev AND idx.regionID=c.regionID JOIN perch2_content_index idx2 ON idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev AND idx2.indexKey='_order' WHERE ((idx.regionID=4 AND idx.itemRev=5)) AND idx.itemID=idx2.itemID AND idx.itemRev=idx2.itemRev ) as tbl GROUP BY itemID, pageID, itemJSON, sortval ORDER BY sortval ASC
[1] Using template: /templates/content/global/_feedback.html
Using sub-template: /templates/content/global/_feedback_form.html
Request time: 0.2931
Process time: 0.2859
Memory: 5.335
Array
(
    [type] => 8
    [message] => Undefined variable: domain
    [file] => /Users/danlee/Sites/Work/armstrong/login/templates/pages/errors/404.php
    [line] => 40
)
Dan Lee

Dan Lee 1 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

When do you get a 404?

Dan Lee

Dan Lee 1 points

The 404 shows when I try to view the product item. So for example when I try to view: https://armstrong.dev/inkjet-flex/order/2-metres-gbp-450-ijf002m/

2-metres-gbp-450-ijf002m is the slug

Drew McLellan

Drew McLellan 2638 points
Perch Support

It looks like your route needs to be:

inkjet-flex/order/[slug:s]