![]() 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/View/ |
<?php /** * @author Amasty Team * @copyright Copyright (c) Amasty (https://www.amasty.com) * @package Product Labels for Magento 2 */ namespace Amasty\Label\Plugin\Catalog\Product\View; use Amasty\Label\Model\LabelViewer; use Amasty\Label\Model\ResourceModel\Label\Collection; class Label { /** * @var array */ private $allowedNames = [ 'product.info.media.magiczoomplus', 'product.info.media.image', 'product.info.media.magicthumb.younify' ]; /** * @var LabelViewer */ private $helper; public function __construct( LabelViewer $helper, array $allowedNames = [] ) { $this->helper = $helper; $this->allowedNames = array_merge($this->allowedNames, array_values($allowedNames)); } /** * @param $subject * @param $result * @return string * @throws \Magento\Framework\Exception\LocalizedException */ public function afterToHtml( $subject, $result ) { $product = $subject->getProduct(); $name = $subject->getNameInLayout(); if ($product && in_array($name, $this->getAllowedNames()) && !$subject->getAmlabelObserved() ) { $subject->setAmlabelObserved(true); $result .= $this->helper->renderProductLabel($product, Collection::MODE_PDP); } return $result; } /** * @return array */ public function getAllowedNames() { return $this->allowedNames; } }