/** * Retrieve Catalog Entity Type Id * * @return int */ public function getEntityTypeId() { if ($this->_entityTypeId === null) { $this->_entityTypeId = $this->_configFactory->create()->getEntityTypeId(); } return $this->_entityTypeId; }
/** * Joins product name attribute value to use it in WHERE and ORDER clauses * * @return $this */ protected function _joinProductNameTable() { if (!$this->_isProductNameJoined) { $entityTypeId = $this->_catalogConfFactory->create()->getEntityTypeId(); /** @var \Magento\Catalog\Model\Entity\Attribute $attribute */ $attribute = $this->_catalogAttrFactory->create()->loadByCode($entityTypeId, 'name'); $storeId = $this->_storeManager->getStore(\Magento\Store\Model\Store::ADMIN_CODE)->getId(); $this->getSelect()->join(['product_name_table' => $attribute->getBackendTable()], 'product_name_table.entity_id=main_table.product_id' . ' AND product_name_table.store_id=' . $storeId . ' AND product_name_table.attribute_id=' . $attribute->getId(), []); $this->_isProductNameJoined = true; } return $this; }
/** * Retrieve resource model * * @return \Magento\Catalog\Model\ResourceModel\Config */ protected function _getResource() { return $this->_configFactory->create(); }