joegalaxy Posted August 19, 2016 Share Posted August 19, 2016 I'm developing a module for a print service. It's quite big and we offer extensive product customization. We create combinations on the fly via ajax before adding the customized product to the cart. The system mostly works. There's only a problem with the size of the "reference" field, that is fixed at 32. I've increased field size on the relevant tables and overrided defaults in product.php but I always got the same error. This: $attribute = $product->addCombinationEntity(0,$price,0,0,0,1,null, $compiled_reference, null, null, null); Lead to this: [19-Aug-2016 19:12:24 UTC] PHP Fatal error: Uncaught exception 'PrestaShopException' with message 'Property Combination->reference length (163) must be between 0 and 32' in /home2/rhpratos/public_html/classes/ObjectModel.php:909 I suspect an error in overriding, any ideas? Many thanks. Link to comment Share on other sites More sharing options...
rocky Posted August 20, 2016 Share Posted August 20, 2016 Your override should look like this: <?php class Combination extends CombinationCore { public function __construct($id = null, $id_lang = null, $id_shop = null) { Combination::$definition['fields']['reference']['size'] = 200; parent::__construct($id, $id_lang, $id_shop); $this->def['fields']['reference']['size'] = 200; } } Change 200 to the size you want the reference field to be. You'll also need to edit the reference field in your database using phpMyAdmin if you haven't already so the references will fit in the database. Link to comment Share on other sites More sharing options...
joegalaxy Posted August 20, 2016 Author Share Posted August 20, 2016 I am overriding product.php: Class Product extends ProductCore { public static $definition = array( 'table' => 'product', 'primary' => 'id_product', 'multilang' => true, 'multilang_shop' => true, 'fields' => array( /* Classic fields */ 'id_shop_default' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_manufacturer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_supplier' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), why is my approach wrong? Link to comment Share on other sites More sharing options...
rocky Posted August 20, 2016 Share Posted August 20, 2016 Changing the size of the reference field in the Product class will affect the product reference only, not the combination reference. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now