Jump to content

Module's override are not correctly installed


kmb

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...