98 lines
2.2 KiB
PHP
Raw Normal View History

<?php
/**
* Carts Guru
*
* @category advertising_marketing
* @author LINKT IT
* @copyright Copyright (c) LINKT IT 2016
* @version 1.1.0
* @license Commercial license
*
*************************************
** CARTS GURU *
** V 1.1.0 *
*************************************
* +
* + Languages: EN, FR
* + PS version: 1.4,1.5,1.6
* + Cloud compatible & tested
*/
abstract class CartGuruMapperAbstract
{
public $id_lang;
public $id_shop_group;
public $id_shop;
public $link;
public function __construct($id_lang, $id_shop_group, $id_shop)
{
$this->id_lang = $id_lang;
$this->id_shop_group = (int) $id_shop_group;
$this->id_shop = (int) $id_shop;
$protocol_link = Configuration::get(
'PS_SSL_ENABLED',
null,
$this->id_shop_group,
$this->id_shop
) ? 'https://' : 'http://';
$use_ssl = Configuration::get('PS_SSL_ENABLED') ? true : false;
$protocol_content = ($use_ssl) ? 'https://' : 'http://';
$this->link = new Link($protocol_link, $protocol_content);
}
/**
* Populate ps object to cart guru array
*
* @param Object $obj
* @return array data
*/
public function create($obj, $params = array())
{
$cart_guru_mapped = array();
if ($obj) {
$cart_guru_mapped = $this->mappObject($obj, $params);
}
return $cart_guru_mapped;
}
/**
* If value is empty return ''
*
* @param
* $value
* @return string
*/
protected function notEmpty($value)
{
return ($value) ? $value : '';
}
/**
* This method format date in json format
*
* @param
* $date
* @return bool string
*/
protected function formatDate($date)
{
return date('Y-m-d\TH:i:sP', strtotime($date));
}
/**
* Populate the Carts Guru Data from PS object
*
* To be implemented by the concrete mapper class
*
* @param Object $psobj
* @param array $params
* @return array
*/
abstract public function mappObject($obj, $params);
}