本文整理汇总了PHP中Magento\Catalog\Model\ResourceModel\Product\Collection::getEntity方法的典型用法代码示例。如果您正苦于以下问题:PHP Collection::getEntity方法的具体用法?PHP Collection::getEntity怎么用?PHP Collection::getEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Catalog\Model\ResourceModel\Product\Collection
的用法示例。
在下文中一共展示了Collection::getEntity方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getProductData
/**
* Separate query for product and order data
*
* @param array $productIds
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
*/
protected function getProductData(array $productIds)
{
$productConnection = $this->productResource->getConnection();
$productAttrName = $this->productResource->getAttribute('name');
$productAttrNameId = (int) $productAttrName->getAttributeId();
$productAttrPrice = $this->productResource->getAttribute('price');
$productAttrPriceId = (int) $productAttrPrice->getAttributeId();
$linkField = $this->productResource->getEntity()->getLinkField();
$select = clone $this->productResource->getSelect();
$select->reset();
$select->from(['main_table' => $this->getTable('catalog_product_entity')], ['main_table.entity_id', 'main_table.*'])->useStraightJoin(true)->joinInner(['product_name' => $productAttrName->getBackend()->getTable()], "product_name.{$linkField} = main_table.{$linkField}" . ' AND product_name.attribute_id = ' . $productAttrNameId . ' AND product_name.store_id = ' . \Magento\Store\Model\Store::DEFAULT_STORE_ID, ['name' => 'product_name.value'])->joinInner(['product_price' => $productAttrPrice->getBackend()->getTable()], "product_price.{$linkField} = main_table.{$linkField}" . " AND product_price.attribute_id = {$productAttrPriceId}", ['price' => new \Zend_Db_Expr('product_price.value')])->where("main_table.entity_id IN (?)", $productIds);
$productData = $productConnection->fetchAssoc($select);
return $productData;
}