Esempio n. 1
0
 /**
  * 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()->getId();
         $this->getSelect()->join(array('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() . ' AND product_name_table.entity_type_id=' . $entityTypeId, array());
         $this->_isProductNameJoined = true;
     }
     return $this;
 }
Esempio n. 2
0
 /**
  * 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();
         $entityMetadata = $this->getMetadataPool()->getMetadata(ProductInterface::class);
         $this->getSelect()->join(['product_name_table' => $attribute->getBackendTable()], 'product_name_table.' . $entityMetadata->getLinkField() . ' = main_table.product_id' . ' AND product_name_table.store_id = ' . $storeId . ' AND product_name_table.attribute_id = ' . $attribute->getId(), []);
         $this->_isProductNameJoined = true;
     }
     return $this;
 }