kmb Posted October 7, 2014 Share Posted October 7, 2014 Hello everyone, I'm currently developping modules for prestashop and I use override to extend core classes. But sometimes, when I try to install a module that has overrides, I get PHP errors in the file that is located in the "override" folder of prestashop. When I look in this file I see that the code it contains is totally messed up. Here's an example: This is the file in the folder 'override/controllers/front' of my module <?php class Customer extends CustomerCore { /** @var int Object avatar number */ public $avatar_num; public function __construct( $id = null ) { self::$definition[ 'fields' ][ 'avatar_num' ] = array( 'type' => self::TYPE_INT ); parent::__construct( $id ); } public function getGenderName() { $genders = Gender::getGenders(); foreach ( $genders as $gender ) { if( $gender->id == $this->id_gender ) { return $gender->name; } } } public function getChildren() { $sql = 'SELECT * FROM `'._DB_PREFIX_.'customer_child` WHERE `customer_id` = \''.(int)$this->id.'\' ORDER BY `id` ASC'; return Db::getInstance()->ExecuteS( $sql ); } /** * Retrieve customers displayName (aka firstanme lastname) * * @static * @param $id * @return array */ public static function getCustomersDisplayNameById($id) { $sql = 'SELECT CONCAT( `firstname` , \' \', `lastname` ) AS displayName FROM `'._DB_PREFIX_.'customer` WHERE `id_customer` = \''.pSQL($id).'\' '.Shop::addSqlRestriction(Shop::SHARE_CUSTOMER); return Db::getInstance()->getValue($sql); } } And then, this is what I get in the folder 'override/controllers/front' of prestashop. class Customer extends CustomerCore { /** @var int Object avatar number */ } } } /** * Retrieve customers displayName (aka firstanme lastname) * * @static * @param $id * @return array } } Do you see anything wrong in my code ? Thank you in advance for your help ! Link to comment Share on other sites More sharing options...
tuk66 Posted October 9, 2014 Share Posted October 9, 2014 Not yours. PrestaShop has many override problems in 1.6 versions. I think it was bad up to 1.6.0.6 and then in 1.6.0.8. I have seen other crazy "overrides". This approach is definitely very unstable and buggy. 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