Jump to content

Adapting custom field in custom module to new PS8.1+ standard


Recommended Posts

Hi all, I have a custom module, that I need to make compatible with PS8.1+. 

It uses the hookDisplayAdminProductsMainStepLeftColumnMiddle, which is deprecated. 
I tried to follow the tutorial here, but it doesn't work: it tells me that the service is invalid and the class (src/Form/Modifier/ProductFormModifier.php) doesn't exist. So I'm thinking I'm maybe doing something wrong in the bit where the example says DemoNewHooks\Form\Modifier\ProductFormModifier in the 'config/services.yml' file. Any one any idea? 

My services.yml looks like this: 

services:
    ModuleName\Form\Modifier\ProductFormModifier:
        autowire: true
        public: true
        arguments:
            $formBuilderModifier: '@form.form_builder_modifier'

And the `ProductFormModifier.php` resides in: 
./modules/modulename/src/Form/Modifier/ProductFormModifier.php
(as I understood it from the tutorial)

Link to comment
Share on other sites

  • 1 month later...
On 3/14/2025 at 4:00 PM, Betz Developer said:

Hi all, I have a custom module, that I need to make compatible with PS8.1+. 

It uses the hookDisplayAdminProductsMainStepLeftColumnMiddle, which is deprecated. 
I tried to follow the tutorial here, but it doesn't work: it tells me that the service is invalid and the class (src/Form/Modifier/ProductFormModifier.php) doesn't exist. So I'm thinking I'm maybe doing something wrong in the bit where the example says DemoNewHooks\Form\Modifier\ProductFormModifier in the 'config/services.yml' file. Any one any idea? 

My services.yml looks like this: 

services:
    ModuleName\Form\Modifier\ProductFormModifier:
        autowire: true
        public: true
        arguments:
            $formBuilderModifier: '@form.form_builder_modifier'

And the `ProductFormModifier.php` resides in: 
./modules/modulename/src/Form/Modifier/ProductFormModifier.php
(as I understood it from the tutorial)

You are using the service method, but there's another approach that works as well.

 

To use it, you need to override the native Twig file in your module at the following path:

modulename/views/PrestaShop/Admin/Sell/Catalog/Product/edit.html.twig

 

Add the following hook after this line:

https://github.com/PrestaShop/PrestaShop/blob/8.1.0/src/PrestaShopBundle/Resources/views/Admin/Sell/Catalog/Product/edit.html.twig#L74 

 

{{ renderhook('hookDisplayAdminProductsMainStepLeftColumnMiddle', { 'id_product': productId }) }}

 

And adjust your content accordingly inside the hook.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...