🎉 Edit Your Mobile Application's Home using the Elementor Integration.

[Product page BO] Where to edit PrestaShop back-office product page?

Someone asked me a question about a twig page in PrestaShop BO (Back-office), she wanted to know how a part of the page is being rendered, and I thought that it would be good to share the steps that I took to find that view page. So, it's a tiny tutorial to find a piece of code.


What was the main question?

following code from \src\PrestaShopBundle\Resources\views\Admin\Product\ProductPage\Panels\pricing.html.twig

<div class="col-md-12 pt-1">
    {{ form_widget(pricingForm.on_sale) }}

above code render in backoffice as
<div class="col-md-12 pt-1">
<div class="checkbox">
<label><input type="checkbox" id="form_step2_on_sale" name="form[step2][on_sale]" value="1" checked="checked">
Display the "On sale!" flag on the product page, and on product listings.</label>
where can i edit this pricingForm.on_sale

My answer:
(checked on ps V1.7.8.6) pricingForm is a variable populated from a variable named: form.step2 at line 137, in this file: src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/product.html.twig but where does the form.step2 come from? the form variable comes from helper functions/methods/classes in Ps, not in a view file (tpl/twig).

Where did it pass to product.html.twig? take a look at this file: src/PrestaShopBundle/Controller/Admin/ProductController.php line 684

You see that there is a form builder (it comes from the new Ps structure, I mean symfony object pool/container, so the form object is being injected here).

Step 2: an object from ProductPrice is being used, so I think you need this class: src/PrestaShopBundle/Form/Admin/Product/ProductPrice.php

That was for product price, which is step 2, for other parts of the product page in back-office are same as the product price. Their classes are as follows:

  • Product information: ProductInformation class
  • Product price: ProductPrice class
  • Product quantity: ProductQuantity class
  • Product shipping: ProductShipping class
  • Product SEO: ProductSeo class

All of the classes are located at: src/PrestaShopBundle/Form/Admin/Product

Posted 1 year ago by Sam Berry