diff --git a/bin/css/style.css b/bin/css/style.css index 153fb1e3d5a9c504962c43055d91d4287768e28d..97abbc38ae33b3a51ed802110ff3570877116e88 100644 --- a/bin/css/style.css +++ b/bin/css/style.css @@ -86,7 +86,7 @@ body { body.iosFix { /*height: 100%;*/ - top: 0 !important; + /*top: 0 !important;*/ } body.iosFix .qui-window-popup { diff --git a/quiqqer/products/types/category.html b/quiqqer/products/types/category.html index 0fdd7bbbf135f83a9e68223d46498220cc3c5d5c..2a469589deeec5531507d588b6ae6c8dfe4b41e5 100644 --- a/quiqqer/products/types/category.html +++ b/quiqqer/products/types/category.html @@ -59,7 +59,7 @@ </div> {/if} - {if isset($ProductList) && $ProductList->count() && !empty($filter) || isset($ProductList) && $ProductList->getAttribute('showFilterInfo')} + {if !empty($filter) && (isset($ProductList) && $ProductList->count() || isset($ProductList) && $ProductList->getAttribute('showFilterInfo'))} <div class="product-sidebar-container product-sidebar-filter template-grid-row clearfix"> <header class="left-sidebar-filter-header"> <h2>{locale group="quiqqer/products" var="type.category.filterTitle"}</h2> diff --git a/quiqqer/productsearch/types/search.html b/quiqqer/productsearch/types/search.html index 505d8cb94426c0bc698e9d86dbc55c95d29c55b8..3411b94c923f212aa86cf4c15242a2369f801cc9 100644 --- a/quiqqer/productsearch/types/search.html +++ b/quiqqer/productsearch/types/search.html @@ -38,7 +38,7 @@ </form> </div> - {if isset($ProductList) && $ProductList->count() && !empty($filter)} + {if !empty($ProductList->getFilter())} <div class="product-sidebar-container product-sidebar-filter template-grid-row clearfix"> <header class="left-sidebar-filter-header"> <h2>{locale group="quiqqer/products" var="type.search.filterTitle"}</h2> diff --git a/src/QUI/TemplateCologne/Controls/ProductGallery.php b/src/QUI/TemplateCologne/Controls/ProductGallery.php index b983f7c92eebe54040d84020d8062863fdb457a7..e8a5500701e2048b6724b682b42e0526ef7b6cb3 100644 --- a/src/QUI/TemplateCologne/Controls/ProductGallery.php +++ b/src/QUI/TemplateCologne/Controls/ProductGallery.php @@ -8,6 +8,8 @@ use QUI; use QUI\ERP\Products\Handler\Fields; +use function is_a; +use function usort; /** * Class ProductGallery @@ -22,29 +24,36 @@ class ProductGallery extends QUI\Control public function __construct($attributes = []) { $this->setAttributes([ - 'Product' => false, -// 'data-qui' => 'package/quiqqer/products/bin/controls/frontend/products/Product' + 'Product' => false ]); -// $this->addCSSFile(dirname(__FILE__).'/ProductGallery.css'); - parent::__construct($attributes); } /** * (non-PHPdoc) * + * @throws QUI\Exception * @see \QUI\Control::create() * - * @throws QUI\Exception */ public function getBody() { - /* @var $Product QUI\ERP\Products\Product\Product */ + if (!$this->getAttribute('Product')) { + return ''; + } + $Engine = QUI::getTemplateManager()->getEngine(); $Product = $this->getAttribute('Product'); $Gallery = new QUI\Gallery\Controls\Slider(); + if ($Product instanceof QUI\ERP\Products\Product\ViewFrontend) { + $Product = $Product->getProduct(); + } + + $typeVariantParent = is_a($Product->getType(), QUI\ERP\Products\Product\Types\VariantParent::class, true); + $typeVariantChild = is_a($Product->getType(), QUI\ERP\Products\Product\Types\VariantChild::class, true); + // gallery $PlaceholderImage = $this->getProject()->getMedia()->getPlaceholderImage(); @@ -62,6 +71,14 @@ public function getBody() } catch (QUI\Exception $Exception) { } + if ($typeVariantParent || $typeVariantChild) { + $Gallery->setAttribute('folderId', false); + + foreach ($this->getVariantImages($Product) as $Image) { + $Gallery->addImage($Image); + } + } + $height = '400px'; if ($this->getAttribute('height')) { $height = $this->getAttribute('height'); @@ -72,7 +89,7 @@ public function getBody() $Gallery->setAttribute('data-qui-options-show-controls-always', 0); $Gallery->setAttribute('data-qui-options-show-title-always', 0); $Gallery->setAttribute('data-qui-options-show-title', 0); - $Gallery->setAttribute('data-qui-options-imagefit', 0); + $Gallery->setAttribute('data-qui-options-imagefit', 1); $Gallery->setAttribute('data-qui-options-preview', 1); $Gallery->setAttribute('data-qui-options-preview-outside', 1); @@ -83,6 +100,57 @@ public function getBody() 'Gallery' => $Gallery, ]); - return $Engine->fetch(dirname(__FILE__) . '/ProductGallery.html'); + return $Engine->fetch(dirname(__FILE__).'/ProductGallery.html'); + } + + /** + * Get product images (for variant parents and children). + * \QUI\ERP\Products\Controls\Products\Product::getVariantImages + * By @peat + * + * @param QUI\ERP\Products\Product\Product $Product + * @return QUI\Projects\Media\Image[] + */ + protected function getVariantImages(QUI\ERP\Products\Product\Product $Product): array + { + $images = $Product->getImages(); + + try { + $MainImage = $Product->getImage(); + $mainImageId = $MainImage->getId(); + $hasMainImage = false; + + foreach ($images as $Image) { + if ($Image->getId() === $MainImage->getId()) { + $hasMainImage = true; + break; + } + } + + if (!$hasMainImage) { + $images[] = $MainImage; + } + } catch (\Exception $Exception) { + QUI\System\Log::writeDebugException($Exception); + $mainImageId = false; + } + + usort($images, function ($ImageA, $ImageB) use ($mainImageId) { + /** + * @var QUI\Projects\Media\Image $ImageA + * @var QUI\Projects\Media\Image $ImageB + */ + if ($ImageA->getId() === $mainImageId) { + return -1; + } + + if ($ImageB->getId() === $mainImageId) { + return 1; + } + + return 0; + }); + + return $images; } }