NEW ref_ext for Attributes

This commit is contained in:
Cédric 2020-09-04 12:06:09 +02:00 committed by GitHub
parent 93959d34c8
commit b841a4354e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,6 +40,12 @@ class ProductAttribute extends CommonObject
* @var string
*/
public $ref;
/**
* External ref of the product attribute
* @var string
*/
public $ref_ext;
/**
* Label of the product attribute
@ -79,8 +85,8 @@ class ProductAttribute extends CommonObject
return -1;
}
$sql = "SELECT rowid, ref, label, rang FROM ".MAIN_DB_PREFIX."product_attribute WHERE rowid = ".(int) $id." AND entity IN (".getEntity('product').")";
$sql = "SELECT rowid, ref, ref_ext, label, rang FROM ".MAIN_DB_PREFIX."product_attribute WHERE rowid = ".(int) $id." AND entity IN (".getEntity('product').")";
$query = $this->db->query($sql);
if (!$this->db->num_rows($query)) {
@ -91,6 +97,7 @@ class ProductAttribute extends CommonObject
$this->id = $obj->rowid;
$this->ref = $obj->ref;
$this->ref_ext = $obj->ref_ext;
$this->label = $obj->label;
$this->rang = $obj->rang;
@ -106,7 +113,7 @@ class ProductAttribute extends CommonObject
{
$return = array();
$sql = 'SELECT rowid, ref, label, rang FROM '.MAIN_DB_PREFIX."product_attribute WHERE entity IN (".getEntity('product').')';
$sql = 'SELECT rowid, ref, ref_ext, label, rang FROM '.MAIN_DB_PREFIX."product_attribute WHERE entity IN (".getEntity('product').')';
$sql .= $this->db->order('rang', 'asc');
$query = $this->db->query($sql);
if ($query)
@ -115,6 +122,7 @@ class ProductAttribute extends CommonObject
$tmp = new ProductAttribute($this->db);
$tmp->id = $result->rowid;
$tmp->ref = $result->ref;
$tmp->ref_ext = $result->ref_ext;
$tmp->label = $result->label;
$tmp->rang = $result->rang;
@ -147,9 +155,9 @@ class ProductAttribute extends CommonObject
//Ref must be uppercase
$this->ref = strtoupper($this->ref);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_attribute (ref, label, entity, rang)
VALUES ('".$this->db->escape($this->ref)."', '".$this->db->escape($this->label)."', ".(int) $this->entity.", ".(int) $this->rang.")";
$sql = "INSERT INTO ".MAIN_DB_PREFIX."product_attribute (ref, ref_ext, label, entity, rang)
VALUES ('".$this->db->escape($this->ref)."', '".$this->db->escape($this->ref_ext)."', '".$this->db->escape($this->label)."', ".(int) $this->entity.", ".(int) $this->rang.")";
$query = $this->db->query($sql);
if ($query)
{
@ -183,8 +191,8 @@ class ProductAttribute extends CommonObject
$this->ref = trim(strtoupper($this->ref));
$this->label = trim($this->label);
$sql = "UPDATE ".MAIN_DB_PREFIX."product_attribute SET ref = '".$this->db->escape($this->ref)."', label = '".$this->db->escape($this->label)."', rang = ".(int) $this->rang." WHERE rowid = ".(int) $this->id;
$sql = "UPDATE ".MAIN_DB_PREFIX."product_attribute SET ref = '".$this->db->escape($this->ref)."', ref_ext = '".$this->db->escape($this->ref_ext)."', label = '".$this->db->escape($this->label)."', rang = ".(int) $this->rang." WHERE rowid = ".(int) $this->id;
if ($this->db->query($sql)) {
return 1;
}