Files
drmaterac.pl/modules/pricewars/pricewars.php
2025-01-06 20:47:25 +01:00

658 lines
24 KiB
PHP

<?php
function pw_myaddslashes(&$i) {
$i = str_replace('"','\"', $i);
}
class Pricewars extends Module
{
private $_html = '';
private $_postErrors = array();
public $CeneoCategories = array(); // Id => słowne
public $mappings = array(); // mapowanie produktow
function __construct()
{
// fix dla klasy link
global $protocol_content;
if (empty($protocol_content))
$protocol_content = 'http://';
$this->name = 'pricewars';
if($this-> isNewPS())
$this->tab = 'advertising_marketing';
else
$this->tab = 'Advertisement';
$this->author = 'SEIGI Grzegorz Zawadzki';
$this->version = '1.9.12';
parent::__construct();
$mappings = glob(_PS_MODULE_DIR_.$this->name.'/mappings/*.php');
if(!defined("_PS_BASE_URL_"))
define('_PS_BASE_URL_', $this->getShopHost(false));
/* The parent construct is required for translations */
$this->page = basename(__FILE__, '.php');
$this->displayName = $this->l('Price Wars!');
$this->description = $this->l('Generuje xml z ofertą sklepu dla Ceneo, Nokaut, Skąpiec, Radar, okazje.info i zakupy.onet.pl');
require(_PS_MODULE_DIR_.$this->name.'/ceneocategories.php');
$this->postProcess();
foreach ($mappings as $mapping) {
require($mapping);
if(isset($array_map) AND is_array($array_map))
foreach ($array_map as $array_map_key => $array_map_value)
$this->mappings[$array_map_key] = $array_map_value;
}
}
protected function getLangId() {
return (Language::getIdByIso("pl") ? Language::getIdByIso("pl") : Configuration::get('PS_LANG_DEFAULT'));
}
public static $cache_getShopHost = NULL;
protected function getShopHost($with_dir = true) {
if (self::$cache_getShopHost === NULL) {
if(strpos(_PS_VERSION_, '1.2') === 0) {
self::$cache_getShopHost = 'http://'.$_SERVER['HTTP_HOST'];
} elseif (strpos(_PS_VERSION_, '1.3') === 0) {
self::$cache_getShopHost = Tools::getHttpHost(true);
} else {
self::$cache_getShopHost = Tools::getShopDomainSsl(true);
}
}
return self::$cache_getShopHost . ($with_dir ? __PS_BASE_URI__ : NULL);
}
// Sprawdza, czy PS w wersji 1.4+
public function isNewPS() {
return version_compare(_PS_VERSION_, '1.4') >= 0 ? true : false;
}
// Sprawdza, czy PS w wersji 1.4+
public function shouldswitchpricewars() {
return version_compare(_PS_VERSION_, '1.5') >= 0 ? true : false;
}
// Maly alias
public function getImageLink($name, $ids, $type = null) {
if(class_exists('Context', false))
$link = new Link(null, 'http://');
else
$link = new Link();
$url = $link->getImageLink($name, $ids, $type);
if(strpos($url, 'http') !== 0)
return (rtrim($this->getShopHost(false),'/').$url);
return $url;
}
public function install()
{
if(!file_exists(_PS_MODULE_DIR_.$this->name.'/mappings'))
mkdir(_PS_MODULE_DIR_.$this->name.'/mappings/');
if (
!parent::install()
//OR ! Configuration::updateValue('PRICEWARS_SKAPIEC_SHOP_ID', '')
OR ! Configuration::updateValue('PRICEWARS_EXP_WITH_ZERO', '0')
OR ! Configuration::updateValue('PRICEWARS_REDUCE_AVAIL', '0')
OR ! Configuration::updateValue('PRICEWARS_DEBUG', '0')
OR ! Configuration::updateValue(strtoupper($this->name).'_XML_IMAGE_TYPE', 'medium')
OR ! $this->registerHook('backOfficeHome')
)
return false;
if(
$this->isNewPS()
AND (
!$this->registerHook('categoryUpdate')
OR !$this->registerHook('categoryDeletion')
)
)
return false;
$this->generateCeneoCategoriesArrayFile(); // call to regenerate CENEO Category Strucure :)
return true;
}
public function uninstall()
{
if (
!Configuration::deleteByName('PRICEWARS_SKAPIEC_SHOP_ID')
OR !Configuration::deleteByName('PRICEWARS_EXP_WITH_ZERO')
OR !Configuration::deleteByName('PRICEWARS_REDUCE_AVAIL')
OR !Configuration::deleteByName('PRICEWARS_DEBUG')
OR !Configuration::deleteByName(strtoupper($this->name).'_XML_IMAGE_TYPE')
OR !parent::uninstall())
return false;
return true;
}
public function postProcess(){
if(isset($_POST['reassignCatSubmit']) AND (int) $_POST['reassignCatIdSubmit']) {
$this->generateCeneoMappingFile();
}
if(isset($_POST['regenerateCeneoCatArray']))
$this->generateCeneoCategoriesArrayFile(); // call to regenerate CENEO Category Strucure :)
}
function getContent()
{
$this->_html = null;
$this->_postValidateProcess();
if($this->shouldswitchpricewars())
$this->_html .= '<p style=" font-size: 20px; color: red; font-weight: bold;">Ta wersja PriceWars jest przeznaczona dla sklepów STARSZYCH (1.4 i wcześniej). Dla wersji sklepu 1.5. Wersję napisaną pod Prestashop 1.5+ można pobrać tutaj: <a href="http://pl.seigi.eu/module/pricewars2.html">Kliknij - http://pl.seigi.eu/module/pricewars2.html</a></p>';
$this->_html .= $this->displayInfoBox();
$this->_html .= '<br><h2>Price wars!</h2>';
$this->_html .= '
<style type="text/css">
ul.pw_links_list {
padding: 0 5px;
list-style: none;
}
ul.pw_links_list li {
padding: 5px;
margin-bottom: 10px;
border: 1px dotted grey;
}
ul.pw_links_list li input {
display: block;
padding: 4px;
width: 710px;
margin: 4px 0;
}
span.greenIt {
color: green;
}
span.redIt {
color: red;
}
</style>';
if($this-> isNewPS()){
$this->_html .= '<fieldset class="width4">
<legend><img src="../img/admin/warning.gif" />Mapowanie kategorii</legend>
<h3>Wybierz Kategorię do mapowania</h3>';
$homeCat = Category::getHomeCategories($this->getLangId());
foreach ($homeCat as $cat) {
$this->_html .= '<a href="index.php?tab=AdminModules&configure='.$this->name.'&token='.$_GET['token'].'&tab_module=administration&module_name='.$this->name.'&reassignCatId='.$cat["id_category"].'">'.$cat["name"].'</a> '
.( file_exists(_PS_MODULE_DIR_.$this->name.'/mappings/'.$cat["id_category"].'.php') ? '<span class="greenIt">Zmapowane</span>' : '<span class="redIt">Nie zmapowane</span>' ).' <br />';
}
if(isset($_GET['reassignCatId'])) {
$this->_html .= '<h2>Opcje mapowania kategorii</h2>';
$toclean = $this->CeneoCategories;
array_walk_recursive($toclean, 'pw_myaddslashes' );
foreach ($toclean as $clkey => &$clvalue)
$clvalue = $clkey.'::'.$clvalue;
$this->_html .= '
<link rel="stylesheet" type="text/css" href="'.$this->getShopHost().'modules/'.$this->name.'/jquery.autocomplete.css" />
<script type="text/javascript" src="'.$this->getShopHost().'modules/'.$this->name.'/jquery.autocomplete.js"></script>
<script>
$(function() {
var availableTags = [
"'.implode('"
, "', $toclean).'"
];
$( ".autcomplpw" ).autocomplete( availableTags, {
minChars: 3,
autoFill: false,
max:20,
matchContains: true,
mustMatch:false,
scroll:false,
selectFirst:false,
delay:50,
cacheLength:0,
formatItem: function(item) {
return item[0];
}
});
});
</script>';
$this->_html .= '<form style="clear: both" method="post" action=""><table>
<input type="hidden" value="'.$_GET['reassignCatId'].'" name="reassignCatIdSubmit" />';
$this->_html .= $this->drawCategoryTree(Category::getCategories($this->getLangId()), 0, 0, $_GET['reassignCatId']);
$this->_html .= '<tr><td></td><td><input type="submit" class="button" name="reassignCatSubmit" value="Przypisz"></td></tr>
</table></form>';
}
$this->_html .= '</fieldset><br/>';
$this->_html .= '<fieldset class="width4">
<legend><img src="../img/admin/warning.gif" />Odświeżanie XML\'a Kategorii ceneo</legend>
Jeśli dopiero zainstalowałeś moduł, kliknij aby mieć najnowszy XML kategorii ceneo w sklepie<br>
<form method="post" action="">
<input type="submit" class="button" name="regenerateCeneoCatArray" value="Pobierz Świeży XML Kategorii z Ceneo">
</form>';
$this->_html .= '</fieldset><br/>';
}
$this->_html .= $this->_displaySettingsForm();
$this->_html .= '<br/><fieldset class="width4">
<legend><img src="../img/admin/warning.gif" />Informacje</legend>
Przy nawiązywaniu współpracy z porównywarkami cen podaj następujące linki jako lokoalizacje plików xml zawierających ofertę sklepu:<br /><br />
<ul class="pw_links_list">';
if($this->isNewPS())
$this->_html .= '
<li><b>Ceneo (Nowy XML):</b> '.'
<input readonly="readonly" value="'.$this->getShopHost().'modules/'.$this->name.'/offer.php?service=ceneoNew"/>
<div>
<span style="color: red;">
Nieprzypisane kategorie, nie będą uwzględnione w nowym XML, gdyż nowy XML Musi mieć kategorie. Jeśli nie chcesz tworzyć mapowania to użyj starego XML\'a.<br /><br />
Przypisywanie kategorii co Ceneo odbywa się na zasadzie edycji kategorii głównych. Jeśli usuniemy lub przemieścimy kategorię główną niżej (np pod inną podkategorię) jej mapowanie zostanie usunięte.<br />
<b>Dlatego też przed rozpoczęciem mapowania zaleca się najpierw ostatecznie ustalić strukturę kategorii.</b>
</span>
<br />
<br />
</div>
</li>
'; else $this->_html .= '<li>Niestety, nowy XML Ceneo jest obsługiwany od wersji 1.4</li>';
$this->_html .= '<li><b>Ceneo:</b>
<input readonly="readonly" value="'.$this->getShopHost().'modules/'.$this->name.'/offer.php?service=ceneo"/>
XML Ceneo akceptują także takie porównywarki jak: <br />
<b>najtaniej24.pl</b>, <b>smartbay.pl</b>, <b>cenuj.pl</b>, <b>kupujemy.pl</b>, <b>bazarcen.pl</b>, <b>harpagon.pl</b>
</li>
<li><b>skapiec.pl:</b>
<input readonly="readonly" value="'.$this->getShopHost().'modules/'.$this->name.'/offer.php?service=skapiec"/></li>
<li><b>nokaut.pl:</b>
<input readonly="readonly" value="'.$this->getShopHost().'modules/'.$this->name.'/offer.php?service=nokaut"/>
</li>
<li><b>radar.pl:</b>
<input readonly="readonly" value="'.$this->getShopHost().'modules/'.$this->name.'/offer.php?service=radar"/></li>
<li><b>okazje.info.pl:</b>
<input readonly="readonly" value="'.$this->getShopHost().'modules/'.$this->name.'/offer.php?service=okazje"/></li>
<li><b>zakupy.onet.pl:</b>
<input readonly="readonly" value="'.$this->getShopHost().'modules/'.$this->name.'/offer.php?service=zakupy_onet"/></li>
<li><b>sklepy24.pl:</b>
<input readonly="readonly" value="'.$this->getShopHost().'modules/'.$this->name.'/offer.php?service=sklepy24"/></li>
';
/* <li><b>tanio.pl:</b>
<code>Brak obsługi</code>
</li> */
$this->_html .= '<li>
<b>oferciak.pl:</b>
<input readonly="readonly" value="'.$this->getShopHost().'modules/'.$this->name.'/offer.php?service=oferciak"/></li>
<li>
<b>szoker.pl:</b>
<input readonly="readonly" value="'.$this->getShopHost().'modules/'.$this->name.'/offer.php?service=szoker"/></li>
<li>
<b>alejka.pl:</b> <code>Cytat ze strony: "Akceptujemy pliki XML w naszym formacie jak również w formacie dowolnej popularnej porównywarki" - także najprawdopodobniej jest obsługa XML np. Ceneo </code></li>
<li>
<b>ceneria.pl: </b> <code>Brak obsługi</code><br />
Zakres: "Skupiamy się wyłącznie na szeroko rozumianym sprzęcie do wszelkich form aktywności"</li>
<li><b>kreocen.pl:</b> <code>Brak obsługi</code><br />
KreoCEN to unikalna platforma promocyjna dla sklepów internetowych z kategorii "Dom i ogród"</li>
</ul>
</fieldset>
';
return $this->_html;
}
protected function drawCategoryTree($categories, $parent = 0, $level = 0, $genForCat = FALSE) {
if(class_exists('Context'))
$do_check_level_at = 2; // to jest poziom, na ktorym filtracja ma zadziałać PS 1.5+ .
else
$do_check_level_at = 1; // to jest poziom, na ktorym filtracja ma zadziałać PS do 1.4.
$return = null;
foreach ($categories[$parent] as $key => $category){
$id = (int) $category['infos']['id_category'];
// filtruje odnogę drzewa kategorii. Sprawdzane na poziomie 2 (do 1.4) lub 3 na ps 1.5+
if ( $genForCat > 0 AND $parent === $do_check_level_at AND $id != $genForCat) {
continue;
}
if( $id > $do_check_level_at ) { // id 1 to Home w ps do 1.4. ID 1 to root i id 2 to home w wersji 1.5+
$return .= '<tr><td style="font-size: '.(15-$level).'px; padding-left: '.($level*40).'px">'.$category['infos']['name'].'</td><td>';
$return .= '<input class="autcomplpw" style="width: 400px; " name="categoryToMap['.$id.']" value="'.( (isset($this->mappings[$id]) AND !empty($this->mappings[$id])) ? ($this->mappings[$id] .'::'. $this->CeneoCategories[$this->mappings[$id]]) : '' ).'" />';
$return .= '
</td></tr>';
}
if (isset($categories[$id]))
$return .= $this-> drawCategoryTree($categories, $id, $level+1 ,$genForCat );
}
return $return;
}
public function generateCeneoMappingFile () {
$file = '<?php $array_map = ';
$mappings = array();
foreach ($_POST['categoryToMap'] as $key=>$value ){
$val = explode('::',$value, 2);
$mappings[$key] = $val[0];
}
$file .= var_export($mappings, true);
$file .= ';';
file_put_contents(_PS_MODULE_DIR_.$this->name.'/mappings/'.$_POST['reassignCatIdSubmit'].'.php', $file );
}
public function generateCeneoCategoriesArrayFile () {
$xml = simplexml_load_file('http://api.ceneo.pl/Kategorie/dane.xml');
$this->ceneoXmlToArray ($xml);
$categories = '<?php
$this->CeneoCategories = ';
$categories .= var_export($this->CeneoCategories, true);
file_put_contents(_PS_MODULE_DIR_.$this->name.'/ceneocategories.php',$categories.';');
}
// reurencyjna funkcja uzywana do zapełniania drzewa kategorii z ceneo.
public function ceneoXmlToArray ($categoryArray, $prefix = NULL) {
foreach ( $categoryArray as $xml ) {
$this->CeneoCategories[(string)$xml->Id] = (string) $prefix . $xml->Name;
if(isset($xml->Subcategories))
$this->ceneoXmlToArray($xml->Subcategories->Category, $prefix.$xml->Name.'/');
}
}
protected function _displaySettingsForm()
{
$return = null;
$exportwithzero = intval(Configuration::get('PRICEWARS_EXP_WITH_ZERO'));
$reduceavailibilty = intval(Configuration::get('PRICEWARS_REDUCE_AVAIL'));
$xmlImageType = Configuration::get(strtoupper($this->name).'_XML_IMAGE_TYPE');
$debug = (int) Configuration::get('PRICEWARS_DEBUG');
//$skapiecShopId = Configuration::get('PRICEWARS_SKAPIEC_SHOP_ID');
if (sizeof($this->_postErrors))
$this->_displayErrors();
$return .= '
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
<fieldset class="width4">
<legend><img src="../img/admin/contact.gif" />'.$this->l('Ustawienia').'</legend>';
// Skapiec Zrezygnowal z Identyfikatorow sklepu, ale dla pewnosci zostawię to na razie :)
/* echo '<label>'.$this->l('Identyfikator Twojego sklepu w skapiec.pl').'</label>
<div class="margin-form"><input type="text" size="10" name="skapiecShopId" value="'.$skapiecShopId.'" /></div>
<br>'; */
$return .= '<label>'.$this->l('Eksportuj z zerowym stanem magazynowym').'</label>
<div class="margin-form">
Eksportuje produkty, które posiadają stan magazynowy 0. Gdy nie prowadzisz stanów magazynowych.<br>
<input type="radio" '.($exportwithzero === 0 ? ' checked="checked" ' : '').' name="exportwithzero" value="0" /><b>(domyślne)</b> Nie eksporuj<br>
<input type="radio" '.($exportwithzero === 1 ? ' checked="checked" ' : '').' name="exportwithzero" value="1" /> Eksportuj (jako dostępne; stan wymuszony na 1) (Tip: Zaznacz, gdy masz na sklepie atrybuty (np. kolory), a główny produkt ma stan magazynowy zero )<br>
<input type="radio" '.($exportwithzero === 2 ? ' checked="checked" ' : '').' name="exportwithzero" value="2" /> Eksportuj (jako niedostępne; stan wszystkich produktów wymuszony na 0)<br>
</div>
<br>
<label>'.$this->l('Redukuj dostępność').'</label>
<div class="margin-form">
<input type="radio" '.($reduceavailibilty === 0 ? ' checked="checked" ' : '').' name="reduceavailibilty" value="0" /><b>(domyślne)</b> Eksportuj produkty z prawdziwym stanem magazynowym; Produkty wymuszone przez poprzenią opcję będą eksportowane ze stanem magazynowym ustalonym wyżej. <br>
<input type="radio" '.($reduceavailibilty === 1 ? ' checked="checked" ' : '').' name="reduceavailibilty" value="1" /> Redukuj stany większe niż 1 na 1; zero pozostaje zerem.
</div>
<br>
<label>'.$this->l('Debugowanie').'</label>
<div class="margin-form">
<input type="radio" '.($debug === 0 ? ' checked="checked" ' : '').' name="pwdebug" value="0" />Nie<br>
<input type="radio" '.($debug === 1 ? ' checked="checked" ' : '').' name="pwdebug" value="1" />Tak
<br>
Tryb debugowania ułatwia stwierdzenie, z jakiego powodu produkty się nie wyświetlają.
Gdy opcja jest włączona, zamiast XML będzie generowany log z informacjami co się dzieje.
Aby sprawdzić dlaczego produkty się nie wyświetlają, proszę włączyć tę opcję a następnie otworzyć link do generowania XML.
</div>
<br>
<label>'.$this->l('Wybierz jaki typ obrazka ma być udostępniany w xml').'</label>
<div class="margin-form">
<select name="xmlimagetype">
';
$images = db::getInstance()->ExecuteS("SELECT name, width, height FROM `"._DB_PREFIX_."image_type` WHERE `products` = 1");
foreach ($images as $image){
$return .= '<option '.($xmlImageType === $image['name'] ? "selected=\"selected\"" : NULL ).' value="'.$image['name'].'">'.$image['name'].' ('.$image['width'].'px x '.$image['height'].'px)</option>';
}
$return .= '</select></div>
<br /><center><input type="submit" name="submitPricewars" value="'.$this->l('Zapisz zmiany').'" class="button" /></center>
</fieldset>
</form>';
return $return;
}
public $debug_cache = null;
public function doDebug($msg) {
if((int) Configuration::get('PRICEWARS_DEBUG')) {
$this->debug_cache .= $msg."<br />\r\n";
}
}
public function showDebug() {
if((int) Configuration::get('PRICEWARS_DEBUG')) {
header("content-type: text/html");
echo $this->debug_cache;
}
}
protected function _postValidateProcess(){
if (isset($_POST['submitPricewars'])){
/* if (empty($_POST['skapiecShopId']))
$this->_postErrors[] = $this->l('Musisz podać id sklepu w skapiec.pl, o ile chcesz z niego korzystać.');
else
Configuration::updateValue('PRICEWARS_SKAPIEC_SHOP_ID', intval($_POST['skapiecShopId'])); */
Configuration::updateValue('PRICEWARS_EXP_WITH_ZERO', intval($_POST['exportwithzero']));
Configuration::updateValue('PRICEWARS_REDUCE_AVAIL', intval($_POST['reduceavailibilty']));
Configuration::updateValue('PRICEWARS_DEBUG', intval($_POST['pwdebug']));
Configuration::updateValue(strtoupper($this->name).'_XML_IMAGE_TYPE', $_POST['xmlimagetype']);
}
}
protected function _displayErrors()
{
$nbErrors = sizeof($this->_postErrors);
$this->_html .= '
<div class="alert error">
<h3>'.($nbErrors > 1 ? $this->l('Wystapily') : $this->l('Wystapil')).' '.$nbErrors.' '.($nbErrors > 1 ? $this->l('bledy') : $this->l('blad')).'</h3>
<ol>';
foreach ($this->_postErrors AS $error)
$this->_html .= '<li>'.$error.'</li>';
$this->_html .= '
</ol>
</div>';
}
protected function _getCategoryTree($delimeter = '/'){
$categories = Category::getCategories($this->getLangId(),false,false);
$categoryArray = array ();
foreach($categories as $category) {
$categoryArray[$category['id_category']] = $category;
}
foreach ($categoryArray as $category) {
$categoryParent = $categoryArray[$category['id_category']]['id_parent'];
$categoryPath = $categoryArray[$category['id_category']]['name'];
$counter = 0;
while ($categoryParent) {
$counter++;
if ($counter > 100)
break;
if ($categoryParent != @$categoryArray[$categoryParent]['id_parent']) {
if (@$categoryArray[$categoryParent]['id_category']!=1)
$categoryPath = @$categoryArray[$categoryParent]['name'] . $delimeter . $categoryPath;
$categoryParent = @$categoryArray[$categoryParent]['id_parent'];
} else {
$categoryParent = 0;
}
}
$categoryArray[$category['id_category']]['path'] = $categoryPath;
}
return $categoryArray;
}
protected function generateXML(){
die('Problem z generowaniem XML Objekt nie posiada poprawnej klasy do generowania XML');
}
public function getXML(){
$xml = $this->generateXML();
if((int) Configuration::get('PRICEWARS_DEBUG'))
$this->showDebug();
else
echo $xml->saveXML();
}
protected function getXmlImageType() {
return Configuration::get(strtoupper($this->name).'_XML_IMAGE_TYPE');
}
/*
*
*
* @param bool $active true aby pobrać tylko produkty aktywne
* @param bool $instock true aby pobrać tylko produkty które są na magazynie.
* @param bool $reducequantity true aby ustawić stan magazynowy produktu na 1 - w celu zamaskowania w xmlu prawdziwej ilosci na magazynie
*
*
*/
protected function getProducts($active = true, $instock = true) {
Global $cookie;
$cookie = new Cookie('ps');
//public static function getProducts($id_lang, $start, $limit, $orderBy, $orderWay, $id_category = false, $only_active = false)
$Products = Product::getProducts($this->getLangId(), 0, null, 'name', 'ASC', false, (bool) $active);
$exportwithzero = intval(Configuration::get('PRICEWARS_EXP_WITH_ZERO'));
$reduceavailibilty = intval(Configuration::get('PRICEWARS_REDUCE_AVAIL'));
foreach ($Products as $key => &$product) {
if ( $exportwithzero === 0 AND $product['quantity'] <= 0) { // to usun
if(method_exists('Product', 'getQuantity'))
$product['quantity'] = Product::getQuantity($product['id_product']);
if($product['quantity'] <= 0){
$this->doDebug('<span style="color: grey;">'.$product['name'].'</span> stan magazynowy = 0, usuwanie z listy.');
unset($Products[$key]);
continue;
}
} elseif ( $exportwithzero === 1 AND $product['quantity'] <= 0 ) {
$this->doDebug('<span style="color: grey;">'.$product['name'].'</span> ustawiono stan mag. na 1');
$product['quantity'] = 1;
} elseif ( $exportwithzero === 2 AND $product['quantity'] <= 0 ) {
$this->doDebug('<span style="color: grey;">'.$product['name'].'</span> ustawiono stan mag. na 0');
$product['quantity'] = 0;
}
if( $reduceavailibilty === 1 AND $product['quantity'] > 1 ){
$this->doDebug('<span style="color: grey;">'.$product['name'].'</span> Redukcja stanu magazynowego z '.$product['quantity'].' na 1');
$product['quantity'] = 1;
}
}
return $Products;
}
public static function htmlentities( $string )
{
return str_replace('&', '&amp;', $string);
return htmlentities( $string , ENT_COMPAT, 'UTF-8');
}
protected function getTaxedPrice ($Product) {
return round(Product::getPriceStatic($Product['id_product'], true),2);
/* if($Product["tax_rate"] === NULL)
$Product["tax_rate"] = 0;
if(!isset($Product["tax_rate"]) OR !isset($Product["price"])) {
throw new Exception('Przekazana wartość musi być tablicą produktu.');
}
if($Product["tax_rate"] > 0)
$tax = $Product["price"] * ( $Product["tax_rate"] / 100);
else
$tax = 0;
return round ($Product["price"] + $tax, 2); */
}
function hookcategoryUpdate(){
if( intval($_POST["id_parent"]) !== 1 AND file_exists(_PS_MODULE_DIR_.$this->name.'/mappings/'.$_POST['id_category'].'.php')) {
unlink(_PS_MODULE_DIR_.$this->name.'/mappings/'.$_POST['id_category'].'.php');
}
}
function hookcategoryDeletion(){
@unlink(_PS_MODULE_DIR_.$this->name.'/mappings/'.$_POST['id_category'].'.php');
}
private function displayInfoBox(){
$output = '';
$output .= "<div style='border: 2px solid #666; padding: 5px;'>
<img style='margin: 12px 10px 10px 0; float: left;' src='http://pl.seigi.eu/images/seigi_logo_a_197x40.png' alt='' />";
$output .= "<b>Moduł</b>: <i>{$this->displayName}</i> w wersji {$this->version} stworzony przez SEIGI Grzegorz Zawadzki<br>";
$output .= "<b>Licencja</b>: Darmowa<br>";
$output .= '
<a href="http://pl.seigi.eu/informacje/prestashop-moduly.html" target="_blank" style="font-weight: bold; display: inline-block; padding: 8px 20px; color: #fff; background-color: #ef924b">Zobacz inne nasze moduły</a>
<a href="http://pl.seigi.eu/module/'.$this->name.'.html" target="_blank" style="font-weight: bold; display: inline-block; padding: 8px 20px; color: #fff; background-color: #ef924b">Strona modułu</a>
';
return $output .= '</div>';
}
}