Forum

Thread tagged as: Question, Shop

Runway and Shop 404 on product

Hi

This is only my second time on Runway and first using Runway and Shop and I'm getting a 404 when I try and view a product.

I'm using; <?php perch_shop_products();?> on the home page to display the products, and here is my list template;

<div class="col-sm-4 col-md-3">
    <div class="product-box">
        <div class="product-image">
            <a href="/shop/products/<perch:shop id="slug" type="slug" />/"><img src="<perch:shop type="image" id="image" label="Image" width="200" height="200" density="1.6" crop="true" />" class="img-responsive rounded-corners" /></a>
        </div>
        <div class="product-box-text text-center">
            <a class="btn btn-primary btn-lg btn-caps" href="/shop/products/<perch:shop id="slug" type="slug" />">VIEW</a>
        </div>
    </div>
</div>

and I've setup a Product page in Perch Runway which has; <?php perch_shop_product(); ?> with the url routing of 'shop/products'

In settings, Product url is set to '/shop/products/{slug}'

Summary information

Perch Runway: 3.0.4, PHP: 5.6.10, MySQL: mysqlnd 5.0.11-dev - 20120503 - $Id: 3c688b6bbc30d36af3ac34fdd4b7b5b787fe5555 $, with PDO
Server OS: Darwin, cgi-fcgi
Installed apps: content (3.0.4), assets (3.0.4), categories (3.0.4), perch_shop_orders (1.2), perch_shop_products (1.2), perch_shop (1.2), perch_members (1.6.1)
App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_members', 'perch_shop', );
PERCH_LOGINPATH: /perch
PERCH_PATH: /Users/hoops78/Documents/stotto/perch
PERCH_CORE: /Users/hoops78/Documents/stotto/perch/core
PERCH_RESFILEPATH: /Users/hoops78/Documents/stotto/perch/resources
Image manipulation: GD
PHP limits: Max upload 32M, Max POST 32M, Memory: 128M, Total max file upload: 32M
F1: 0c66c2e1f82f9e0b7617b2cb8270f2c7
Resource folder writeable: Yes
SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
REQUEST_URI: /perch/core/settings/diagnostics/
DOCUMENT_ROOT: /Users/hoops78/Documents/stotto
HTTP_HOST: stotto

But I'm getting a 404 error when I try and view the product(s). Am I missing something you need to do with Runway?

Wayne Hooper

Wayne Hooper 6 points

  • 4 years ago

Hi Wayne

Try using [slug:product] to get the product slug, rather than {slug}.

Jon

Thanks for the suggestion, but I still get a 404 doing that.

You probably also need to filter on the product function. I'm not sure what the default product function would do.

So something like:

    <?php

        perch_shop_product(perch_get('product'),[
            'template' => 'products/product_detail.html', // Your product detail template here
            'variants' => true, // Needed if you want to list the variants for the product as it's false by default
            'filter' => 'slug',
            'match' => 'eq',
            'value' => perch_get('product')
        ]); 
    ?>  

Thanks, but still goes to a 404...

So you have /shop/product/ set as the product page path

And the routing pointing to shop/[slug:product]?

If so have you checked that you've got no other routes set to that path structure confusing the issue?

Thats correct... I have /shop/product/ on the product page and updated the setting to shop/[slug:product]. I haven't got far with the site, so there isn't any other routes setup at the moment. Thought I found out the issue, as list.html references shop/products rather than shop/product, but changing it still 404's.

New list.html

<div class="col-sm-4 col-md-3">
    <div class="product-box">
        <div class="product-image">
            <a href="/shop/product/<perch:shop id="slug" type="slug" />/"><img src="<perch:shop type="image" id="image" label="Image" width="200" height="200" density="1.6" crop="true" />"class="img-responsive rounded-corners" /></a>
        </div>
        <div class="product-box-text text-center">
            <a class="btn btn-primary btn-lg btn-caps" href="/shop/product/<perch:shop id="slug" type="slug" />">VIEW</a>
        </div>
    </div>
</div>

Are you sure your route is set to shop/product/[slug:product] and not shop/products/[slug:product] – you started off the thread quoting "products".

You might be wise to set up routing on a standard page and see if that works first. Judging by a previous post you've had issues setting Runway & Shop up and this may be an ongoing issue.

Hi Jonathan

It was with an 's', but I changed it to shop/product/[slug:product] and I'm still getting a 404...

Drew McLellan

Drew McLellan 2638 points
Perch Support

What does debug say on the 404 page?

it says;

