Jump to content

Problem override from module


MrGumby

Recommended Posts

I added some columns into database for storing additional data and I want to reach that data through adminController, I write Class and Controller override in /modules/my_module/override but when I try to run the controller, it throws exception:

Identifier or table format not valid for class Manufacturer
at line 189 in file classes/ObjectModel.php

As seen, I override Manufacturer class and AdminManufacturerController.

 

I added column 'ean_gpc' into 'ps_manufacturer' table. I store first 7 digits from ean there - this sequence should identifiy manufacturer - I want to be able to edit that sequence when edit manufacturer in back office. Therefore I create

 

class override

<?php
// my_module/override/classes/Manufacturer.php

class Manufacturer extends ManufacturerCore
{
	/** @var string EAN-GPC */
	public $ean_gpc;

	public function __construct($id = null, $id_lang = null)
	{
		self::$definition['fields']['ean_gpc'] = array('type' => self::TYPE_STRING, 'validate' => 'isUnsignedInt', 'size' => 7);
		parent::__construct($id, $id_lang);
	}
}

controller override

<?php
// my_module/override/controllers/admin/AdminManufacturersController.php

class AdminManufacturersController extends AdminManufacturersControllerCore
{
	
	public function renderForm()
	{
		// ...not changed

		$this->fields_form = array(
			'tinymce' => true,
			'legend' => array(
				'title' => $this->l('Manufacturers'),
				'icon' => 'icon-certificate'
			),
			'input' => array(
				// ...added one input nearly at the end of inputs:

				array(
					'type' => 'text',
					'label' => 'EAN-GPC',
					'name' => 'ean_gpc',
					'col' => 2,
					'hint' => $this->l('First 7 digits of EAN13 that identifies manufacturer')
				),

				// ... not changed
				)
			)
		);

		// ... not changed
	}
}

When i write this changes directly int PS core files (just for test), it works, but when I try to override from module, then it fails at following test in ObjectModel:

if (!Validate::isTableOrIdentifier($this->def['primary']) || !Validate::isTableOrIdentifier($this->def['table']))
 			throw new PrestaShopException('Identifier or table format not valid for class '.get_class($this));

Any suggestions?

 

Edit: type errors

Edited by MrGumby (see edit history)
Link to comment
Share on other sites

My brain betrayed me again. He and my eyes. I wrote wrong name of controllers folder inside module/override, and it gets me two days to find it! I should not bought this high DPI display.

 

Anyway, now it is working.

 

Sorry for wasting database.

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...