Jump to content

Edit History

beubz2

beubz2


add image upload

I managed to display more or less what I wanted, but I don't think I followed the best practices. I still share my code and the result obtained, and leave the topic open if ever someone has a cleaner solution for me.

In classes/form/CustomerFormatter.php


        $groups = Group::getShopGroups($this->language->id);
        if ($genders->count() > 0) {
            $groupField = (new FormField())
                ->setName('id_default_group')
                ->setType('radio-buttons')
                ->setLabel(
                    $this->translator->trans(
                        'Statut',
                        [],
                        'Shop.Forms.Labels'
                    )
                );
            foreach ($groups as $group) {
                var_dump($group);
                $groupField->addAvailableValue($group->id);
            }
            $format[$groupField->getName()] = $groupField;
        }

And 

In classes/Group.php


    public static function getShopGroups($idLang = null)
    {
        if (null === $idLang) {
            $idLang = Context::getContext()->language->id;
        }
        $groups = new PrestaShopCollection('Group', $idLang);

        return $groups;
    }

 

Capture d’écran de 2021-12-06 12-38-15.png

beubz2

beubz2

I managed to display more or less what I wanted, but I don't think I followed the best practices. I still share my code and the result obtained, and leave the topic open if ever someone has a cleaner solution for me.

In classes/form/CustomerFormatter.php


        $groups = Group::getShopGroups($this->language->id);
        if ($genders->count() > 0) {
            $groupField = (new FormField())
                ->setName('id_default_group')
                ->setType('radio-buttons')
                ->setLabel(
                    $this->translator->trans(
                        'Statut',
                        [],
                        'Shop.Forms.Labels'
                    )
                );
            foreach ($groups as $group) {
                var_dump($group);
                $groupField->addAvailableValue($group->id);
            }
            $format[$groupField->getName()] = $groupField;
        }

And 

In classes/Group.php


    public static function getShopGroups($idLang = null)
    {
        if (null === $idLang) {
            $idLang = Context::getContext()->language->id;
        }
        $groups = new PrestaShopCollection('Group', $idLang);

        return $groups;
    }

 

beubz2

beubz2

I managed to display more or less what I wanted, but I don't think I followed the best practices. I still share my code and the result obtained, and leave the topic open if ever someone has a cleaner solution for me.

 

In classes/form/CustomerFormatter.php


        $groups = Group::getShopGroups($this->language->id);
        if ($genders->count() > 0) {
            $groupField = (new FormField())
                ->setName('id_default_group')
                ->setType('radio-buttons')
                ->setLabel(
                    $this->translator->trans(
                        'Statut',
                        [],
                        'Shop.Forms.Labels'
                    )
                );
            foreach ($groups as $group) {
                var_dump($group);
                $groupField->addAvailableValue($group->id);
            }
            $format[$groupField->getName()] = $groupField;
        }
In classes/Group.php


    public static function getShopGroups($idLang = null)
    {
        if (null === $idLang) {
            $idLang = Context::getContext()->language->id;
        }
        $groups = new PrestaShopCollection('Group', $idLang);

        return $groups;
    }

 

×
×
  • Create New...