Jump to content

Using EAN13 Field for Something Else


rseigel

Recommended Posts

Hi all,

 

I'm using my EAN13 field to insert the Amazon ASIN number instead.

 

I accomplished this by changing line 279 in classes/Product.php from:

'ean13' => array('type' => self::TYPE_STRING, 'validate' => 'isean13', 'size' => 13),

to:

'ean13' => array('type' => self::TYPE_STRING, 'validate' => 'isString', 'size' => 10),

So far so good.

 

Now I also need to be able to reuse the EAN13 field in COmbinations for the same purpose (in this case sizes).

 

I can't seem to locate the file (I can't find another instance of validation in Product.php so I have to assume it's in another file) that contains the validation for the EAN13 field in combinations.

 

Does anyone know where I should look?

 

Thanks,

 

Ron

Link to comment
Share on other sites

Not that I can recommend what you're doing - you should really look at adding an additional field... but.......

 

Wouldn't it just have been much simpler (and less destructive of the core files) just to add an override for the validation? Just stick this in a file called:

 /override/classes/Validate.php

and stop editing those core files :lol:

<?php
class Validate extends ValidateCore
{
       /*
        * Pretend that we're really checking an ean
        * but treat a string as valid
        *
        */
	public static function isEan13($ean13)
	{
		return is_string($ean13);
	}
}
Edited by Paul C (see edit history)
Link to comment
Share on other sites

Thanks very much for the help. You're absolutely correct about not touching core files. I knew better - was just looking for a shortcut.

 

For some reason your code still doesn't work for combinations. Still getting "Field ean13 is not valid".

 

There has to be another check somewhere for the EAN13 field in the combinations.  :huh:

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