Debug Message - Perch Runway 3.0.4
[3] SELECT p.pagePath, pr.routePattern, pr.routeRegExp, p.pageTemplate, pr.routeOrder, s.settingValue AS siteOffline FROM perch2_pages p LEFT JOIN perch2_page_routes pr ON p.pageID=pr.pageID LEFT JOIN perch2_settings s ON s.settingID='siteOffline' UNION SELECT NULL AS pagePath, pr2.routePattern, pr2.routeRegExp, pr2.templatePath AS pageTemplate, pr2.routeOrder, NULL AS siteOffline FROM perch2_page_routes pr2 WHERE templateID!=0 ORDER BY routeOrder ASC, pagePath ASC
Using master page: /templates/pages/errors/404.php
[1] SELECT * FROM perch2_pages WHERE pagePath='/errors/404' LIMIT 1
[1] SELECT * FROM perch2_shop_cart WHERE cartID=181
[1] SELECT * FROM perch2_shop_cart WHERE cartID=181
[nil] SELECT * FROM perch2_shop_sales WHERE saleFrom<='2017-05-16 16:58:00' AND saleTo>'2017-05-16 16:58:00' AND saleActive=1 AND saleDeleted IS NULL ORDER BY saleOrder ASC
Using template: /templates/pages/attributes/seo.html
[4] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/errors/404' OR regionPage='*' ORDER BY regionPage DESC
[1] SELECT pageTreePosition FROM perch2_pages WHERE pagePath='/errors/404' OR pageSortPath='/errors/404' LIMIT 1
[1] SELECT * FROM perch2_pages WHERE pageNew=0 AND pageTreePosition IN ('000-002', '000') ORDER BY pageTreePosition
[1] Using template: /templates/navigation/breadcrumbs.html
[1] SELECT pageID FROM perch2_pages WHERE pagePath='/errors/404' LIMIT 1
INSERT INTO perch2_content_regions(regionKey,regionPage,regionHTML,regionOptions,pageID) SELECT 'footer' AS regionKey,'/errors/404' AS regionPage,'<!-- Undefined content: footer -->' AS regionHTML,'' AS regionOptions,'32' AS pageID FROM (SELECT 1) AS dtable WHERE ( SELECT COUNT(*) FROM perch2_content_regions WHERE regionKey='footer' AND (regionPage='/errors/404' OR regionPage='*') )=0 LIMIT 1
UPDATE perch2_content_regions SET regionOrder=0 WHERE regionPage='/errors/404' AND regionKey='Google Code in Body' LIMIT 1
UPDATE perch2_content_regions SET regionOrder=1 WHERE regionPage='/errors/404' AND regionKey='Main Navigation' LIMIT 1
UPDATE perch2_content_regions SET regionOrder=2 WHERE regionPage='/errors/404' AND regionKey='Error description' LIMIT 1
UPDATE perch2_content_regions SET regionOrder=3 WHERE regionPage='/errors/404' AND regionKey='footer' LIMIT 1
Request time: 0.0668
Process time: 0.0664
Memory: 5.6132

I know I need to edit the 404.php file as there are some regions missing that aren't needed.

Morning

I've tried re-looking at this with fresh eyes, but still getting a 404. As I've changed a few things, heres a re-cap;

I'm using; <?php perch_shop_products();?> on the home page to display the products, and here is my list template;

Here is my list.html;

<div class="col-sm-4 col-md-3">
    <div class="product-box">
        <div class="product-image">
            <a href="/shop/product/<perch:shop id="slug" type="slug" />/"><img src="<perch:shop type="image" id="image" label="Image" width="200" height="200" density="1.6" crop="true" />"class="img-responsive rounded-corners" /></a>
        </div>
        <div class="product-box-text text-center">
            <a class="btn btn-primary btn-lg btn-caps" href="/shop/product/<perch:shop id="slug" type="slug" />">VIEW</a>
        </div>
    </div>
</div>

and I've setup a Product page in Perch Runway which has;

<?php  perch_shop_product(perch_get('product')[
            'template' => 'products/product.html', 
            'variants' => true, 
            'filter' => 'slug',
            'match' => 'eq',
            'value' => perch_get('product') ]);  
        ?> 

with the url routing of 'shop/products'

and the product url in settings is set to 'shop/product/[slug:product]'

Debug and Diagnostics are the same as before

Drew McLellan

Drew McLellan 2638 points
Perch Support

What's the URL when you get a 404, and what does the corresponding route look like?

Hi Drew

The url is;

https://stotto/shop/product/ballast-stothg0004

for example, so it looks correct using the /shop/product/ starting and the product slug is correct.

Wayne

Drew McLellan

Drew McLellan 2638 points
Perch Support

What's the route that you're trying to match them with?

Drew McLellan said:

What's the route that you're trying to match them with?

Maybe thats what I'm missing. Is that something I should set?

I have setup a product page in Runway with the URL route of shop/product

Is this what you meant?

Hi Wayne

Are you sure you're not getting your page location settings the wrong way round? The route should contain the dynamic slug not the location path.

If your page path is shop/product/ then your route might be set to shop/product/[slug:product] as mentioned above a couple of days ago.

Here's a screengrab of the shop I am working on at the moment. Mine also has a brand page but it gives you the idea of how you might structure things.

Image

Hi Jonathan

I did have them the wrong way around.... I've now fixed this and instead of getting 404's I'm getting a white blank screen,which hopefully I can sort out... but progress. Thanks

Edit: Typo in product.php was causing white screen, all fixed now.

Wayne