Skip to Content
Menu
This question has been flagged
2 Replies
14209 Views

In the Odoo website ecommerce page /shop there is a product table that allow you to clic on the products to send you to the product page and be able to buy it. How could we use that product table to show it in the homepage or in the page you need?

This is a follow up question of the question https://www.odoo.com/es_ES/forum/help-1/question/how-to-believe-that-we-cant-use-our-products-on-website-homepage-93011

I will provide the answer and examples of how to do it. This will start a serie of qweb widgets posts that solve some situations that could be solved using the provided solutions

Avatar
Discard

Have a look at the controllers and the views in the module website_sale. The controllers do the redirection and the XML files create those views which show all products in combination with slug.

Author Best Answer

This could be solved in several ways like those referred in the follow up question, I have developed at least two ways to solve it. 

The first one and more simple way is to use the widget website_products. 
What widget is that?
It's a new widget that you could use after install the module solt_qweb_widgets from https://github.com/aek/odoo_public/tree/8.0/addons/solt_qweb_widgets
How can I use that widget to display the products?

<div class="row" t-esc="website" t-esc-options='{"widget":"website_products"}'/>

That will display all the products you have, 4 products per row and 20 total products per page like in the original shop

How can I filter what products will be displayed?

<div class="row" t-esc="website" t-esc-options='{"widget":"website_products", "domain": [["sale_ok", "=", true], ["service_quotation", "=", false], ["website_published", "=", true]]}'/>

As you see in the options you could specify a domain to filter the products to display

How can I change the template used?

There is a default template that it's a clean of the original website_sale.products template without the layout that will include the header and footer stuffs. You don't need to specify a template, but if you wanna provide your own template you could do it like this:

<div class="row" t-esc="website" t-esc-options='{"widget":"website_products", "template": "solt_qweb_widgets.website_products", "domain": [["sale_ok", "=", true], ["service_quotation", "=", false], ["website_published", "=", true]]}'/>

Take as a base the template solt_qweb_widgets.website_products for your modifications

See an example of how this works at my Odoo website version of my site: https://saas.soltein.org


The second way to display the products table it's using another qweb component of that module that allow you to use t-call-xpath to select the nodes from an existing template. It's functional but not complete yet. The use of that tag attribute in combination with a widget to provide the additional data that the template need to render will give the same result of the first way when you retrieve the content of the <t t-call="website.layout"> to remove the header and footer of the /shop page , but have more use for other scenarios

The first way it's the recommended one right now since it's in production right now.

Hope that helps to others, the same technique apply for whatever you want to use it on your page like partners that it's also available and you could see it on my site too

Cheers

Avatar
Discard

Hi,

The link you gave is broken.

I'd be interested to see your addon.

How can I find it now?

Kind regards,

Author

I have remove it from the repo, please drop me an email

Related Posts Replies Views Activity
1
Aug 17
3893
3
Apr 25
1274
2
Jan 25
2293
0
Oct 23
797
1
Dec 24
1731