![]() 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/old/app/code/Kaliop/CatalogGenericProductItem/ViewModel/Product/ |
<?php /** * Copyright (c) 2020 Kaliop Digital Commerce (https://digitalcommerce.kaliop.com) All Rights Reserved. * https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * kaliop_cataloggenericproductitem_m2 * <[email protected]> */ declare(strict_types=1); namespace Kaliop\CatalogGenericProductItem\ViewModel\Product; use Kaliop\CatalogGenericProductItem\Block\Product\ProductList\Item\Block; use Magento\Catalog\Api\Data\ProductInterface; use Magento\Framework\DataObject; use Magento\Framework\View\Element\Block\ArgumentInterface; use Magento\Framework\View\Element\BlockInterface; use Magento\Framework\View\LayoutInterface; class Item extends DataObject implements ArgumentInterface { /** * @var LayoutInterface */ private $layout; /** * @var array */ private $defaultParams = []; /** * Item constructor. * @param LayoutInterface $layout * @param array $defaultParams */ public function __construct( LayoutInterface $layout, array $defaultParams = [] ) { $this->layout = $layout; $this->defaultParams = $defaultParams; } /** * @param ProductInterface $product * @param BlockInterface $parentBlock * @param array $params * @param string $templateName * @param string $blocTypeClassName * @return string */ public function renderProductListItem( ProductInterface $product, BlockInterface $parentBlock, array $params = [], $templateName = 'Kaliop_CatalogGenericProductItem::item.phtml', $blocTypeClassName = Block::class ): string { $block = $this->layout->createBlock($blocTypeClassName); if ($templateName) { $block->setTemplate($templateName); } $block->setProduct($product); $block->setData('parent_block', $parentBlock); /** * @see /vendor/kaliop/module-cataloggenericproductitem/etc/di.xml */ $block->addData($this->defaultParams); if ($params) { $block->addData($params); } return $block->toHtml(); } }