/** * Display search result * * @return void */ public function execute() { $this->layerResolver->create(Resolver::CATALOG_LAYER_SEARCH); /* @var $query \Magento\Search\Model\Query */ $query = $this->_queryFactory->get(); $query->setStoreId($this->_storeManager->getStore()->getId()); if ($query->getQueryText() != '') { if ($this->_objectManager->get('Magento\\CatalogSearch\\Helper\\Data')->isMinQueryLength()) { $query->setId(0)->setIsActive(1)->setIsProcessed(1); } else { if ($query->getId()) { $query->setPopularity($query->getPopularity() + 1); } else { $query->setPopularity(1); } if ($query->getRedirect()) { $query->save(); $this->getResponse()->setRedirect($query->getRedirect()); return; } else { $query->prepare(); } } $this->_objectManager->get('Magento\\CatalogSearch\\Helper\\Data')->checkNotes(); $this->_view->loadLayout(); $this->_view->renderLayout(); if (!$this->_objectManager->get('Magento\\CatalogSearch\\Helper\\Data')->isMinQueryLength()) { $query->save(); } } else { $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl()); } }
/** * Perform operations after collection load * * @param string $tableName * @param string|null $linkField * @return void */ protected function performAfterLoad($tableName, $linkField) { $linkedIds = $this->getColumnValues($linkField); if (count($linkedIds)) { $connection = $this->getConnection(); $select = $connection->select()->from(['cms_entity_store' => $this->getTable($tableName)])->where('cms_entity_store.' . $linkField . ' IN (?)', $linkedIds); $result = $connection->fetchAll($select); if ($result) { $storesData = []; foreach ($result as $storeData) { $storesData[$storeData[$linkField]][] = $storeData['store_id']; } foreach ($this as $item) { $linkedId = $item->getData($linkField); if (!isset($storesData[$linkedId])) { continue; } $storeIdKey = array_search(Store::DEFAULT_STORE_ID, $storesData[$linkedId], true); if ($storeIdKey !== false) { $stores = $this->storeManager->getStores(false, true); $storeId = current($stores)->getId(); $storeCode = key($stores); } else { $storeId = current($storesData[$linkedId]); $storeCode = $this->storeManager->getStore($storeId)->getCode(); } $item->setData('_first_store_id', $storeId); $item->setData('store_code', $storeCode); $item->setData('store_id', $storesData[$linkedId]); } } } }
/** * {@inheritdoc} * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function getCatalogPrice(\Magento\Catalog\Model\Product $product, \Magento\Store\Api\Data\StoreInterface $store = null, $inclTax = false) { // Workaround to avoid loading stock status by admin's website if ($store instanceof \Magento\Store\Api\Data\StoreInterface) { $currentStore = $this->storeManager->getStore(); $this->storeManager->setCurrentStore($store->getId()); } $subProducts = $product->getTypeInstance()->getAssociatedProducts($product); if ($store instanceof \Magento\Store\Api\Data\StoreInterface) { $this->storeManager->setCurrentStore($currentStore->getId()); } if (!$subProducts) { return null; } $minPrice = null; foreach ($subProducts as $subProduct) { $subProduct->setWebsiteId($product->getWebsiteId())->setCustomerGroupId($product->getCustomerGroupId()); if ($subProduct->isSalable()) { if ($this->commonPriceModel->getCatalogPrice($subProduct) < $minPrice || $minPrice === null) { $minPrice = $this->commonPriceModel->getCatalogPrice($subProduct); $product->setTaxClassId($subProduct->getTaxClassId()); } } } return $minPrice; }
/** * Retrieve stores configured in system. * * @return \Magento\Framework\Data\Collection\AbstractDb */ public function getStores() { if (!$this->_stores) { $this->_stores = $this->_storeManager->getStore()->getResourceCollection()->load(); } return $this->_stores; }
/** * @param \Magento\Framework\App\ActionInterface $subject * @param callable $proceed * @param \Magento\Framework\App\RequestInterface $request * * @return \Magento\Framework\App\ResponseInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) * @throws \Magento\Framework\Exception\State\InitException */ public function aroundDispatch(\Magento\Framework\App\ActionInterface $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request) { if (!$this->_storeManager->getStore()->isActive()) { throw new \Magento\Framework\Exception\State\InitException(__('Current store is not active.')); } return $proceed($request); }
/** * Execute method. * * @param \Magento\Framework\Event\Observer $observer * * @return $this */ public function execute(\Magento\Framework\Event\Observer $observer) { $order = $observer->getEvent()->getOrder(); $email = $order->getCustomerEmail(); $website = $this->storeManager->getWebsite($order->getWebsiteId()); $storeName = $this->storeManager->getStore($order->getStoreId())->getName(); //if api is not enabled if (!$this->helper->isEnabled($website)) { return $this; } //automation enrolment for order if ($order->getCustomerIsGuest()) { // guest to automation mapped $programType = 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_GUEST_ORDER'; $automationType = \Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_TYPE_NEW_GUEST_ORDER; } else { // customer to automation mapped $programType = 'XML_PATH_CONNECTOR_AUTOMATION_STUDIO_ORDER'; $automationType = \Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_TYPE_NEW_ORDER; } $programId = $this->helper->getAutomationIdByType($programType, $order->getWebsiteId()); //the program is not mapped if (!$programId) { return $this; } try { $this->automationFactory->create()->setEmail($email)->setAutomationType($automationType)->setEnrolmentStatus(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_STATUS_PENDING)->setTypeId($order->getId())->setWebsiteId($website->getId())->setStoreName($storeName)->setProgramId($programId)->save(); } catch (\Exception $e) { $this->helper->debug((string) $e, []); } return $this; }
/** * Prepare data before save * * @param \Magento\Framework\DataObject $object * @return $this */ protected function _beforeSave($object) { if (!$object->getData($this->getAttribute()->getAttributeCode())) { $object->setData($this->getAttribute()->getAttributeCode(), $this->_storeManager->getStore()->getId()); } return $this; }
/** * {@inheritdoc} */ public function addFilter(Collection $collection, $field, $condition = null) { if (isset($condition['eq']) && $condition['eq']) { /** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */ $collection->addStoreFilter($this->storeManager->getStore($condition['eq'])); } }
/** * {@inheritdoc} */ public function setMethod($cartId, $carrierCode, $methodCode) { /** @var \Magento\Sales\Model\Quote $quote */ $quote = $this->quoteLoader->load($cartId, $this->storeManager->getStore()->getId()); if (0 == $quote->getItemsCount()) { throw new InputException('Shipping method is not applicable for empty cart'); } if ($quote->isVirtual()) { throw new NoSuchEntityException('Cart contains virtual product(s) only. Shipping method is not applicable.'); } $shippingAddress = $quote->getShippingAddress(); if (!$shippingAddress->getCountryId()) { throw new StateException('Shipping address is not set'); } $billingAddress = $quote->getBillingAddress(); if (!$billingAddress->getCountryId()) { throw new StateException('Billing address is not set'); } $shippingAddress->setShippingMethod($carrierCode . '_' . $methodCode); if (!$shippingAddress->requestShippingRates()) { throw new NoSuchEntityException('Carrier with such method not found: ' . $carrierCode . ', ' . $methodCode); } try { $quote->collectTotals()->save(); } catch (\Exception $e) { throw new CouldNotSaveException('Cannot set shipping method. ' . $e->getMessage()); } return true; }
/** * Retrieves the current Store ID from Magento and adds it to the record * * @param array $record * @return array */ public function __invoke(array $record) { // get the store_id and add it to the record $store = $this->storeManager->getStore(); $record['extra']['store_id'] = $store->getId(); return $record; }
/** * Get store object * * @return \Magento\Store\Model\Store */ public function getStore() { if ($this->getShipment()) { return $this->getShipment()->getStore(); } return $this->_storeManager->getStore(); }
/** * Get url for config settings where base url option can be changed * * @return string */ protected function _getConfigUrl() { $output = ''; $defaultUnsecure = $this->_config->getValue(Store::XML_PATH_UNSECURE_BASE_URL, 'default'); $defaultSecure = $this->_config->getValue(Store::XML_PATH_SECURE_BASE_URL, 'default'); if ($defaultSecure == \Magento\Store\Model\Store::BASE_URL_PLACEHOLDER || $defaultUnsecure == \Magento\Store\Model\Store::BASE_URL_PLACEHOLDER) { $output = $this->_urlBuilder->getUrl('adminhtml/system_config/edit', ['section' => 'web']); } else { /** @var $dataCollection \Magento\Config\Model\Resource\Config\Data\Collection */ $dataCollection = $this->_configValueFactory->create()->getCollection(); $dataCollection->addValueFilter(\Magento\Store\Model\Store::BASE_URL_PLACEHOLDER); /** @var $data \Magento\Framework\App\Config\ValueInterface */ foreach ($dataCollection as $data) { if ($data->getScope() == 'stores') { $code = $this->_storeManager->getStore($data->getScopeId())->getCode(); $output = $this->_urlBuilder->getUrl('adminhtml/system_config/edit', ['section' => 'web', 'store' => $code]); break; } elseif ($data->getScope() == 'websites') { $code = $this->_storeManager->getWebsite($data->getScopeId())->getCode(); $output = $this->_urlBuilder->getUrl('adminhtml/system_config/edit', ['section' => 'web', 'website' => $code]); break; } } } return $output; }
public function exportModules($data) { $moduleTables = $this->getModuleTables(); $configs = []; if (!empty($data['modules'])) { $store = $this->_storeManager->getStore($data['store_id']); foreach ($data['modules'] as $k => $v) { if (isset($moduleTables[$v])) { $tables = $moduleTables[$v]; } $systemFileDir = $this->_moduleDir->getDir($v, Dir::MODULE_ETC_DIR) . DIRECTORY_SEPARATOR . 'adminhtml' . DIRECTORY_SEPARATOR . 'system.xml'; if (file_exists($systemFileDir)) { $systemConfigs = $this->parser->load($systemFileDir)->xmlToArray(); if ($systemConfigs['config']['_value']['system']['section']) { foreach ($systemConfigs['config']['_value']['system']['section'] as $_section) { $groups = []; if (isset($_section['_value']['group'])) { $groups = $_section['_value']['group']; } elseif (isset($_section['group'])) { $groups = $_section['group']; } $_sectionId = ''; if (isset($_section['_attribute']['id'])) { $_sectionId = $_section['_attribute']['id']; } elseif (isset($systemConfigs['config']['_value']['system']['section']['_attribute']['id'])) { $_sectionId = $systemConfigs['config']['_value']['system']['section']['_attribute']['id']; } if (empty($groups)) { continue; } foreach ($groups as $_group) { if (!isset($_group['_value']['field'])) { continue; } foreach ($_group['_value']['field'] as $_field) { if (isset($_sectionId) && isset($_group['_attribute']['id']) && isset($_field['_attribute']['id'])) { $key = $_sectionId . '/' . $_group['_attribute']['id'] . '/' . $_field['_attribute']['id']; $result = $this->_scopeConfig->getValue($key, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $store); if ($result == '') { continue; } $configs[$v]['system_configs'][] = ['key' => $key, 'value' => $result]; } } } } } } if (isset($moduleTables[$v]) && is_array($moduleTables[$v])) { foreach ($moduleTables[$v] as $key => $tableName) { $connection = $this->_resource->getConnection(); $select = 'SELECT * FROM ' . $this->_resource->getTableName($tableName); $rows = $connection->fetchAll($select); $configs[$v]['tables'][$tableName] = $rows; } } } } return $configs; }
/** * If it's configured to capture on shipment - do this. * * @param \Magento\Framework\Event\Observer $observer * * @return $this */ public function execute(\Magento\Framework\Event\Observer $observer) { $dataObject = $observer->getEvent()->getDataObject(); if ($dataObject->getCustomerId() && $dataObject->getStatusId() == \Magento\Review\Model\Review::STATUS_APPROVED) { $customerId = $dataObject->getCustomerId(); $this->helper->setConnectorContactToReImport($customerId); //save review info in the table $this->registerReview($dataObject); $store = $this->storeManager->getStore($dataObject->getStoreId()); $storeName = $store->getName(); $website = $this->storeManager->getStore($store)->getWebsite(); $customer = $this->customerFactory->create()->load($customerId); //if api is not enabled if (!$this->helper->isEnabled($website)) { return $this; } $programId = $this->helper->getWebsiteConfig('connector_automation/visitor_automation/review_automation'); if ($programId) { $automation = $this->automationFactory->create(); $automation->setEmail($customer->getEmail())->setAutomationType(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_TYPE_NEW_REVIEW)->setEnrolmentStatus(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_STATUS_PENDING)->setTypeId($dataObject->getReviewId())->setWebsiteId($website->getId())->setStoreName($storeName)->setProgramId($programId); $automation->save(); } } return $this; }
/** * Get data * * @param array $item * @return string */ protected function prepareItem(array $item) { if ($item['store_id'] == \Magento\Store\Model\Store::DEFAULT_STORE_ID) { return __('All Store Views'); } return $this->storeManager->getStore($item['store_id'])->getName(); }
public function testProcessWithoutStoreCode() { $path = 'rest/V1/customerAccounts/createCustomer'; $result = $this->pathProcessor->process($path); $this->assertEquals('/V1/customerAccounts/createCustomer', $result); $this->assertEquals('default', $this->storeManager->getStore()->getCode()); }
/** * {@inheritdoc} */ public function save(\Magento\Catalog\Api\Data\CategoryInterface $category) { $existingData = $category->toFlatArray(); if ($category->getId()) { $existingCategory = $this->get($category->getId()); if (isset($existingData['image']) && is_array($existingData['image'])) { $existingData['image_additional_data'] = $existingData['image']; unset($existingData['image']); } $existingData['id'] = $existingCategory->getId(); $existingData['parent_id'] = $existingCategory->getParentId(); $existingData['path'] = $existingCategory->getPath(); $existingData['is_active'] = $existingCategory->getIsActive(); $existingData['include_in_menu'] = isset($existingData['include_in_menu']) ? (bool) $existingData['include_in_menu'] : false; $category->setData($existingData); } else { $parentId = $category->getParentId() ?: $this->storeManager->getStore()->getRootCategoryId(); $parentCategory = $this->get($parentId); $existingData['include_in_menu'] = isset($existingData['include_in_menu']) ? (bool) $existingData['include_in_menu'] : false; /** @var $category Category */ $category->setData($existingData); $category->setPath($parentCategory->getPath()); } try { $this->validateCategory($category); $this->categoryResource->save($category); } catch (\Exception $e) { throw new CouldNotSaveException(__('Could not save category: %1', $e->getMessage()), $e); } unset($this->instances[$category->getId()]); return $category; }
/** * Retrieve tracking url with params * * @param string $key * @param \Magento\Sales\Model\Order|\Magento\Sales\Model\Order\Shipment|\Magento\Sales\Model\Order\Shipment\Track $model * @param string $method Optional - method of a model to get id * @return string */ protected function _getTrackingUrl($key, $model, $method = 'getId') { $urlPart = "{$key}:{$model->{$method}()}:{$model->getProtectCode()}"; $params = ['_direct' => 'shipping/tracking/popup', '_query' => ['hash' => $this->urlEncoder->encode($urlPart)]]; $storeModel = $this->_storeManager->getStore($model->getStoreId()); return $storeModel->getUrl('', $params); }
/** * Send confirmation link to specified email * * @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\View\Result\Page */ public function execute() { if ($this->session->isLoggedIn()) { /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); $resultRedirect->setPath('*/*/'); return $resultRedirect; } // try to confirm by email $email = $this->getRequest()->getPost('email'); if ($email) { /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */ $resultRedirect = $this->resultRedirectFactory->create(); try { $this->customerAccountManagement->resendConfirmation($email, $this->storeManager->getStore()->getWebsiteId()); $this->messageManager->addSuccess(__('Please check your email for confirmation key.')); } catch (InvalidTransitionException $e) { $this->messageManager->addSuccess(__('This email does not require confirmation.')); } catch (\Exception $e) { $this->messageManager->addException($e, __('Wrong email.')); $resultRedirect->setPath('*/*/*', ['email' => $email, '_secure' => true]); return $resultRedirect; } $this->session->setUsername($email); $resultRedirect->setPath('*/*/index', ['_secure' => true]); return $resultRedirect; } /** @var \Magento\Framework\View\Result\Page $resultPage */ $resultPage = $this->resultPageFactory->create(); $resultPage->getLayout()->getBlock('accountConfirmation')->setEmail($this->getRequest()->getParam('email', $email)); return $resultPage; }
/** * @param DesignConfigRepository $subject * @param DesignConfigInterface $designConfig * @return DesignConfigInterface * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ public function afterDelete(DesignConfigRepository $subject, DesignConfigInterface $designConfig) { $website = in_array($designConfig->getScope(), [ScopeInterface::SCOPE_WEBSITE, ScopeInterface::SCOPE_WEBSITES]) ? $this->storeManager->getWebsite($designConfig->getScopeId()) : ''; $store = in_array($designConfig->getScope(), [ScopeInterface::SCOPE_STORE, ScopeInterface::SCOPE_STORES]) ? $this->storeManager->getStore($designConfig->getScopeId()) : ''; $this->eventManager->dispatch('admin_system_config_changed_section_design', ['website' => $website, 'store' => $store]); return $designConfig; }
/** * Retrieve store * * @return \Magento\Store\Model\Store */ public function getStore() { if ($this->_store === null) { $this->_store = $this->_storeManager->getStore(); } return $this->_store; }
/** * Get store object * * @return \Magento\Store\Model\Store */ public function getStore() { if ($this->getCreditmemo()) { return $this->getCreditmemo()->getStore(); } return $this->_storeManager->getStore(); }
/** * Save newsletter subscription preference action * * @return void|null */ public function executeInternal() { if (!$this->formKeyValidator->validate($this->getRequest())) { return $this->_redirect('customer/account/'); } $customerId = $this->_customerSession->getCustomerId(); if ($customerId === null) { $this->messageManager->addError(__('Something went wrong while saving your subscription.')); } else { try { $customer = $this->customerRepository->getById($customerId); $storeId = $this->storeManager->getStore()->getId(); $customer->setStoreId($storeId); $this->customerRepository->save($customer); if ((bool) $this->getRequest()->getParam('is_subscribed', false)) { $this->subscriberFactory->create()->subscribeCustomerById($customerId); $this->messageManager->addSuccess(__('We saved the subscription.')); } else { $this->subscriberFactory->create()->unsubscribeCustomerById($customerId); $this->messageManager->addSuccess(__('We removed the subscription.')); } } catch (\Exception $e) { $this->messageManager->addError(__('Something went wrong while saving your subscription.')); } } $this->_redirect('customer/account/'); }
/** * {@inheritDoc} */ public function isFreeShipping(\Magento\Quote\Model\Quote $quote, $items) { /** @var \Magento\Quote\Api\Data\CartItemInterface[] $items */ if (!count($items)) { return false; } $addressFreeShipping = true; $store = $this->storeManager->getStore($quote->getStoreId()); $this->calculator->init($store->getWebsiteId(), $quote->getCustomerGroupId(), $quote->getCouponCode()); /** @var \Magento\Quote\Api\Data\CartItemInterface $item */ foreach ($items as $item) { if ($item->getNoDiscount()) { $addressFreeShipping = false; $item->setFreeShipping(false); continue; } /** Child item discount we calculate for parent */ if ($item->getParentItemId()) { continue; } $this->calculator->processFreeShipping($item); $itemFreeShipping = (bool) $item->getFreeShipping(); $addressFreeShipping = $addressFreeShipping && $itemFreeShipping; /** Parent free shipping we apply to all children*/ $this->applyToChildren($item, $itemFreeShipping); } return $addressFreeShipping; }
/** * Return current store id * * @return int */ public function getStoreId() { if ($this->_storeId === null) { $this->setStoreId($this->_storeManager->getStore()->getId()); } return $this->_storeId; }
/** * {@inheritdoc} */ public function set(\Magento\Checkout\Service\V1\Data\Cart\PaymentMethod $method, $cartId) { $quote = $this->quoteLoader->load($cartId, $this->storeManager->getStore()->getId()); $payment = $this->paymentMethodBuilder->build($method, $quote); if ($quote->isVirtual()) { // check if billing address is set if (is_null($quote->getBillingAddress()->getCountryId())) { throw new InvalidTransitionException('Billing address is not set'); } $quote->getBillingAddress()->setPaymentMethod($payment->getMethod()); } else { // check if shipping address is set if (is_null($quote->getShippingAddress()->getCountryId())) { throw new InvalidTransitionException('Shipping address is not set'); } $quote->getShippingAddress()->setPaymentMethod($payment->getMethod()); } if (!$quote->isVirtual() && $quote->getShippingAddress()) { $quote->getShippingAddress()->setCollectShippingRates(true); } if (!$this->zeroTotalValidator->isApplicable($payment->getMethodInstance(), $quote)) { throw new InvalidTransitionException('The requested Payment Method is not available.'); } $quote->setTotalsCollectedFlag(false)->collectTotals()->save(); return $quote->getPayment()->getId(); }
/** * Get store object * * @return \Magento\Store\Model\Store */ public function getStore() { if ($this->getInvoice()) { return $this->getInvoice()->getStore(); } return $this->_storeManager->getStore(); }
/** * @return void */ public function execute() { $currentActiveStore = $this->storeManager->getStore(); $storeCode = $this->_request->getParam(StoreResolver::PARAM_NAME, $this->storeCookieManager->getStoreCodeFromCookie()); try { $store = $this->storeRepository->getActiveStoreByCode($storeCode); } catch (StoreIsInactiveException $e) { $error = __('Requested store is inactive'); } catch (NoSuchEntityException $e) { $error = __('Requested store is not found'); } if (isset($error)) { $this->messageManager->addError($error); $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl()); return; } $defaultStoreView = $this->storeManager->getDefaultStoreView(); if ($defaultStoreView->getId() == $store->getId()) { $this->storeCookieManager->deleteStoreCookie($store); } else { $this->httpContext->setValue(Store::ENTITY, $store->getCode(), $defaultStoreView->getCode()); $this->storeCookieManager->setStoreCookie($store); } if ($store->isUseStoreInUrl()) { // Change store code in redirect url if (strpos($this->_redirect->getRedirectUrl(), $currentActiveStore->getBaseUrl()) !== false) { $this->getResponse()->setRedirect(str_replace($currentActiveStore->getBaseUrl(), $store->getBaseUrl(), $this->_redirect->getRedirectUrl())); } else { $this->getResponse()->setRedirect($store->getBaseUrl()); } } else { $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl()); } }
/** * Perform operations after collection load * * @param string $tableName * @param string $columnName * @return void */ protected function performAfterLoad($tableName, $columnName) { $items = $this->getColumnValues($columnName); if (count($items)) { $connection = $this->getConnection(); $select = $connection->select()->from(['cms_entity_store' => $this->getTable($tableName)])->where('cms_entity_store.' . $columnName . ' IN (?)', $items); $result = $connection->fetchPairs($select); if ($result) { foreach ($this as $item) { $entityId = $item->getData($columnName); if (!isset($result[$entityId])) { continue; } if ($result[$entityId] == 0) { $stores = $this->storeManager->getStores(false, true); $storeId = current($stores)->getId(); $storeCode = key($stores); } else { $storeId = $result[$item->getData($columnName)]; $storeCode = $this->storeManager->getStore($storeId)->getCode(); } $item->setData('_first_store_id', $storeId); $item->setData('store_code', $storeCode); $item->setData('store_id', [$result[$entityId]]); } } } }
/** * Render action. * * @param \Magento\Framework\DataObject $row * * @return string */ public function render(\Magento\Framework\DataObject $row) { $storeViewId = $this->getRequest()->getParam('store'); $banner = $this->bannerFactory->create()->setStoreViewId($storeViewId)->load($row->getId()); $srcImage = $this->storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA) . $this->subDir . '/' . $banner->getImage(); return '<image width="150" height="50" src ="' . $srcImage . '" alt="' . $banner->getImage() . '" >'; }