Jump to content

Unable to raise reference size to N chars


Recommended Posts

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

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

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

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