Jump to content

[SOLUCIONADO]Override con nuevo campo en classe Product.php


Javier Delgado

Recommended Posts

Hola a todos. He añadido un nuevo campo (ubicacion) en la tabla productos, y tambien en el formulario tpl. El problema es que no consigo hacer un override del archivo product.php

 

El archivo esta situado en la carpeta /override/classes/product.php y es el siguiente:

 

<?php
 
if (!defined('_CAN_LOAD_FILES_'))
exit;
 
define('_CUSTOMIZE_FILE_', 0);
 
define('_CUSTOMIZE_TEXTFIELD_', 1);
   
class ProductOverride extends ProductCore
{
    
    public $ubicacion;
 
    
    protected static $cacheStock = array();
    public static $definition = array(
        'table' => 'product',
        'primary' => 'id_product',
        'multilang' => true,
        'multilang_shop' => true,
        'fields' => array(
            /* Classic fields */
            'ubicacion' =>                    array('type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 25),
            ),
    );
 
    
      
}
 
 
Tambien eliminio el archivo class_index.php de la carpeta cache.
 
Si añado el siguiente codigo  directamente en el archivo product.php si funciona, pero con tanta actualizaciones ya lo he tenido que intrucir a mano varias veces
 
Variables de los campos              public $ubicacion;
 
public static $definition = array(
'ubicacion' =>                    array('type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 25),
 
 
Alguna idea? Llevo 4 horas y ningun resultado. Gracias Y felices fiestas
Edited by Javier Delgado (see edit history)
Link to comment
Share on other sites

Prueba asi

<?php
class Product extends ProductCore
{

  public $nuevo_campo;
  public function __construct($id_product = null, $full = false, $id_lang = null, $id_shop = null, Context $context = null)
 {
  Product::$definition['fields']['nuevo_campo'] = array('type' => self::TYPE_STRING, 'validate' => 'isReference', 'size' => 25);
   parent::__construct($id_product, $full, $id_lang, $id_shop, $context);
 }
 }
Link to comment
Share on other sites

  • nadie locked this topic
Guest
This topic is now closed to further replies.
×
×
  • Create New...