Forum

Thread tagged as: Problem, Shop

Shop product data will not display inside a perch conditional filtered by catego...

Hi all,

I'm trying to get some product specific data to display inside a perch conditional. The template code I'm using is

<perch:categories id="category" set="products"> 
    <perch:if id="catPath" value="products/sparkling-presss/"> 
        <h3>Ingredients</h3>
        <p>
            <perch:shop id="ingredients" />
        </p>
    </perch:if> 
</perch:categories>

I know the conditional statement is working correctly because the h3 tag only appears for products in the category with catPath = products/sparkling-presss/.

I've also confirmed that <perch:shop id="ingredients" /> shows the correct text string if it's placed outside of the conditional statement.

Would appreciate any ideas to solve this please.

Diagnostics report

Health check

    Perch is up to date
    PHP 5.6.9-1+deb.sury.org~trusty+2 is up to date
    MySQL 5.6.10 is up to date
    No image processing library. Consider installing GD or ImageMagick for resizing images.
    File upload size is low. You can only upload files up to 2M.

Summary information

    Perch: 2.8.34, PHP: 5.6.9-1+deb.sury.org~trusty+2, MySQL: 5.5.49, with PDO
    Server OS: Linux, apache2handler
    Installed apps: content (2.8.34), assets (2.8.34), categories (2.8.34), jw_activity_log (1.0.0), perch_shop_orders (1.0.10), perch_shop_products (1.0.10), perch_shop (1.0.10), perch_members (1.5)
    App runtimes: <?php $apps_list = array( 'content', 'categories', 'perch_members', 'perch_shop', );
    PERCH_LOGINPATH: /perch
    PERCH_PATH: /vagrant/www/kingsdownwater/public_html/perch
    PERCH_CORE: /vagrant/www/kingsdownwater/public_html/perch/core
    PERCH_RESFILEPATH: /vagrant/www/kingsdownwater/public_html/perch/resources
    Image manipulation:
    PHP limits: Max upload 2M, Max POST 8M, Memory: 128M, Total max file upload: 2M
    F1: 6a33f95eca3667f9e0c39bf5ca2980fe
    Resource folder writeable: Yes
    HTTP_HOST: kingsdownwater.dev
    DOCUMENT_ROOT: /vagrant/www/kingsdownwater/public_html
    REQUEST_URI: /perch/core/settings/diagnostics/
    SCRIPT_NAME: /perch/core/settings/diagnostics/index.php
Martin Jewiss

Martin Jewiss 0 points

  • 4 years ago
Duncan Revell

Duncan Revell 78 points
Registered Developer

Have you checked the debug output for that page, to see what queries are being run against the database?

Drew McLellan

Drew McLellan 2638 points
Perch Support

To use that within the scope of the categories tags, you'll need to set scope-parent="true" and then use parent.ingredients

Duncan Revell said:

Have you checked the debug output for that page, to see what queries are being run against the database?

Thanks for your help Duncan.

I'm a designer not a developer - I can follow each line the debug message but don't know how to tell if it's working as expected. The pages, shop cart, shop product, categories, and shop currency tables are all being queried:

Debug Message
[1] SELECT * FROM perch2_pages WHERE pagePath='/shop/products.php' LIMIT 1
[1] SELECT * FROM perch2_shop_cart WHERE cartID=8
[1] SELECT * FROM perch2_shop_cart WHERE cartID=8
[1] 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='_id' WHERE 1=1 AND ((idx.indexKey='slug' AND idx.indexValue='kingsdown-rhubarb-sparkle-330ml-sk-rs-330')) 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 ASC
[28] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
[1] Using template: /templates/shop/products/product-detail.html
[1] SELECT * FROM perch2_categories ORDER BY catTreePosition ASC
[1] SELECT * FROM perch2_shop_currencies WHERE currencyID=47 LIMIT 1
Duncan Revell

Duncan Revell 78 points
Registered Developer

Hi Martin,

I certainly couldn't declare I know everything that is being reported in the debug - but sometimes something will jump out - a blatant error (in red) or no reference to the value you're expecting to see etc.

I've learned something from Drew's answer - everyday is a school day!

Drew McLellan said:

To use that within the scope of the categories tags, you'll need to set scope-parent="true" and then use parent.ingredients

Thanks for your help Drew - I missed your reply while writing my own.

I've added your solution to my code (and looked up other scope-parent documentation) but I'm still experiencing the same issue. The revised code is

<perch:categories id="category" set="products" scope-parent="true"> 
<perch:if id="catPath" value="products/sparkling-presss/"> 
<h3>Ingredients</h3>
<p>
<perch:shop id="parent.ingredients" />
</p>
</perch:if> 
</perch:categories>

Is there something I'm missing? I'm working with Perch, not Runway btw.

Thanks again for your help.

Drew McLellan

Drew McLellan 2638 points
Perch Support

What does <perch:showall /> output?

Your perch:shop tag might need to be a perch:category tag. showall will tell you that.

Drew McLellan said:

What does <perch:showall /> output?

Your perch:shop tag might need to be a perch:category tag. showall will tell you that.

Thanks so much Drew.

Your last suggestion was absolutely correct. showall returned perch_namespace: perch:category

I've got this working now and will also add <perch:showall /> to my standard debug procedure.

Thanks again.

I should also have said, please mark this thread as answered :-)