mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-03-01 19:03:14 +03:00
Add converting of weight units
This commit is contained in:
parent
7a8be5f637
commit
af3f8ed1a2
@ -59,3 +59,5 @@ There are list of available filters:
|
|||||||
* *RetailcrmFilterSaveCorporateCustomerAddress* - built corporate customer address object, which will be saved to CMS
|
* *RetailcrmFilterSaveCorporateCustomerAddress* - built corporate customer address object, which will be saved to CMS
|
||||||
|
|
||||||
* *RetailcrmFilterJobManagerIntervals* - array with jobs as keys and intervals as values
|
* *RetailcrmFilterJobManagerIntervals* - array with jobs as keys and intervals as values
|
||||||
|
* *RetailcrmFilterWeight* - array with weight units in ICML
|
||||||
|
* *RetailcrmFilterMiddlewares* - array with middlewares, which running before and after request
|
||||||
|
@ -191,10 +191,7 @@ class RetailcrmCatalog
|
|||||||
$article = null;
|
$article = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$weight = round($product['weight'], 2);
|
$weight = $this->getWeightInKg($product['weight']);
|
||||||
if (0.0 === $weight) {
|
|
||||||
$weight = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
$width = round($product['width'], 3);
|
$width = round($product['width'], 3);
|
||||||
$height = round($product['height'], 3);
|
$height = round($product['height'], 3);
|
||||||
@ -366,10 +363,8 @@ class RetailcrmCatalog
|
|||||||
return $pictures;
|
return $pictures;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function getProductsCount(
|
private static function getProductsCount($id_lang, Context $context = null)
|
||||||
$id_lang,
|
{
|
||||||
Context $context = null
|
|
||||||
) {
|
|
||||||
if (!$context) {
|
if (!$context) {
|
||||||
$context = Context::getContext();
|
$context = Context::getContext();
|
||||||
}
|
}
|
||||||
@ -450,4 +445,71 @@ class RetailcrmCatalog
|
|||||||
|
|
||||||
return $parentId;
|
return $parentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function getWeightInKg($weight)
|
||||||
|
{
|
||||||
|
if (0 == $weight) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$mg = 1 / 1000 / 1000;
|
||||||
|
$g = 1 / 1000;
|
||||||
|
$ton = 1 * 1000;
|
||||||
|
$oz = 1 / 35.3;
|
||||||
|
$pd = 1 * 2.2;
|
||||||
|
$st = 1 * 6.35;
|
||||||
|
|
||||||
|
$weightUnits = [
|
||||||
|
'mg' => $mg,
|
||||||
|
'мг' => $mg,
|
||||||
|
'miligramo' => $mg,
|
||||||
|
'миллиграмм' => $mg,
|
||||||
|
'milligram' => $mg,
|
||||||
|
|
||||||
|
'g' => $g,
|
||||||
|
'gram' => $g,
|
||||||
|
'grammo' => $g,
|
||||||
|
'г' => $g,
|
||||||
|
'гр' => $g,
|
||||||
|
'грамм' => $g,
|
||||||
|
|
||||||
|
'kg' => 1,
|
||||||
|
'kilogram' => 1,
|
||||||
|
'kilogramme' => 1,
|
||||||
|
'kilo' => 1,
|
||||||
|
'kilogramo' => 1,
|
||||||
|
|
||||||
|
'ton' => $ton,
|
||||||
|
'т' => $ton,
|
||||||
|
'тонна' => $ton,
|
||||||
|
'tonelada' => $ton,
|
||||||
|
'toneladas' => $ton,
|
||||||
|
|
||||||
|
'oz' => $oz,
|
||||||
|
'унция' => $oz,
|
||||||
|
'ounce' => $oz,
|
||||||
|
'onza' => $oz,
|
||||||
|
|
||||||
|
'pd' => $pd,
|
||||||
|
'фунт' => $pd,
|
||||||
|
'pound' => $pd,
|
||||||
|
'lb' => $pd,
|
||||||
|
'libra' => $pd,
|
||||||
|
'paladio' => $pd,
|
||||||
|
|
||||||
|
'st' => $st,
|
||||||
|
'стоун' => $st,
|
||||||
|
'stone' => $st,
|
||||||
|
];
|
||||||
|
|
||||||
|
$weightUnits = RetailcrmTools::filter('RetailcrmFilterWeight', $weightUnits);
|
||||||
|
|
||||||
|
$weightUnit = Configuration::get('PS_WEIGHT_UNIT');
|
||||||
|
|
||||||
|
if (isset($weightUnits[$weightUnit])) {
|
||||||
|
return $weight * $weightUnits[$weightUnit];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $weight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,12 +62,12 @@ class RetailcrmIcml
|
|||||||
'productActivity',
|
'productActivity',
|
||||||
'dimensions',
|
'dimensions',
|
||||||
'vatRate',
|
'vatRate',
|
||||||
|
'weight',
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->params = [
|
$this->params = [
|
||||||
'article' => 'Артикул',
|
'article' => 'Артикул',
|
||||||
'color' => 'Цвет',
|
'color' => 'Цвет',
|
||||||
'weight' => 'Вес',
|
|
||||||
'tax' => 'Наценка',
|
'tax' => 'Наценка',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user