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 !