Jump to content

AdminManufacturer 1.7.6.3


theduder

Recommended Posts

Hello, i need your help -> 

 

My requirements is to extend Manufacturer with an extra field -> highlight . I need to add this field in the form, and in the manufacturer list. Also i need to mark just one highlight, so when i mark one, the other must be disabled.

My prestashop version is : 1.7.6.3

 

So i tried to modify it AdminManufacturersController, but i've find out that this way is deprecated: 

 

@deprecated since 1.7.6, to be removed in the next minor

 

So i've not found the proper way to do it within the Symfony -> PrestaShopBundle ..

 

 I'd be thankfully if you provide me, instructions, docs, or any clue to modify this "Controller" properly in the Symfony way.. 

 

Thanks in advance

 

Link to comment
Share on other sites

i've find out that there is some doc in this url: 

https://devdocs.prestashop.com/1.7/modules/sample_modules/grid-and-identifiable-object-form-hooks-usage/

And a github sample here: 

https://github.com/PrestaShop/demo-cqrs-hooks-usage-module/blob/master/ps_democqrshooksusage.php

so i've created a module to show the SWITCH for the new field, but something must be wrong with my code ->

 

<?php

        
    use PrestaShopBundle\Form\Admin\Type\SwitchType;    

    if (!defined('_PS_VERSION_')) {
        exit;
    }

    class ExtraManufacturer extends Module
    {
        public function __construct()
        {
            $this->name = 'extramanufacturer';
            $this->tab = 'administration';
            $this->version = '1.0.0';
            $this->author = 'mine';
            $this->need_instance = 0;
            $this->ps_versions_compliancy = [
                'min' => '1.7',
                'max' => _PS_VERSION_
            ];
            $this->bootstrap = true;

            parent::__construct();

            

            $this->displayName = $this->getTranslator()->trans(
                'Manufacturer extra',
                [],
                'Modules.Extramanufacturer.Admin'
            );

            $this->description = $this->getTranslator()->trans(
                'Manufacturer extra',
                [],
                'Modules.Extramanufacturer.Admin'
            );

            $this->confirmUninstall = $this->l('Are you sure you want to uninstall?');

            if (!Configuration::get('MYMODULE_NAME')) {
                $this->warning = $this->l('No name provided');
            }
        }

        public function install()
        {
            return parent::install() && $this->registerHook('actionManufacturerFormBuilderModifier');
    
        }

        public function uninstall()
        {
            return parent::uninstall();
        }

        

        public function hookActionManufacturerFormBuilderModifier(array $params)
        {
            /** @var FormBuilderInterface $formBuilder */
            $formBuilder = $params['form_builder'];
            $formBuilder->add('is_highlighted', SwitchType::class, [
                'label' => $this->getTranslator()->trans('Hightlight', [], 'Modules.Extramanufacturer'),
                'required' => false,
            ]);                        
            
            $params['data']['is_highlighted'] = 1;

            $formBuilder->setData($params['data']);
        }
   


    }

 

 

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...