本文整理汇总了PHP中Mage_Catalog_Model_Resource_Product_Collection::_loadAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Resource_Product_Collection::_loadAttributes方法的具体用法?PHP Mage_Catalog_Model_Resource_Product_Collection::_loadAttributes怎么用?PHP Mage_Catalog_Model_Resource_Product_Collection::_loadAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Resource_Product_Collection
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Resource_Product_Collection::_loadAttributes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _loadAttributes
/**
* Load attributes from MongoDB after main data are loaded from MySQL
*
* @param bool $printQuery If the SQL query should be printed or not
* @param bool $logQuery If the SQL query should be logegd or not
*
* @return Smile_MongoCore_Model_Resource_Override_Catalog_Product_Collection Self reference
*/
public function _loadAttributes($printQuery = false, $logQuery = false)
{
parent::_loadAttributes($printQuery, $logQuery);
if (!empty($this->_itemsById)) {
$storeFilter = array_unique(array('attr_' . $this->getDefaultStoreId(), 'attr_' . $this->getStoreId()));
if (is_null($this->_loadedDocuments)) {
$documentIds = $this->getLoadedIds();
foreach ($documentIds as $key => $value) {
$documentIds[$key] = new MongoInt32($value);
}
$idFilter = array('_id' => array('$in' => $documentIds));
$cursor = $this->_getDocumentCollection()->find($idFilter, $storeFilter);
$this->_loadedDocuments = array();
while ($cursor->hasNext()) {
$document = $cursor->getNext();
$this->_loadedDocuments[] = $document;
}
}
foreach ($this->_loadedDocuments as $document) {
$loadedData = array();
//$document = $cursor->getNext();
foreach ($storeFilter as $storeId) {
if (isset($document[$storeId])) {
if (!is_array($document[$storeId])) {
$document[$storeId] = array($storeId => $document[$storeId]);
}
foreach ($document[$storeId] as $attributeCode => $attributeValue) {
$loadedData[$attributeCode] = $attributeValue;
}
}
}
$this->_items[$document['_id']]->addData($loadedData);
}
}
return $this;
}