Forum

Thread tagged as: Addons, Meta, Shop

Perch Shop - Featured Product on Home Page

Hi Everyone,

Using a checkbox on the Perch Shop product admin template, when ticked, I would like this product to become a featured product on the home page.

I've tried using perch_content_custom and perch_shop_custom but can't seem to get it to work.

Is there a special way this has to be done in order to repeat content from a product in Shop, rather than in the normal way to reuse content in a region?

Many thanks as always

Glen

Glen Piggott

Glen Piggott 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

No, there shouldn't be anything special.

Can you show us what you're doing and how it's failing?

Thanks Drew.

This is what I'm trying...

    perch_shop_product('Products', array(
        'filter'=>'featured',
        'match'=>'eq',
        'value'=>'true',
        'template'=>'featured_products.html'
    ));

Debug...

SELECT * FROM perch2_pages WHERE pagePath='/index.php' LIMIT 1
[1] SELECT * FROM perch2_shop_cart WHERE cartID=11
[1] SELECT * FROM perch2_shop_cart WHERE cartID=11
Using template: /templates/pages/attributes/seo.html
[4] SELECT regionKey, regionHTML FROM perch2_content_regions WHERE regionPage='/index.php' OR regionPage='*' ORDER BY regionPage DESC
[11] 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
[11] 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
[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='_id' AND idx.itemID IN ('1', '10', '11', '14', '15', '4', '5', '6', '7', '8', '9') AND idx.itemID IN ('1', '10', '11', '14', '15', '4', '5', '6', '7', '8', '9') WHERE 1=1 AND ((idx.indexKey='featured' AND idx.indexValue='true')) AND idx.itemID=idx2.itemID AND idx.itemKey=idx2.itemKey ) as tbl WHERE (productDeleted IS NULL) GROUP BY itemID, sortval ORDER BY sortval ASC
[33] SELECT DISTINCT settingID, settingValue FROM perch2_settings WHERE userID=0
Using template: /templates/shop/featured_products.html
[1] SELECT regionID, regionTemplate, regionPage, regionRev AS rev FROM perch2_content_regions WHERE regionKey='Special Offer Banner' AND (regionPage='/index.php' 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=1 AND idx.itemRev=6)) 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/special_offer_banner_home.html
Drew McLellan

Drew McLellan 2638 points
Perch Support

In your template, does the featured field get set to the string value true ?

Thanks Drew - it does now.

There was no value set in the template tag.

Glen

PS - Have you seen my other thread about rewrite for Perch Shop?...

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, it looks like you've been discussing how to create rewrite rules. That's absolutely fine to discuss with other users, but it's not something we can dedicate time to helping with as it's not Perch.

Rewrite rules can be hard, which is why Runway has built in routing. That's our solution for URL rewriting.

Ok, thanks Drew