Merge branch 'ticket-philea' into develop
This commit is contained in:
commit
a6be8282c0
@ -1,165 +1,153 @@
|
||||
<?php
|
||||
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
$_SERVER['SERVER_PORT'] = 80;
|
||||
$_SERVER['HTTP_HOST'] = 'www.bebeboutik.com';
|
||||
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
|
||||
$_SERVER['SERVER_PORT'] = 80;
|
||||
|
||||
include(dirname(__FILE__) . '/../../../config/config.inc.php');
|
||||
include( dirname(__FILE__) . '/../philea_magistor.php');
|
||||
include(dirname(__FILE__) . '/../../../config/config.inc.php');
|
||||
include( dirname(__FILE__) . '/../philea_magistor.php');
|
||||
|
||||
$id_sale = (int) $argv[1];
|
||||
if($id_sale == 0) {
|
||||
exit;
|
||||
}
|
||||
|
||||
function getName($id_product, $id_lang, $id_product_attribute = FALSE) {
|
||||
$name = DB::getInstance()->getValue('
|
||||
SELECT `name`
|
||||
FROM `'._DB_PREFIX_.'product_lang`
|
||||
WHERE `id_product` = '.$id_product.'
|
||||
AND `id_lang` = '.$id_lang.'
|
||||
');
|
||||
|
||||
if($id_product_attribute) {
|
||||
foreach(Db::getInstance()->ExecuteQ('
|
||||
SELECT agl.`name` AS group_name, al.`name` AS attribute_name
|
||||
FROM `'._DB_PREFIX_.'product_attribute_combination` pac
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute` a
|
||||
ON a.`id_attribute` = pac.`id_attribute`
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group` ag
|
||||
ON ag.`id_attribute_group` = a.`id_attribute_group`
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_lang` al
|
||||
ON a.`id_attribute` = al.`id_attribute`
|
||||
AND al.`id_lang` = '.(int) $id_lang.'
|
||||
LEFT JOIN `'._DB_PREFIX_.'attribute_group_lang` agl
|
||||
ON ag.`id_attribute_group` = agl.`id_attribute_group`
|
||||
AND agl.`id_lang` = '.(int) $id_lang.'
|
||||
WHERE pac.`id_product_attribute` = '.(int) $id_product_attribute.'
|
||||
ORDER BY pac.`id_product_attribute`
|
||||
') as $name_attribute) {
|
||||
$name .= ' - '.$name_attribute['group_name'].' : '.$name_attribute['attribute_name'];
|
||||
}
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
|
||||
$id_sale = (int) $argv[1];
|
||||
$magistorModule = new philea_magistor();
|
||||
@ini_set('display_errors', 'on');
|
||||
|
||||
//$_id_shipping = 4; // philea
|
||||
if($magistorModule->active) {
|
||||
global $regex_file_out;
|
||||
$regex_file_out = '@^ART01(.*)\.(BAL|DAT)@';
|
||||
@set_time_limit(0);
|
||||
|
||||
if($id_sale == 0) {
|
||||
exit;
|
||||
$fileName = dirname(__FILE__) . '/OUT/ART01' . date('ymdHis');
|
||||
|
||||
$repo_archive = dirname(__FILE__) . '/archives/OUT/ARTICLES/';
|
||||
$repo_paths = array(date('Y'), date('m'));
|
||||
foreach ($repo_paths as $repo_path) {
|
||||
$repo_archive .= $repo_path . '/';
|
||||
if (!file_exists($repo_archive))
|
||||
mkdir($repo_archive);
|
||||
}
|
||||
|
||||
$magistorModule = new philea_magistor();
|
||||
@ini_set('display_errors', 'on');
|
||||
$fileArchive = $repo_archive . 'ART01' . date('ymdHis');
|
||||
|
||||
if($magistorModule->active) {
|
||||
global $regex_file_out;
|
||||
$regex_file_out = '@^ART01(.*)\.(BAL|DAT)@';
|
||||
@set_time_limit(0);
|
||||
$code_societe = (int)(Configuration::get('PHILEA_MAGISTOR_CODE_STE'));
|
||||
$db = Db::getInstance();
|
||||
$products = $db->ExecuteS('
|
||||
SELECT * FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
ON (
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)(Configuration::get('PS_LANG_DEFAULT')).'
|
||||
)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` c
|
||||
ON c.`id_product` = p.`id_product`
|
||||
WHERE c.`id_sale` = '.(int) $id_sale.'
|
||||
ORDER BY p.`id_product` ASC
|
||||
');
|
||||
if (!$products) {
|
||||
$products = array();
|
||||
}
|
||||
|
||||
$db = Db::getInstance();
|
||||
$data = '';
|
||||
|
||||
$products = $db->ExecuteS('
|
||||
SELECT * FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_lang` pl
|
||||
ON (
|
||||
p.`id_product` = pl.`id_product`
|
||||
AND pl.`id_lang` = '.(int)(Configuration::get('PS_LANG_DEFAULT')).'
|
||||
)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_ps_cache` c
|
||||
ON c.`id_product` = p.`id_product`
|
||||
WHERE c.`id_sale` = '.(int) $id_sale.'
|
||||
ORDER BY p.`id_product` ASC
|
||||
foreach($products as $product) {
|
||||
|
||||
$link = new Link();
|
||||
$cover = Db::getInstance()->getValue('
|
||||
SELECT `id_image`
|
||||
FROM `'._DB_PREFIX_.'image`
|
||||
WHERE id_product = ' . (int) $product['id_product'] . '
|
||||
AND `cover` = 1');
|
||||
$ids = (int) $product['id_product'] . '-' . (int) $cover;
|
||||
$img_link = 'http://'.$link->getImageLink($product['link_rewrite'], $ids, 'thickbox');
|
||||
|
||||
$attributes = $db->ExecuteQ('
|
||||
SELECT *
|
||||
FROM `'._DB_PREFIX_.'product_attribute`
|
||||
WHERE `id_product` = '.$product['id_product'].'
|
||||
');
|
||||
if (!$products)
|
||||
$products = array();
|
||||
|
||||
if((int) Db::getInstance()->getValue('
|
||||
SELECT `featured`
|
||||
FROM `'._DB_PREFIX_.'privatesale`
|
||||
WHERE `id_sale` = '.(int) $id_sale.'
|
||||
')) {
|
||||
$code_societe = 101; // 78
|
||||
} else {
|
||||
$code_societe = (int)(Configuration::get('PHILEA_MAGISTOR_CODE_STE'));
|
||||
}
|
||||
|
||||
$fileName = dirname(__FILE__) . '/OUT/ART01' . date('ymdHis');
|
||||
|
||||
$repo_archive = dirname(__FILE__) . '/archives/OUT/ARTICLES/';
|
||||
$repo_paths = array(date('Y'), date('m'));
|
||||
foreach ($repo_paths as $repo_path) {
|
||||
$repo_archive .= $repo_path . '/';
|
||||
if (!file_exists($repo_archive))
|
||||
mkdir($repo_archive);
|
||||
}
|
||||
|
||||
$fileArchive = $repo_archive . 'ART01' . date('ymdHis');
|
||||
|
||||
$data = '';
|
||||
|
||||
foreach( $products as $product ) {
|
||||
/*if($product['send_philea'])*/
|
||||
// ANTADIS
|
||||
// continue;
|
||||
|
||||
/**
|
||||
* @Override
|
||||
* Get image link
|
||||
*/
|
||||
$link = new Link();
|
||||
$cover = Db::getInstance()->getValue('
|
||||
SELECT `id_image`
|
||||
FROM `'._DB_PREFIX_.'image`
|
||||
WHERE id_product = ' . (int) $product['id_product'] . '
|
||||
AND `cover` = 1');
|
||||
$ids = (int) $product['id_product'] . '-' . (int) $cover;
|
||||
$img_link = 'http://'.$link->getImageLink($product['link_rewrite'], $ids, 'thickbox');
|
||||
|
||||
$attributes = $db->ExecuteS('SELECT * FROM '._DB_PREFIX_.'product_attribute WHERE id_product = '.$product['id_product']);
|
||||
if(count($attributes)>0)
|
||||
{
|
||||
foreach($attributes as $attribute)
|
||||
{
|
||||
if(isset($attribute['ean13']) && !empty($attribute['ean13']))
|
||||
$ean = $attribute['ean13'];
|
||||
else
|
||||
//$ean = '';
|
||||
$ean = substr(!empty($attribute['supplier_reference'])? $attribute['supplier_reference']: $product['supplier_reference'], 0, 13);
|
||||
|
||||
if($code_societe == 78) {
|
||||
$ref = !empty($attribute['ean13'])? $attribute['ean13']: $attribute['supplier_reference'];
|
||||
} else {
|
||||
$ref = $product['id_product'].'_'.$attribute['id_product_attribute'];
|
||||
}
|
||||
|
||||
$data .= str_pad('ART01', 10, ' ', STR_PAD_RIGHT );
|
||||
$data .= str_pad( $code_societe, 20, ' ', STR_PAD_RIGHT );
|
||||
$data .= str_pad( substr(utf8_decode(str_replace(array("\r", "\n"), "", $ref)),0,50), 50, ' ', STR_PAD_RIGHT );
|
||||
$data .= str_pad( substr(utf8_decode(str_replace(array("\r", "\n"), "", $magistorModule->getName($product['id_product'],Configuration::get('PS_LANG_DEFAULT'),$attribute['id_product_attribute']))),0,80), 80, ' ', STR_PAD_RIGHT );
|
||||
$data .= str_pad( 1, 10, '0', STR_PAD_LEFT );
|
||||
$data .= str_pad( str_replace(array("\r", "\n"), "", $ean), 14, ' ', STR_PAD_LEFT );
|
||||
$data .= str_pad( str_replace('.',',',($product['weight']+$attribute['weight'])/**1000*/), 10, '0', STR_PAD_LEFT );
|
||||
$data .= str_pad( $product['width']*$product['height']*$product['depth'], 10, '0', STR_PAD_LEFT );
|
||||
$data .= str_pad( substr($img_link, 0, 150), 150, ' ', STR_PAD_RIGHT );
|
||||
// $data .= str_pad( '', 14, '0', STR_PAD_LEFT );
|
||||
// $data .= str_pad( '', 10, '0', STR_PAD_LEFT );
|
||||
// $data .= str_pad( '', 10, '0', STR_PAD_LEFT );
|
||||
// $data .= str_pad( '', 10, '0', STR_PAD_LEFT );
|
||||
// $data .= str_pad( '', 14, '0', STR_PAD_LEFT );
|
||||
// $data .= str_pad( '', 10, '0', STR_PAD_LEFT );
|
||||
// $data .= str_pad( '', 10, '0', STR_PAD_LEFT );
|
||||
// $data .= str_pad( '', 10, '0', STR_PAD_LEFT );
|
||||
$data .= PHP_EOL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isset($product['ean13']) && !empty($product['ean13']))
|
||||
$ean = $product['ean13'];
|
||||
else
|
||||
//$ean = '';
|
||||
$ean = substr($product['supplier_reference'], 0, 13);
|
||||
|
||||
if($code_societe == 78) {
|
||||
$ref = !empty($product['ean13'])? $product['ean13']: $product['supplier_reference'];
|
||||
if(count($attributes) > 0) {
|
||||
foreach($attributes as $attribute) {
|
||||
if(isset($attribute['ean13']) && !empty($attribute['ean13'])) {
|
||||
$ean = $attribute['ean13'];
|
||||
} else {
|
||||
$ref = $product['id_product'];
|
||||
$ean = $attribute['supplier_reference'];
|
||||
}
|
||||
|
||||
$data .= str_pad('ART01', 10, ' ', STR_PAD_RIGHT );
|
||||
$data .= str_pad( $code_societe, 20, ' ', STR_PAD_RIGHT );
|
||||
$data .= str_pad( str_replace(array("\r", "\n"), "", $ref), 50, ' ', STR_PAD_RIGHT );
|
||||
$data .= str_pad( substr(utf8_decode(str_replace(array("\r", "\n"), "", $product['name'])),0,80), 80, ' ', STR_PAD_RIGHT );
|
||||
$data .= str_pad( 1, 10, '0', STR_PAD_LEFT );
|
||||
$data .= str_pad( str_replace(array("\r", "\n"), "", $ean), 14, ' ', STR_PAD_LEFT );
|
||||
$data .= str_pad( str_replace('.',',',$product['weight']/**1000*/), 10, '0', STR_PAD_LEFT );
|
||||
$data .= str_pad( $product['width']*$product['height']*$product['depth'], 10, '0', STR_PAD_LEFT );
|
||||
$data .= str_pad( substr($img_link, 0, 150), 150, ' ', STR_PAD_RIGHT );
|
||||
// $data .= str_pad( '', 14, '0', STR_PAD_LEFT );
|
||||
// $data .= str_pad( '', 10, '0', STR_PAD_LEFT );
|
||||
// $data .= str_pad( '', 10, '0', STR_PAD_LEFT );
|
||||
// $data .= str_pad( '', 10, '0', STR_PAD_LEFT );
|
||||
// $data .= str_pad( '', 14, '0', STR_PAD_LEFT );
|
||||
// $data .= str_pad( '', 10, '0', STR_PAD_LEFT );
|
||||
// $data .= str_pad( '', 10, '0', STR_PAD_LEFT );
|
||||
// $data .= str_pad( '', 10, '0', STR_PAD_LEFT );
|
||||
$data .= str_pad('ART01', 10, ' ', STR_PAD_RIGHT);
|
||||
$data .= str_pad($code_societe, 20, ' ', STR_PAD_RIGHT);
|
||||
$data .= str_pad(substr(utf8_decode(str_replace(array("\r", "\n"), '', $ean)), 0, 50), 50, ' ', STR_PAD_RIGHT);
|
||||
$data .= str_pad(substr(utf8_decode(str_replace(array("\r", "\n"), '', getName($product['id_product'], Configuration::get('PS_LANG_DEFAULT'), $attribute['id_product_attribute']))), 0,80), 80, ' ', STR_PAD_RIGHT);
|
||||
$data .= str_pad(1, 10, '0', STR_PAD_LEFT);
|
||||
$data .= str_pad(str_replace(array("\r", "\n"), '', $attribute['ean13']), 14, ' ', STR_PAD_LEFT);
|
||||
$data .= str_pad(str_replace('.', ',', $product['weight'] + $attribute['weight']), 10, '0', STR_PAD_LEFT);
|
||||
$data .= str_pad($product['width'] * $product['height'] * $product['depth'], 10, '0', STR_PAD_LEFT);
|
||||
$data .= str_pad(substr($img_link, 0, 150), 150, ' ', STR_PAD_RIGHT);
|
||||
$data .= PHP_EOL;
|
||||
}
|
||||
} //End if send_philea
|
||||
file_put_contents($fileName . '.DAT', "\xEF\xBB\xBF".utf8_encode($data));
|
||||
file_put_contents($fileArchive . '.DAT', "\xEF\xBB\xBF".utf8_encode($data));
|
||||
} else {
|
||||
if(isset($product['ean13']) && !empty($product['ean13'])) {
|
||||
$ean = $product['ean13'];
|
||||
} else {
|
||||
$ean = $product['supplier_reference'];
|
||||
}
|
||||
|
||||
$data .= str_pad('ART01', 10, ' ', STR_PAD_RIGHT);
|
||||
$data .= str_pad($code_societe, 20, ' ', STR_PAD_RIGHT);
|
||||
$data .= str_pad(str_replace(array("\r", "\n"), '', $ean), 50, ' ', STR_PAD_RIGHT);
|
||||
$data .= str_pad(substr(utf8_decode(str_replace(array("\r", "\n"), '', $product['name'])), 0, 80), 80, ' ', STR_PAD_RIGHT);
|
||||
$data .= str_pad(1, 10, '0', STR_PAD_LEFT);
|
||||
$data .= str_pad(str_replace(array("\r", "\n"), '', $product['ean13']), 14, ' ', STR_PAD_LEFT);
|
||||
$data .= str_pad(str_replace('.', ',', $product['weight']), 10, '0', STR_PAD_LEFT);
|
||||
$data .= str_pad($product['width'] * $product['height'] * $product['depth'], 10, '0', STR_PAD_LEFT);
|
||||
$data .= str_pad(substr($img_link, 0, 150), 150, ' ', STR_PAD_RIGHT);
|
||||
$data .= PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
if($data != '') {
|
||||
file_put_contents($fileName.'.DAT', "\xEF\xBB\xBF".utf8_encode($data));
|
||||
file_put_contents($fileArchive.'.DAT', "\xEF\xBB\xBF".utf8_encode($data));
|
||||
unset($data);
|
||||
|
||||
chmod($fileName . '.DAT', 0755);
|
||||
file_put_contents($fileName . '.BAL', '');
|
||||
chmod($fileName . '.BAL', 0755);
|
||||
chmod($fileName.'.DAT', 0755);
|
||||
file_put_contents($fileName.'.BAL', '');
|
||||
chmod($fileName.'.BAL', 0755);
|
||||
require_once('connection_ftp.php');
|
||||
echo 'fin';
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user