Я хотел бы показать цены на все доступные товары для пользователей на странице, не связанной с магазином.
Если я смотрю код отображения товаров на странице магазина, он дает мне эту строку:
<span t-if="product.price" t-esc="product.price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
На другой моей странице я называю свои продукты, используя этот код:
<t t-set="products" t-value="request.env['product.template'].search([])"/>
<t t-foreach="products" t-as="product_template">
<span t-if="product_template.price" t-esc="product_template.price" t-options="{'widget': 'monetary', 'display_currency': website.currency_id}"/>
</t>
Это не отображает цену продукта. Если я удалю t-if="product_template.price"
, он отобразит 0.00 $
. Значит product_template.price
не установлен?
Должен ли я называть что-то вроде <t t-call="website_sale"/>
или что-то подобное?
Спасибо за вашу помощь!
Изменить:
На других страницах товаров классы называются js_sale
oe_website_sale
oe_product
oe_product_price
oe_price_h4
. Итак, я пробовал это:
<div id="wrap" class="js_sale">
<div class="oe_website_sale">
<t t-set="products" t-value="request.env['product.product'].search([['id', '=', 135]])"/>
<div t-foreach="products" t-as="product" class="oe_product oe_grid">
<div class="oe_product_price product_price">
<h4 class="oe_price_h4">
<span t-esc="product.price"/>
</h4>
</div>
</div>
</div>
</div>
Но это все еще не работает. Любая помощь, пожалуйста?