add empik module

This commit is contained in:
2025-05-30 09:08:26 +02:00
parent 87a41f4cfc
commit 56aa2cdc2d
1466 changed files with 138249 additions and 146 deletions

View File

@@ -0,0 +1,60 @@
<?php
class EmpikAction extends ObjectModel
{
const ACTION_OTHER = 'OTHER';
const ACTION_PRODUCT_EXPORT = 'PRODUCT_EXPORT';
const ACTION_OFFER_EXPORT = 'OFFER_EXPORT';
const ACTION_PRODUCT_EXPORT_INCLUDE = 'PRODUCT_EXPORT_INCLUDE';
const ACTION_PRODUCT_EXPORT_EXCLUDE = 'PRODUCT_EXPORT_EXCLUDE';
const STATUS_NEW = 'NEW';
const STATUS_COMPLETED = 'COMPLETE';
public $id_shop;
public $action = self::ACTION_OTHER;
public $status = self::STATUS_NEW;
public $id_import;
public $import_count;
public $date_start;
public $date_end;
public static $definition = [
'table' => 'empik_action',
'primary' => 'id_empik_action',
'fields' => [
'id_shop' => [
'type' => self::TYPE_INT,
'validate' => 'isUnsignedInt',
'required' => true,
],
'action' => [
'type' => self::TYPE_STRING,
'validate' => 'isCleanHtml',
],
'status' => [
'type' => self::TYPE_STRING,
'validate' => 'isCleanHtml',
],
'id_import' => [
'type' => self::TYPE_INT,
'validate' => 'isCleanHtml',
],
'import_count' => [
'type' => self::TYPE_INT,
'validate' => 'isCleanHtml',
],
'date_start' => [
'type' => self::TYPE_DATE,
'validate' => 'isDate',
'required' => true,
],
'date_end' => [
'type' => self::TYPE_DATE,
'validate' => 'isDate',
'required' => true,
],
],
];
}

View File

@@ -0,0 +1,30 @@
<?php
class EmpikActionLog extends ObjectModel
{
public $id_empik_action;
public $message;
public $date_add;
public static $definition = [
'table' => 'empik_action',
'primary' => 'id_empik_action_log',
'fields' => [
'id_empik_action' => [
'type' => self::TYPE_INT,
'validate' => 'isUnsignedInt',
'required' => true,
],
'message' => [
'type' => self::TYPE_STRING,
'validate' => 'isCleanHtml',
],
'date_add' => [
'type' => self::TYPE_DATE,
'validate' => 'isDate',
'required' => true,
],
],
];
}

View File

@@ -0,0 +1,87 @@
<?php
class EmpikOrder extends ObjectModel
{
public $id_order;
public $empik_order_reference;
public $empik_order_carrier;
public $empik_payment;
public $empik_carrier;
public $empik_pickup_point;
public $empik_vat_number;
public $date_add;
public static $definition = [
'table' => 'empik_orders',
'primary' => 'id_empik_order',
'fields' => [
'id_order' => [
'type' => self::TYPE_INT,
'validate' => 'isUnsignedInt',
'required' => true,
],
'empik_order_reference' => [
'type' => self::TYPE_STRING,
'validate' => 'isCleanHtml',
],
'empik_order_carrier' => [
'type' => self::TYPE_STRING,
'validate' => 'isCleanHtml',
],
'empik_payment' => [
'type' => self::TYPE_STRING,
'validate' => 'isCleanHtml',
'required' => true,
],
'empik_carrier' => [
'type' => self::TYPE_STRING,
'validate' => 'isCleanHtml',
'required' => true,
],
'empik_pickup_point' => [
'type' => self::TYPE_STRING,
'validate' => 'isCleanHtml',
],
'empik_vat_number' => [
'type' => self::TYPE_STRING,
'validate' => 'isCleanHtml',
],
'date_add' => [
'type' => self::TYPE_DATE,
'validate' => 'isDate',
'required' => false,
],
],
];
public static function getEmpikOrderByOrderId($orderId)
{
$query = (new DbQuery())
->select('eo.*')
->from('empik_orders', 'eo')
->where('eo.id_order = "'.pSQL($orderId).'"');
return Db::getInstance()->getRow($query);
}
public static function getEmpikOrderReferenceByOrderId($orderId)
{
$query = (new DbQuery())
->select('eo.empik_order_reference')
->from('empik_orders', 'eo')
->where('eo.id_order = "'.pSQL($orderId).'"');
return Db::getInstance()->getValue($query);
}
public static function getOrderIdByEmpikOrderReference($empikOrderReference)
{
$query = (new DbQuery())
->select('eo.id_order')
->from('empik_orders', 'eo')
->where('eo.empik_order_reference = "'.pSQL($empikOrderReference).'"');
return Db::getInstance()->getValue($query);
}
}

View File

@@ -0,0 +1,64 @@
<?php
class EmpikProduct extends ObjectModel
{
public $id_product;
public $id_product_attribute;
public $product_export;
public $offer_export;
public $offer_price;
public $offer_price_reduced;
public $logistic_class;
public $condition;
public $export_original_price;
public static $definition = [
'table' => 'empik_product',
'primary' => 'id_empik_product',
'fields' => [
'id_product' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'id_product_attribute' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true],
'product_export' => ['type' => self::TYPE_INT, 'validate' => 'isBool', 'required' => false],
'offer_export' => ['type' => self::TYPE_INT, 'validate' => 'isBool', 'required' => false],
'offer_price' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => false],
'offer_price_reduced' => ['type' => self::TYPE_FLOAT, 'validate' => 'isPrice', 'required' => false],
'logistic_class' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => false],
'condition' => ['type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => false],
'export_original_price' => ['type' => self::TYPE_INT, 'validate' => 'isBool', 'required' => false],
],
];
public static function getById($productId, $productAttributeId = 0)
{
$sql = new DbQuery();
$sql->select('*');
$sql->from('empik_product');
$sql->where('id_product = '.(int)$productId);
$sql->where('id_product_attribute = '.(int)$productAttributeId);
$row = Db::getInstance()->getRow($sql);
if ($row) {
$empikProduct = new EmpikProduct();
$empikProduct->hydrate($row);
return $empikProduct;
}
return null;
}
public static function getOrCreate($productId, $productAttributeId = 0)
{
$empikProduct = self::getById($productId, $productAttributeId);
if (!$empikProduct) {
$empikProduct = new EmpikProduct();
$empikProduct->condition = 11;
$empikProduct->id_product = $productId;
$empikProduct->id_product_attribute = $productAttributeId;
$empikProduct->add();
}
return $empikProduct;
}
}

View File

@@ -0,0 +1,11 @@
<?php
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;