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