mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-03-01 19:03:14 +03:00
Add cover on first position in pictures
This commit is contained in:
parent
72639aadbb
commit
9c22f2c855
@ -112,8 +112,8 @@ class RetailcrmCatalog
|
||||
$id_lang = $this->default_lang;
|
||||
$homeCategory = $this->home_category;
|
||||
|
||||
$inactiveCategories = array();
|
||||
$categoriesIds = array();
|
||||
$inactiveCategories = [];
|
||||
$categoriesIds = [];
|
||||
|
||||
$types = Category::getCategories($id_lang, true, false);
|
||||
|
||||
@ -219,22 +219,17 @@ class RetailcrmCatalog
|
||||
|
||||
if (!empty($combinations)) {
|
||||
foreach ($combinations as $combination) {
|
||||
$arSet = array(
|
||||
$arSet = [
|
||||
'group_name' => $combination['group_name'],
|
||||
'attribute' => $combination['attribute_name'],
|
||||
);
|
||||
];
|
||||
|
||||
$arComb[] = $arSet;
|
||||
}
|
||||
}
|
||||
|
||||
$pictures = array();
|
||||
$covers = Image::getImages($id_lang, $product['id_product'], $offer['id_product_attribute']);
|
||||
|
||||
foreach ($covers as $cover) {
|
||||
$picture = $this->protocol . $this->link->getImageLink($product['link_rewrite'], $product['id_product'] . '-' . $cover['id_image'], 'large_default');
|
||||
$pictures[] = $picture;
|
||||
}
|
||||
$pictures = $this->getPictures($covers, $product, true);
|
||||
|
||||
if (!$pictures) {
|
||||
$image = Image::getCover($product['id_product']);
|
||||
@ -269,7 +264,7 @@ class RetailcrmCatalog
|
||||
$offerArticle = $article;
|
||||
}
|
||||
|
||||
$item = array(
|
||||
$item = [
|
||||
'id' => $product['id_product'] . '#' . $offer['id_product_attribute'],
|
||||
'productId' => $product['id_product'],
|
||||
'productActivity' => ($available_for_order) ? 'Y' : 'N',
|
||||
@ -286,7 +281,7 @@ class RetailcrmCatalog
|
||||
'weight' => $weight,
|
||||
'dimensions' => $dimensions,
|
||||
'vatRate' => $product['rate'],
|
||||
);
|
||||
];
|
||||
|
||||
if (!empty($combinations)) {
|
||||
foreach ($arComb as $itemComb) {
|
||||
@ -297,21 +292,17 @@ class RetailcrmCatalog
|
||||
yield RetailcrmTools::filter(
|
||||
'RetailcrmFilterProcessOffer',
|
||||
$item,
|
||||
array(
|
||||
[
|
||||
'product' => $product,
|
||||
'offer' => $offer
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$offersCount++;
|
||||
|
||||
$pictures = array();
|
||||
$covers = Image::getImages($id_lang, $product['id_product'], null);
|
||||
foreach ($covers as $cover) {
|
||||
$picture = $this->protocol . $this->link->getImageLink($product['link_rewrite'], $product['id_product'] . '-' . $cover['id_image'], 'large_default');
|
||||
$pictures[] = $picture;
|
||||
}
|
||||
$pictures = $this->getPictures($covers, $product);
|
||||
|
||||
if ($this->version == "1.3") {
|
||||
$quantity = $product['quantity'];
|
||||
@ -319,7 +310,7 @@ class RetailcrmCatalog
|
||||
$quantity = (int)StockAvailable::getQuantityAvailableByProduct($product['id_product']);
|
||||
}
|
||||
|
||||
$item = array(
|
||||
$item = [
|
||||
'id' => $product['id_product'],
|
||||
'productId' => $product['id_product'],
|
||||
'productActivity' => ($available_for_order) ? 'Y' : 'N',
|
||||
@ -336,14 +327,14 @@ class RetailcrmCatalog
|
||||
'weight' => $weight,
|
||||
'dimensions' => $dimensions,
|
||||
'vatRate' => $product['rate'],
|
||||
);
|
||||
];
|
||||
|
||||
yield RetailcrmTools::filter(
|
||||
'RetailcrmFilterProcessOffer',
|
||||
$item,
|
||||
array(
|
||||
[
|
||||
'product' => $product
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -354,6 +345,22 @@ class RetailcrmCatalog
|
||||
RetailcrmCatalogHelper::setIcmlFileInfo($productsCount, $offersCount);
|
||||
}
|
||||
|
||||
private function getPictures(array $covers, array $product, $offers = false)
|
||||
{
|
||||
$pictures = [];
|
||||
foreach ($covers as $cover) {
|
||||
$picture = $this->protocol . $this->link->getImageLink($product['link_rewrite'], $product['id_product'] . '-' . $cover['id_image'], 'large_default');
|
||||
|
||||
if ($offers === false && $cover['cover']) {
|
||||
array_unshift($pictures, $picture);
|
||||
} else {
|
||||
$pictures[] = $picture;
|
||||
}
|
||||
|
||||
}
|
||||
return $pictures;
|
||||
}
|
||||
|
||||
private static function getProductsCount(
|
||||
$id_lang,
|
||||
Context $context = null
|
||||
|
Loading…
x
Reference in New Issue
Block a user