![]() 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/Catalog/Product/ |
<?php /** * @author Amasty Team * @copyright Copyright (c) Amasty (https://www.amasty.com) * @package Product Labels for Magento 2 */ namespace Amasty\Label\Plugin\Catalog\Product; use Amasty\Label\Model\AbstractLabels; use Amasty\Label\Model\ResourceModel\Label\Collection; class ListProduct { /** * @var \Amasty\Label\Model\LabelViewer */ private $helper; /** * @var \Magento\Framework\Registry */ private $registry; public function __construct( \Amasty\Label\Model\LabelViewer $helper, \Magento\Framework\Registry $registry ) { $this->helper = $helper; $this->registry = $registry; } /** * @param $subject * @param $result * @return string * @throws \Magento\Framework\Exception\LocalizedException */ public function afterToHtml( $subject, $result ) { if (!$this->registry->registry('amlabel_category_observer') && !$subject->getIsAmLabelObserved()) { $products = $subject->getLoadedProductCollection(); if (!$products) { $products = $subject->getProductCollection(); } if ($products) { foreach ($products as $product) { $result .= $this->helper->renderProductLabel( $product, Collection::MODE_LIST, true ); } $subject->setIsAmLabelObserved(true); } } return $result; } }