![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/cartforge.co/app/code/Amasty/Label/Plugin/Block/Checkout/Cart/Crosssell/ |
<?php declare(strict_types=1); /** * @author Amasty Team * @copyright Copyright (c) Amasty (https://www.amasty.com) * @package Product Labels for Magento 2 */ namespace Amasty\Label\Plugin\Block\Checkout\Cart\Crosssell; use Amasty\Label\Model\LabelViewer; use Amasty\Label\Model\ResourceModel\Label\Collection; use Magento\Framework\Registry; use Magento\TargetRule\Block\Checkout\Cart\Crosssell; use Magento\Checkout\Block\Cart\Crosssell as CheckoutCrosssell; class AddLabel { /** * @var LabelViewer */ private $helper; /** * @var Registry */ private $registry; public function __construct( LabelViewer $helper, Registry $registry ) { $this->helper = $helper; $this->registry = $registry; } /** * @param CheckoutCrosssell|Crosssell $subject * @param string $result * * @return string * @throws \Magento\Framework\Exception\LocalizedException */ public function afterToHtml( $subject, string $result ): string { if (!$this->registry->registry('amlabel_category_observer') && !$subject->getIsAmLabelObserved()) { $products = $subject->getItemCollection(); if (!$products) { $products = $subject->getItems(); } if ($products) { foreach ($products as $product) { $result .= $this->helper->renderProductLabel( $product, Collection::MODE_LIST, true ); } $subject->setIsAmLabelObserved(true); } } return $result; } }