setDefaultLayout example

return [
            ProductEvents::PRODUCT_LOADED_EVENT => 'loaded',
            'product.partial_loaded' => 'loaded',
            'sales_channel.' . ProductEvents::PRODUCT_LOADED_EVENT => 'salesChannelLoaded',
            'sales_channel.product.partial_loaded' => 'salesChannelLoaded',
        ];
    }

    public function loaded(EntityLoadedEvent $event): void
    {
        foreach ($event->getEntities() as $product) {
            $this->setDefaultLayout($product);

            $this->productVariationBuilder->build($product);
        }
    }

    public function salesChannelLoaded(SalesChannelEntityLoadedEvent $event): void
    {
        foreach ($event->getEntities() as $product) {
            $price = $product->get('cheapestPrice');

            if ($price instanceof CheapestPriceContainer) {
                
Home | Imprint | This part of the site doesn't use cookies.