![]() 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/Webkul/PrivateShop/Ui/Component/Listing/Column/ |
<?php /** * Webkul Software * * @category Webkul * @package Webkul_PrivateShop * @author Webkul Software Private Limited * @copyright Webkul Software Private Limited (https://webkul.com) * @license https://store.webkul.com/license.html */ namespace Webkul\PrivateShop\Ui\Component\Listing\Column; use Magento\Framework\View\Element\UiComponent\ContextInterface; use Magento\Framework\View\Element\UiComponentFactory; use Magento\Ui\Component\Listing\Columns\Column; class StoreName extends Column { /** * Constant for All Store */ public const ALL_STORE = 'All Store Views'; /** * @var \Magento\Store\Model\StoreManagerInterface */ protected $storeManager; /** * @param ContextInterface $context * @param UiComponentFactory $uiComponentFactory * @param \Magento\Store\Model\StoreManagerInterface $storeManager * @param array $components * @param array $data */ public function __construct( ContextInterface $context, UiComponentFactory $uiComponentFactory, \Magento\Store\Model\StoreManagerInterface $storeManager, array $components = [], array $data = [] ) { parent::__construct($context, $uiComponentFactory, $components, $data); $this->storeManager = $storeManager; } /** * Prepare Data Source * * @param array $dataSource * @return array */ public function prepareDataSource(array $dataSource) { if (isset($dataSource['data']['items'])) { foreach ($dataSource['data']['items'] as &$item) { $item['store_id'] = $this->getStoreName($item['store_id']); } } return $dataSource; } /** * Get store name * * @param int $storeId * @return string */ public function getStoreName($storeId) { if ($storeId == 0) { return self::ALL_STORE; } $storeData = $this->storeManager->getStore($storeId); $storeName = (string)$storeData->getName(); return $storeName; } }