66 lines
2.2 KiB
PHP
66 lines
2.2 KiB
PHP
<?php
|
|
|
|
|
|
class XGpsrResponsibleEntityProductCustom extends ObjectModel
|
|
{
|
|
public $id;
|
|
public $x13gpsr_responsible_entity_product_custom;
|
|
public $id_product;
|
|
public $extra_information;
|
|
|
|
public $date_add;
|
|
public $date_upd;
|
|
|
|
public static $definition = [
|
|
'table' => 'x13gpsr_responsible_entity_product_custom',
|
|
'primary' => 'id_x13gpsr_responsible_entity_product_custom',
|
|
'multilang' => true,
|
|
'fields' => [
|
|
'id_product' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'],
|
|
'extra_information' => ['type' => self::TYPE_HTML, 'lang' => true],
|
|
'date_add' => ['type' => self::TYPE_DATE, 'validate' => 'isDate'],
|
|
'date_upd' => ['type' => self::TYPE_DATE, 'validate' => 'isDate']
|
|
],
|
|
];
|
|
|
|
public static function getEntityCustomInformationByProduct($productId, $langId = null, $returnAsObjectInstance = false)
|
|
{
|
|
$query = new DbQuery();
|
|
$query->select('pec.*, pecl.*');
|
|
$query->from('x13gpsr_responsible_entity_product_custom', 'pec');
|
|
$query->innerJoin('x13gpsr_responsible_entity_product_custom_lang', 'pecl', 'pec.id_x13gpsr_responsible_entity_product_custom = pecl.id_x13gpsr_responsible_entity_product_custom');
|
|
$query->where('pec.id_product = ' . (int) $productId);
|
|
|
|
if ($langId) {
|
|
$query->where('pecl.id_lang = ' . (int) $langId);
|
|
}
|
|
|
|
$result = Db::getInstance()->getRow($query);
|
|
|
|
if ($result && $returnAsObjectInstance) {
|
|
$entity = new XGpsrResponsibleEntityProductCustom($result['id_x13gpsr_responsible_entity_product_custom'], $langId);
|
|
|
|
return $entity;
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
public static function deleteByProductId($productId)
|
|
{
|
|
$query = new DbQuery();
|
|
$query->select('pec.id_x13gpsr_responsible_entity_product_custom');
|
|
$query->from('x13gpsr_responsible_entity_product_custom', 'pec');
|
|
$query->where('pec.id_product = ' . (int) $productId);
|
|
|
|
$result = Db::getInstance()->getValue($query);
|
|
|
|
if ($result) {
|
|
$entity = new XGpsrResponsibleEntityProductCustom($result);
|
|
$entity->delete();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|