Jump to content

Classes override from module not working PS 1.5


gr4devel

Recommended Posts

Hi community.

Here's the problem: I've put an override > classes > Address.php in one of my modules because I need to set the phone a required field when creating an address.

I've added the 'required' keyword to the $definition in the override of AddressCore.

However it doesn't seem to be considered!

I've already tried to delete the class_index.php in the cache directory but nothing changes...

 

Can someone help me...I'm really frustrated :(

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

Thank you very much eleazar!

Unfortunately my goal is to force the insertion of a valid phone when creating an address in the BO.

In particular an address associated with a manufacturer.

 

However let me thank you again for your help! Thanks :)!!!

Link to comment
Share on other sites

Sorry for the lateness of my response Vekia :(.

You're right.

I was trying to do the override after the module installation.

However when I try to reinstall the module I get this error:

 

The following module(s) were not installed properly:

  • - mymoudulename :
    Unable to install override: Class AddressOverrideOriginal does not exist

As always thank you very much for your patience and your precious help :)!

Link to comment
Share on other sites

Sure :) here it is the Address.php that I placed inside my module override/classes/ dir.

 

<?php
class Address extends AddressCore
{
 public static $definition = array(
   'table' => 'address',
   'primary' => 'id_address',
   'fields' => array(
  'id_customer' =>    array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
  'id_manufacturer' =>  array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
  'id_supplier' =>    array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
  'id_warehouse' =>	 array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId', 'copy_post' => false),
  'id_country' =>	 array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
  'id_state' =>	   array('type' => self::TYPE_INT, 'validate' => 'isNullOrUnsignedId'),
  'alias' =>	    array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'required' => true, 'size' => 32),
  'company' =>	  array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 64),
  'lastname' =>	   array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
  'firstname' =>	  array('type' => self::TYPE_STRING, 'validate' => 'isName', 'required' => true, 'size' => 32),
  'vat_number' =>	 array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'),
  'address1' =>	   array('type' => self::TYPE_STRING, 'validate' => 'isAddress', 'required' => true, 'size' => 128),
  'address2' =>	   array('type' => self::TYPE_STRING, 'validate' => 'isAddress', 'size' => 128),
  'postcode' =>	   array('type' => self::TYPE_STRING, 'validate' => 'isPostCode', 'size' => 12),
  'city' =>		 array('type' => self::TYPE_STRING, 'validate' => 'isCityName', 'required' => true, 'size' => 64),
  'other' =>	    array('type' => self::TYPE_STRING, 'validate' => 'isMessage', 'size' => 300),
  'phone' =>	    array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'required', 'size' => 32),
  'phone_mobile' =>	 array('type' => self::TYPE_STRING, 'validate' => 'isPhoneNumber', 'required', 'size' => 32),
  'dni' =>	    array('type' => self::TYPE_STRING, 'validate' => 'isDniLite', 'size' => 16),
  'deleted' =>	  array('type' => self::TYPE_BOOL, 'validate' => 'isBool', 'copy_post' => false),
  'date_add' =>	   array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'copy_post' => false),
  'date_upd' =>	   array('type' => self::TYPE_DATE, 'validate' => 'isDateFormat', 'copy_post' => false),
   ),
 );
}

 

The only thing that I changed is the required in phone and phone_mobile fields.

Link to comment
Share on other sites

One thing.

I'm having some difficulties also in doing an override of the AdminOrderControllerCore.

I've placed my custom AdminOrderController.php file in the override/controllers/admin but it seems that it isn't considered at all :(.

 

If I need to open another topic for this problem please let me know so that I can keep the forum clean and coherent :).

Link to comment
Share on other sites

Sorry eleazar for my incredibly late response :(.

If I remove the /cache/class_index.php I get the following error when I load the FO:

 

Fatal error: Call to undefined method Address::getFirstCustomerAddressId() in /media/data/dev/sites/vdp/vdp/classes/controller/FrontController.php on line 241

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