Housy Posted October 30, 2015 Share Posted October 30, 2015 (edited) Hello guys Why am i not able to override PDFGenerator.php file? Under "Override/classes/pdf/" i have created the same file, which is PDFGenerator.php. Within that file i have put code below, because i want to define different header and footer height. The problem is, that override doesn't work at all, even if i disable cache and delete class_index.php file within cache directory. What am i doing wrong? Is there maybe a bug or something? <?php class PDFGeneratorCoreOverride extends PDFGeneratorCore { /* Header and Footer HEIGHT change */ public function writePage() { $this->SetHeaderMargin(10); $this->SetFooterMargin(30); $this->setMargins(10, 40, 10); $this->AddPage(); $this->writeHTML($this->content, true, false, true, false, ''); } } I am using Prestashop version 1.6.0.14. If i change code directly, it affects PDF, when it is exported. It works as it should but no results, when overriding PDFGenerator.php file. Overriding works good for modules as well.Could you guys take a look and help me here please?Thank you and best regards,Housy Edited October 30, 2015 by Housy (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted October 30, 2015 Share Posted October 30, 2015 This is not the correct code class PDFGeneratorCoreOverride extends PDFGeneratorCore { It should be this... class PDFGenerator extends PDFGeneratorCore { 1 1 Link to comment Share on other sites More sharing options...
Housy Posted October 30, 2015 Author Share Posted October 30, 2015 bellini13, it works properly now Could you please explain, why does it matter, how you name the class? How did you know that you have to name it PDFGenerator? You'll maybe laugh, but i'm not good with classes at all and i thought it doesn't matter how you name it and it is only important that you extend the right class ofcourse. Thank you for saving my ass, you are the man! Regards, Housy This is not the correct code class PDFGeneratorCoreOverride extends PDFGeneratorCore { It should be this... class PDFGenerator extends PDFGeneratorCore { Link to comment Share on other sites More sharing options...
Eolia Posted October 31, 2015 Share Posted October 31, 2015 Overrideclass should have the same name that the original class, it's all. In Prestashop, you can call native class adding Core suffix. if you write class PDFGeneratorCoreOverride extends PDFGeneratorCore {...} you create a new class, but not an override^^ 1 Link to comment Share on other sites More sharing options...
Housy Posted October 31, 2015 Author Share Posted October 31, 2015 (edited) But that is not true for overriding modules, right? Because for example, i have modified "cashondelivery.php" and within override php file i have code below and it works. The class name is different than original class but it does work. <?php class CashOnDeliveryOverride extends CashOnDelivery { // some code } Overrideclass should have the same name that the original class, it's all. In Prestashop, you can call native class adding Core suffix. if you write class PDFGeneratorCoreOverride extends PDFGeneratorCore {...} you create a new class, but not an override^^ Edited October 31, 2015 by Housy (see edit history) Link to comment Share on other sites More sharing options...
Eolia Posted October 31, 2015 Share Posted October 31, 2015 Yes because cashondelivery is not a core class^^ 1 Link to comment Share on other sites More sharing options...
Housy Posted November 3, 2015 Author Share Posted November 3, 2015 Yes because cashondelivery is not a core class^^ Thank you for the explanation 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