Jump to content

1.7.7 How should we override src\Adapter AdminProductDataProvider?


qian.li.ok@gmail.com

Recommended Posts

Hi, I want to add supplier reference in the back office Products page, and I have created my own module so I can keep the PrestaShop code untouched. I've managed to have the webpage updated with the new column by override the twig files in my module. 

But now the new column isn't populated with the supplier reference value, after some hours of tracing, I've found that src\Adapter\Product\AdminProductDataProvider's getCatalogProductList method needs to be updated to include the `supplier_reference`  column in the sqlSelect. It works by updating the PS source code, but I still hope that I can keep PS core sourcecode clean and untouched, so I'm wondering if anyone may recommend how I should override the Adapter DataProvider cleanly? Many thanks in advance. 

Link to comment
Share on other sites

Hi Jo, many thanks for your reply. In that case,  if we need to update the SELECT SQL to pull out more data, how should I do it without changing the PS DataProvider code? I really hope that I can do it without touching core source code. I've already created my own module to override a few twig files. Is that something possible we can achieve with my module? 

Link to comment
Share on other sites

  • 8 months later...

src/ can be override in module for example class /src/Adapter/PDF/OrderInvoicePdfGenerator.php:

 

file1: /modules/someModule/src/OrderInvoicePdfGenerator.php

-- copy of file OrderInvoicePdfGenerator.php and changed namespace to  PrestaShop\Module\someModule\Controller;

 

file2: /modules/someModul/config/services.yml:

services:
    _defaults:
      public: true
    prestashop.adapter.pdf.order_invoice_pdf_generator:
      class: PrestaShop\Module\someModule\Controller\OrderInvoicePdfGenerator
      arguments:
        - '@translator'

file3: /modules/someModul/composer.json

    "autoload": {
        "psr-4": {
            "PrestaShop\\Module\\someModule\\": "src/"
          },
...

 

Edited by damian_pm (see edit history)
  • Like 3
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...