/** * Return entities where attribute value is * * @param array|int $entityIdsFilter * @param \Magento\Eav\Model\Entity\Attribute $attribute * @param mixed $expectedValue * @return array */ public function findWhereAttributeIs($entityIdsFilter, $attribute, $expectedValue) { $bind = array('attribute_id' => $attribute->getId(), 'value' => $expectedValue); $select = $this->_getReadAdapter()->select()->from($attribute->getBackend()->getTable(), array('entity_id'))->where('attribute_id = :attribute_id')->where('value = :value')->where('entity_id IN(?)', $entityIdsFilter); return $this->_getReadAdapter()->fetchCol($select, $bind); }
/** * Return entities where attribute value is * * @param array|int $entityIdsFilter * @param \Magento\Eav\Model\Entity\Attribute $attribute * @param mixed $expectedValue * @return array */ public function findWhereAttributeIs($entityIdsFilter, $attribute, $expectedValue) { $linkField = $this->getLinkField(); $bind = ['attribute_id' => $attribute->getId(), 'value' => $expectedValue]; $selectEntities = $this->getConnection()->select()->from(['ce' => $this->getTable('catalog_category_entity')], ['entity_id'])->joinLeft(['ci' => $attribute->getBackend()->getTable()], "ci.{$linkField} = ce.{$linkField} AND attribute_id = :attribute_id", ['value'])->where('ci.value = :value')->where('ce.entity_id IN (?)', $entityIdsFilter); return $this->getConnection()->fetchCol($selectEntities, $bind); }