Tutorial Extension  1.0.0
SellerDeck Extensions - Tutorial Extension
CFieldMapping.php
1 <?php
2 
3 /**
4  * CFieldMapping.php - Abstract Field Mapping class.
5  *
6  * @package SellerDeck Extensions
7  *
8  * @author Péter Erdődi
9  * @copyright © SellerDeck Ltd 2015. All rights reserved.
10  */
11 
12 namespace SDExtension\Import;
13 
14 abstract class CFieldMapping
15  {
16 
17  /**
18  * @var object $m_oTax Tax Module
19  */
20  protected $m_oTax = null;
21 
22  /**
23  * @var object $m_oValidator Validator
24  */
25  protected $m_oValidator = null;
26 
27  /**
28  * @var object $m_oCatalogDB Catalog DB
29  */
30  protected $m_oCatalogDB = null;
31 
32  /**
33  * @var object $m_oShippingDB Shipping DB
34  */
35  protected $m_oShippingDB = null;
36 
37  /**
38  * @var string $m_sCurrentDate Current Date
39  */
40  protected $m_sCurrentDate = "";
41 
42  /**
43  * @var object $m_dDefaultWeight Default Weight
44  */
45  protected $m_dDefaultWeight = DEFAULT_WEIGHT;
46 
47  /**
48  * __construct - Object constructor
49  *
50  * @access public
51  * @param object $oCatalogDB Catalog DB
52  * @param object $oShippingDB Shipping DB
53  * @return void
54  */
55  public function __construct($oCatalogDB, $oShippingDB)
56  {
57  $this->m_oValidator = new \SDExtension\Helper\CValidator($oCatalogDB, $oShippingDB);
58  $this->m_oTax = new \SDExtension\CTax($oCatalogDB, $oShippingDB);
59  $this->m_oCatalogDB = $oCatalogDB;
60  $this->m_oShippingDB = $oShippingDB;
61  $this->m_sCurrentDate = SellerDeckDate();
62  $oQueryResult = $this->m_oShippingDB->Select(TABLE_WEIGHT_CONFIGURATION, 'sDefaultWeight', [['nID', 0]]);
63  if ($oQueryResult !== false)
64  {
65  $aControlInfo = $oQueryResult->fetch(\PDO::FETCH_ASSOC);
66  $this->m_dDefaultWeight = (double) arr_get($aControlInfo, 'sDefaultWeight', DEFAULT_WEIGHT);
67  }
68  }
69 
70  /**
71  * MapOrders - Maps Orders
72  *
73  * @access protected
74  * @param array $aGetOrdersResult GetOrders() Result
75  */
76  abstract protected function MapOrders($aGetOrdersResult);
77 
78  /**
79  * MapOrders - Maps Orders
80  *
81  * @access protected
82  * @param array $aGetOrdersResult GetOrders() Result
83  */
84  abstract protected function GenerateOrderNumber($sExternalOrderID);
85 
86  /**
87  * GetProductByReference - Getting Product by Reference
88  *
89  * @access protected
90  * @param string $sProductReference Product Reference
91  * @return array Product
92  */
93  protected function GetProductByReference($sProductReference)
94  {
95  $oQueryResult = $this->m_oCatalogDB->Select(TABLE_PRODUCT, '*', [['Product Reference', SQL_TYPE_STRING . $sProductReference]]);
96  if ($oQueryResult === false)
97  {
98  return [];
99  }
100  return $oQueryResult->fetch(\PDO::FETCH_ASSOC);
101  }
102 
103  /**
104  * GetProductByBarcode - Getting Product by Barcode
105  *
106  * @access protected
107  * @param string $sBarcode Barcode
108  * @return array Product
109  */
110  protected function GetProductByBarcode($sBarcode)
111  {
112  $oQueryResult = $this->m_oCatalogDB->Select(TABLE_PRODUCT, ['Product Reference'], [['sBarcode', SQL_TYPE_STRING . $sBarcode]]);
113  if ($oQueryResult === false)
114  {
115  return [];
116  }
117  return $oQueryResult->fetch(\PDO::FETCH_ASSOC);
118  }
119 
120  /**
121  * GetProductPropertiesByBarcode - Getting Product Properties by Barcode
122  *
123  * @access protected
124  * @param string $sBarcode Barcode
125  * @return array Product Properties
126  */
127  protected function GetProductPropertiesByBarcode($sBarcode)
128  {
129  $oQueryResult = $this->m_oCatalogDB->Select(TABLE_PRODUCT_PROPERTIES, '*', [['nType', 8], ['sString4', SQL_TYPE_STRING . $sBarcode]]);
130  if ($oQueryResult === false)
131  {
132  return [];
133  }
134  return $oQueryResult->fetch(\PDO::FETCH_ASSOC);
135  }
136 
137  }
__construct($oCatalogDB, $oShippingDB)
MapOrders($aGetOrdersResult)
GetProductByReference($sProductReference)
GenerateOrderNumber($sExternalOrderID)