[email protected] Posted January 20, 2021 Share Posted January 20, 2021 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 More sharing options...
joseantgv Posted January 20, 2021 Share Posted January 20, 2021 It's not possible to override /src. Link to comment Share on other sites More sharing options...
[email protected] Posted January 20, 2021 Author Share Posted January 20, 2021 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 More sharing options...
joseantgv Posted January 20, 2021 Share Posted January 20, 2021 (edited) Check this: https://devdocs.prestashop.com/1.7/modules/sample-modules/grid-and-identifiable-object-form-hooks-usage/ https://devdocs.prestashop.com/1.7/development/components/grid/tutorials/modify-grid-in-module/ https://devdocs.prestashop.com/1.7/modules/concepts/templating/admin-views/ Edited January 21, 2021 by joseantgv (see edit history) 1 Link to comment Share on other sites More sharing options...
damian_pm Posted October 12, 2021 Share Posted October 12, 2021 (edited) 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 October 12, 2021 by damian_pm (see edit history) 4 Link to comment Share on other sites More sharing options...
mzfp Posted July 3, 2023 Share Posted July 3, 2023 This doesn't seem to work. I am attempting to override: src/Adapter/PDF/PDFGenerator.php I created the following file in my module: modules/mymodule/src/Adapter/PDF/PDFGenerator.php and in module services.yml: prestashop.adapter.pdf.pdf_generator: class: PrestaShop\Module\MyModule\Adapter\PDF\PDFGenerator arguments: - '@=service("prestashop.adapter.legacy.context").getContext().smarty' - '@=service("templateTypeProvider")' and the contents of the override file (modules/mymodule/src/Adapter/PDF/PDFGenerator.php) namespace PrestaShop\Module\MyModule\Adapter\PDF; use PrestaShop\PrestaShop\Adapter\Entity\PDF; use PrestaShop\PrestaShop\Core\PDF\PDFGeneratorInterface; use PrestaShop\PrestaShop\Core\PDF\PDFTemplateTypeProviderInterface; use Smarty; /** * Class PDFManager responsible for PDF generation using legacy code. */ final class PDFGenerator implements PDFGeneratorInterface { public function generatePDF(array $objectCollection) { print "override"; die; } } and of course composer.json contains the path to /src Any ideas what's going wrong? Link to comment Share on other sites More sharing options...
Ali Samie Posted July 11, 2023 Share Posted July 11, 2023 On 10/12/2021 at 2:42 PM, damian_pm said: -- copy of file OrderInvoicePdfGenerator.php and changed namespace to PrestaShop\Module\someModule\Controller; do you mean that we need to define a modern controller for an override? 1 Link to comment Share on other sites More sharing options...
idnovate.com Posted July 26, 2023 Share Posted July 26, 2023 On 7/11/2023 at 11:27 AM, Ali Samie said: do you mean that we need to define a modern controller for an override? You have to "decorate" it 😬 Link to comment Share on other sites More sharing options...
Maurice Posted November 16, 2023 Share Posted November 16, 2023 Good Day Guys I m really surprise about this issue: Prestashop Store : 1.7.8.10 i m unable to delete products as well i mean product will be deleted but i always get error so in debug Mode i found the following error: AdminProductDataUpdater->deleteProduct() received an unknown ID.[Exception 5005] public function deleteProduct($productId) { $product = new Product($productId); if (!Validate::isLoadedObject($product)) { throw new \Exception('AdminProductDataUpdater->deleteProduct() received an unknown ID.', 5005); } // dumb? no: delete() makes a lot of things, and can reject deletion in specific cases. // Hooks: will trigger actionProductDelete $result = $product->delete(); I kindly ask if above mentioned error can be even involved by Cloudflare service Thanks in adevance Link to comment Share on other sites More sharing options...
idnovate.com Posted November 24, 2023 Share Posted November 24, 2023 On 11/16/2023 at 12:58 PM, Maurice said: Good Day Guys I m really surprise about this issue: Prestashop Store : 1.7.8.10 i m unable to delete products as well i mean product will be deleted but i always get error so in debug Mode i found the following error: AdminProductDataUpdater->deleteProduct() received an unknown ID.[Exception 5005] public function deleteProduct($productId) { $product = new Product($productId); if (!Validate::isLoadedObject($product)) { throw new \Exception('AdminProductDataUpdater->deleteProduct() received an unknown ID.', 5005); } // dumb? no: delete() makes a lot of things, and can reject deletion in specific cases. // Hooks: will trigger actionProductDelete $result = $product->delete(); I kindly ask if above mentioned error can be even involved by Cloudflare service Thanks in adevance But which ID is received? Check the backtrace too. Link to comment Share on other sites More sharing options...
Maurice Posted November 24, 2023 Share Posted November 24, 2023 3 minuti fa, idnovate.com dice: But which ID is received? Check the backtrace too. this is the screen , while in php error i found: Script timed out before returning headers Thanks Link to comment Share on other sites More sharing options...
idnovate.com Posted December 22, 2023 Share Posted December 22, 2023 On 11/24/2023 at 12:18 PM, Maurice said: this is the screen , while in php error i found: Script timed out before returning headers Thanks But which is the origin of this request? It seems that you are trying to remove the product 66307. Is this ID correct? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now