o0ozinkyo0o Posted October 30, 2013 Share Posted October 30, 2013 Hi all, I wanna modify Class but I don't wanna touch Original File. So I choose way write a file located at folder "Override". Example, I wanna override Class ProductDownload.php, I create a file ProductDownload.php in folder "Override/classes" and content below... <?php class ProductDownload extends ProductDownloadCore { public static function getIdFromIdProduct($id_product) { if (!ProductDownload::isFeatureActive()) return false; if (array_key_exists((int)$id_product, self::$_productIds)) return self::$_productIds[$id_product]; $sql = ' SELECT `id_product_download` FROM `'._DB_PREFIX_.'product_download` WHERE `id_product` = '.(int)$id_product.' AND `active` = 1 '; $res = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); foreach($res as $re){ self::$_productIds[$id_product][] = $re; } return self::$_productIds[$id_product]; } } ?> But my ProductDownload.php code is like above, not change. Can anyone help me, is there any other additional steps needed to override? Link to comment Share on other sites More sharing options...
El Patron Posted October 30, 2013 Share Posted October 30, 2013 when manually installing an override you must then delete cache/class_index.php then it will recognize your override Link to comment Share on other sites More sharing options...
o0ozinkyo0o Posted October 30, 2013 Author Share Posted October 30, 2013 when manually installing an override you must then delete cache/class_index.php then it will recognize your override OH! I got it! Thanks so much! And now i want to override file tpl. Not .tpl of module. Just .tpl example: virtualproduct.tpl or orderdetail.tpl Can you help me. Thanks U very much! Link to comment Share on other sites More sharing options...
El Patron Posted October 30, 2013 Share Posted October 30, 2013 you are welcome, glad I could help. Note: when a module has an override deleting that file is not required. as for 'other' overrides etc. please review here http://doc.prestashop.com/display/PS15/Overriding+default+behaviors#Overridingdefaultbehaviors-Overridingotherbehaviors Link to comment Share on other sites More sharing options...
o0ozinkyo0o Posted October 30, 2013 Author Share Posted October 30, 2013 It's use hooks? Link to comment Share on other sites More sharing options...
vekia Posted October 30, 2013 Share Posted October 30, 2013 hooks? what you mean ? 1 Link to comment Share on other sites More sharing options...
o0ozinkyo0o Posted October 30, 2013 Author Share Posted October 30, 2013 Maybe I wrong... Overriding other behaviorsPrestaShop has certain files you can use to override elements such as displaying redirections (Tools.php) and measuring hook execution time (_Module.php), etc. you can enable them by removing the "_" prefix. For instance, rename _Tools.php into Tools.php. If there already exists aTools.php override, you will have to merge it with yours. It not say about .tpl files... Anybody help me? Link to comment Share on other sites More sharing options...
El Patron Posted October 30, 2013 Share Posted October 30, 2013 Maybe I wrong... It not say about .tpl files... Anybody help me? you need to keep reading, seems you gave up to soon Link to comment Share on other sites More sharing options...
o0ozinkyo0o Posted October 31, 2013 Author Share Posted October 31, 2013 Ok! By creating same file in "Override' folder and change path file tpl in Controller And I got It! Thanks very much with your support. Link to comment Share on other sites More sharing options...
Recommended Posts