本文整理汇总了PHP中Mage_Catalog_Model_Resource_Product_Collection::getItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Resource_Product_Collection::getItems方法的具体用法?PHP Mage_Catalog_Model_Resource_Product_Collection::getItems怎么用?PHP Mage_Catalog_Model_Resource_Product_Collection::getItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Resource_Product_Collection
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Resource_Product_Collection::getItems方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: appendSummary
/**
* Append review summary to product collection
*
* @param Mage_Catalog_Model_Resource_Product_Collection $collection
* @return Mage_Review_Model_Review
*/
public function appendSummary($collection)
{
$entityIds = array();
foreach ($collection->getItems() as $_itemId => $_item) {
$entityIds[] = $_item->getEntityId();
}
if (sizeof($entityIds) == 0) {
return $this;
}
$summaryData = Mage::getResourceModel('Mage_Review_Model_Resource_Review_Summary_Collection')->addEntityFilter($entityIds)->addStoreFilter(Mage::app()->getStore()->getId())->load();
foreach ($collection->getItems() as $_item) {
foreach ($summaryData as $_summary) {
if ($_summary->getEntityPkValue() == $_item->getEntityId()) {
$_item->setRatingSummary($_summary);
}
}
}
return $this;
}
示例2: addPriceIndexToCollection
/**
* Add bundle price range index to Product collection
*
* @param Mage_Catalog_Model_Resource_Product_Collection $collection
* @return Mage_Bundle_Model_Price_Index
*/
public function addPriceIndexToCollection($collection)
{
$productObjects = array();
$productIds = array();
foreach ($collection->getItems() as $product) {
/* @var $product Mage_Catalog_Model_Product */
if ($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_BUNDLE) {
$productIds[] = $product->getEntityId();
$productObjects[$product->getEntityId()] = $product;
}
}
$websiteId = Mage::app()->getStore($collection->getStoreId())->getWebsiteId();
$groupId = Mage::getSingleton('Mage_Customer_Model_Session')->getCustomerGroupId();
$addOptionsToResult = false;
$prices = $this->_getResource()->loadPriceIndex($productIds, $websiteId, $groupId);
foreach ($productIds as $productId) {
if (isset($prices[$productId])) {
$productObjects[$productId]->setData('_price_index', true)->setData('_price_index_min_price', $prices[$productId]['min_price'])->setData('_price_index_max_price', $prices[$productId]['max_price']);
} else {
$addOptionsToResult = true;
}
}
if ($addOptionsToResult) {
$collection->addOptionsToResult();
}
return $this;
}
示例3: _processProductCollection
/**
* Process all of the products within a given store.
*
* @param Mage_Catalog_Model_Resource_Product_Collection $products products for a specific store
* @param EbayEnterprise_Catalog_Model_Pim_Product_Collection $pimProducts collection of PIM Product instances
* @param string $key
* @param array $productIds
* @return EbayEnterprise_Catalog_Model_Pim_Product_Collection $pimProducts collection of PIM Product instances
*/
protected function _processProductCollection(Mage_Catalog_Model_Resource_Product_Collection $products, EbayEnterprise_Catalog_Model_Pim_Product_Collection $pimProducts, array &$productIds = null)
{
$excludedProductIds = array();
$currentStoreId = $products->getStoreId();
$config = Mage::helper('eb2ccore')->getConfigModel($currentStoreId);
$clientId = $config->clientId;
$catalogId = $config->catalogId;
foreach ($products->getItems() as $product) {
$product->setStoreId($currentStoreId);
$pimProduct = $pimProducts->getItemForProduct($product);
if (!$pimProduct) {
$pimProduct = Mage::getModel('ebayenterprise_catalog/pim_product', array('client_id' => $clientId, 'catalog_id' => $catalogId, 'sku' => $product->getSku()));
$pimProducts->addItem($pimProduct);
}
try {
$pimProduct->loadPimAttributesByProduct($product, $this->_doc, $this->_getFeedConfig(), $this->_getFeedAttributes($currentStoreId));
} catch (EbayEnterprise_Catalog_Model_Pim_Product_Validation_Exception $e) {
$logData = ['sku' => $pimProduct->getSku()];
$logMessage = 'Product "{sku}" excluded from export.';
$this->_logger->warning($logMessage, $this->_context->getMetaData(__CLASS__, $logData));
$this->_logger->logException($e, $this->_context->getMetaData(__CLASS__, [], $e));
$excludedProductIds[] = $product->getId();
$pimProducts->deleteItem($pimProduct);
}
}
if ($productIds) {
$productIds = array_diff($productIds, $excludedProductIds);
}
return $pimProducts;
}