Jump to content

REGE

Members
  • Posts

    54
  • Joined

  • Last visited

  • Days Won

    2

REGE last won the day on February 17

REGE had the most liked content!

Profile Information

  • Location
    Poland
  • Activity
    Other

Recent Profile Visitors

3,710,546 profile views

REGE's Achievements

  1. Is there a hook triggered on duplicate product? I found hookActionAdminProductsControllerDuplicateAfter or hookActionAdminControllerDuplicateAfter described on the Internet but they don't work.
  2. I don't know if you've solved this problem, but I have a solution - maybe it will be useful to someone. public function hookActionGetAdminToolbarButtons(array $params) : void { // Get the collection of toolbar buttons $toolbar = $params['toolbar_extra_buttons_collection']; // Create a new button $newButton = new \PrestaShop\PrestaShop\Core\Action\ActionsBarButton( 'btn-secondary', // CSS class for the button ['href' => 'your_link_here'], // Link where the button redirects 'Your button text' // Text displayed on the button ); // Add the new button to the collection $toolbar->add($newButton); } You don't say what version of PrestaShop you are using, but it definitely works on v8.1.3.
  3. Is there a hook triggered when saving/updating a combination in the product administration form? Something similar to hookActionObjectProductUpdateBefore? I would like to dynamically change some combination values as I save them I tried hookActionObjectProductAttributeUpdateBefore but it is not triggered. I also tried to do it via hookActionObjectProductUpdateBefore, but it is only triggered when saving the product. When saving a combination, it is not triggered. Maybe there is another way this can be done?
  4. I found a solution. I replaced Translator with TranslatorInterface and it started working. <?php namespace MyModule\Controller; use Symfony\Contracts\Translation\TranslatorInterface; final class CustomModuleController { /** @var TranslatorInterface */ private TranslatorInterface $translator; public function __construct(TranslatorInterface $translator) { $this->translator = $translator; } public function foo() { $this->text = $this->translator->trans('My text to translate', [], 'Modules.Mymodule.Custommoduleclass'); } }
  5. W x13.pl wypuścili właśnie aktualizację swojego modułu: [Aktualizacja] **EU Cookies - baner z funkcją blokowania ciastek - Consent Mode V2** Właśnie zaktualizowaliśmy moduł, dzięki któremu Twój klient może wybrać z jakich ciastek chce korzystać w Twoim sklepie. Pewnie słyszałeś o ważnej zmianie, która wchodzi w życie z początkiem marca - jeśli korzystasz z analytics, adsów, remarketingu itd., musisz mieć wdrożone CM V2 w swoim sklepie! Wdrożenie naszego rozwiązania i konfiguracja go pomoże spełnić te wymagania, a Twoje reklamy nie ucierpią. Najważniejsza zmiany tej wersji to dodanie pełnej kompatybilności z Consent Mode V2 Zapraszamy do pobrania najnowszej wersji dodatku: https://x13.pl/moduly-prestashop/eu-cookies-baner-z-funkcja- blokowania-2022.html
  6. Thank you for your answer. Currently I've modified them using JS. When I have more time I will dig into the code.
  7. I would like to test the module before purchasing it, but the demo doesn't seem to work. When trying to generate a description, name, etc. for a product, the module returns the error There was an error while generating content!.
  8. I have a module that adds an additional field to a product form. I have to check before saving whether it is completed. I do this with hookActionObjectProductUpdateBefore like this: public function hookActionObjectProductUpdateBefore($params): bool { $product = Tools::getValue('product'); $test_field = $product['description']['test_field']; // check if the variable exists and has a value if (empty($test_field)) throw new PrestaShopException('Missing test field'); return true; } In case of an error, the above method returns the following message: Throwing a PrestaShopException is fine for reporting system errors, but not ideal for presenting short error messages to the end user, especially in the context of input forms. Is it possible to pass the error to the product form in a more elegant form?
  9. I wrote a sample controller class for my module: <?php namespace MyModule\Controller; use PrestaShopBundle\Translation\Translator; final class CustomModuleController { /** @var Translator */ private Translator $translator; public function __construct(Translator $translator) { $this->translator = $translator; } public function foo() { $this->text = $this->translator->trans('My text to translate', [], 'Modules.Mymodule.Custommoduleclass'); } } I would like to translate it. Everything seems fine, but the text to be translated does not appear in BackOffice->International->Translations. However, the translations from the main module file mymodule.php are all there. Am I doing something wrong? How to translate texts from the module controller?
  10. Thank you very much for your answer, I was hoping to avoid overwriting the twig template and dataprovider. I give up changing the filter type for now.
  11. I am creating a module, I want to change `id_product` filter for the admin product grid from IntegerMinMaxFilterType to TextType. I managed to do it using hookActionProductGridDefinitionModifier: public function hookActionProductGridDefinitionModifier(array $params) { if (empty($params['definition'])) return; /** @var PrestaShop\PrestaShop\Core\Grid\Definition\GridDefinitionInterface $definition */ $definition = $params['definition']; $filters = $definition->getFilters(); $filters ->remove('id_product') ->add( (new Filter('id_product', TextType::class)) ->setTypeOptions([ 'required' => false, ]) ->setAssociatedColumn('id_product') ) ; } The filter field has changed, but after entering a value in it and clicking "Search", I get an error: Can you tell me what else I should change and where?
  12. I found a solution on PrestaShop GitHub: https://github.com/PrestaShop/PrestaShop/issues/22832 In product-prices.tpl file you need to change {$product.rounded_display_price} to {$product.price_amount}
  13. Hello, I added a test_field in /src/PrestaShopBundle/Form/Admin/Product/ProductInformation.php public function buildForm(FormBuilderInterface $builder, array $options) { . . . ->add('test_field', TranslateType::class, [ 'type' => FormType\TextType::class, 'constraints' => [ new Assert\Regex([ 'pattern' => '/[<>;=#{}]/', 'match' => false, ]), new Assert\NotBlank(), new Assert\Length(['min' => 3, 'max' => 50]), ], 'options' => [ 'attr' => [ 'placeholder' => $this->translator->trans('Enter your test text', [], 'Admin.Catalog.Feature'), 'class' => 'edit js-edit', 'counter' => 50, ], 'required' => true, ], 'locales' => $this->locales, 'label' => $this->translator->trans('Test field', [], 'Admin.Catalog.Feature'), ]) . . . } defined in /src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/product.html.twig {# PANEL ESSENTIALS #} {% block product_panel_essentials %} {% set formQuantityShortcut = form.step1.qty_0_shortcut is defined ? form.step1.qty_0_shortcut : null %} {{ include('@Product/ProductPage/Panels/essentials.html.twig', { . . . 'formTestField': form.step1.test_field, . . . }) }} {% endblock %} and set HTML in /src/PrestaShopBundle/Resources/views/Admin/Product/ProductPage/Panels/essentials.html.twig <div id="test_field" class="mb-3"> <strong>{{ form_label(formTestField) }}</strong> {{ form_widget(formTestField) }} </div> The field is displayed correctly. It's for JS use only - it doesn't write to the database. However, I have a problem with the translation. It should be on the Admin.Catalog.Feature domain but it's not showing in the translation interface. What am I doing wrong? How do I translate the label and placeholder for a newly added field to my language?
×
×
  • Create New...