custom/plugins/WbfkExtensions/src/CmsElementResolver/ProductSliderCmsElementResolver.php line 43

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace WbfkExtensions\CmsElementResolver;
  4. use Shopware\Core\Content\Cms\Aggregate\CmsSlot\CmsSlotEntity;
  5. use Shopware\Core\Content\Cms\DataResolver\CriteriaCollection;
  6. use Shopware\Core\Content\Cms\DataResolver\Element\ElementDataCollection;
  7. use Shopware\Core\Content\Cms\DataResolver\ResolverContext\ResolverContext;
  8. use Shopware\Core\Content\Product\Aggregate\ProductVisibility\ProductVisibilityDefinition;
  9. use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
  10. use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\RangeFilter;
  11. class ProductSliderCmsElementResolver extends \Shopware\Core\Content\Product\Cms\ProductSliderCmsElementResolver
  12. {
  13.     use SliderElementResolverTrait;
  14.     public function collect(CmsSlotEntity $slotResolverContext $resolverContext): ?CriteriaCollection
  15.     {
  16.         $collection parent::collect($slot$resolverContext);
  17.         if ($collection) {
  18.             /** @var Criteria[] $criteriaCollection */
  19.             foreach ($collection as $criteriaCollection) {
  20.                 foreach ($criteriaCollection as $criteria) {
  21.                     $criteria
  22.                         ->addAssociation('options.variant')
  23.                         ->addAssociation('featureSet')
  24.                         ->addAssociation('deliveryTime')
  25.                         ->addAssociation('properties')
  26.                         ->addAssociation('properties.group')
  27.                         ->addAssociation('tags');
  28.                     $criteria->addFilter(new RangeFilter('product.visibilities.visibility', [RangeFilter::GTE => ProductVisibilityDefinition::VISIBILITY_ALL]));
  29.                 }
  30.             }
  31.         }
  32.         return ($collection && $collection->all()) ? $collection null;
  33.     }
  34.     public function enrich(CmsSlotEntity $slotResolverContext $resolverContextElementDataCollection $result): void
  35.     {
  36.         parent::enrich($slot$resolverContext$result);
  37.         $responsive = ['xs' => 1'sm' => 2'md' => 2'lg' => 3'xl' => 4];
  38.         $fieldConfig $slot->getFieldConfig();
  39.         $additionalDate = [];
  40.         $this->getSliderConfig($additionalDate$fieldConfig$responsive);;
  41.         $slot->assign($additionalDate);
  42.     }
  43. }