本文整理汇总了PHP中Mage_Eav_Model_Entity_Collection_Abstract::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Collection_Abstract::getData方法的具体用法?PHP Mage_Eav_Model_Entity_Collection_Abstract::getData怎么用?PHP Mage_Eav_Model_Entity_Collection_Abstract::getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Eav_Model_Entity_Collection_Abstract
的用法示例。
在下文中一共展示了Mage_Eav_Model_Entity_Collection_Abstract::getData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getProductCollection
protected function getProductCollection()
{
$typeFilter = $this->getData('type_filter');
$storeId = Mage::app()->getStore()->getId();
if ($typeFilter == 'bestseller') {
$products = Mage::getResourceModel('reports/product_collection')->addOrderedQty()->setStoreId($storeId)->addStoreFilter($storeId)->setOrder('ordered_qty', 'desc');
} else {
if ($typeFilter == 'halo_featured') {
$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToFilter('halo_featured', 1);
} else {
if ($typeFilter == 'most_viewed') {
$products = Mage::getResourceModel('reports/product_collection')->addOrderedQty()->setStoreId($storeId)->addStoreFilter($storeId)->addViewsCount();
} else {
if ($typeFilter == 'new_products') {
$todayStartOfDayDate = Mage::app()->getLocale()->date()->setTime('00:00:00')->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$todayEndOfDayDate = Mage::app()->getLocale()->date()->setTime('23:59:59')->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$products = Mage::getResourceModel('catalog/product_collection');
$products->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
$products->addStoreFilter()->addAttributeToFilter('news_from_date', array('or' => array(0 => array('date' => true, 'to' => $todayEndOfDayDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')->addAttributeToFilter('news_to_date', array('or' => array(0 => array('date' => true, 'from' => $todayStartOfDayDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')->addAttributeToFilter(array(array('attribute' => 'news_from_date', 'is' => new Zend_Db_Expr('not null')), array('attribute' => 'news_to_date', 'is' => new Zend_Db_Expr('not null'))))->addAttributeToSort('news_from_date', 'desc');
} else {
if ($typeFilter == 'sale_off') {
$todayStartOfDayDate = Mage::app()->getLocale()->date()->setTime('00:00:00')->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$todayEndOfDayDate = Mage::app()->getLocale()->date()->setTime('23:59:59')->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$products = Mage::getResourceModel('catalog/product_collection');
$products->setVisibility(Mage::getSingleton('catalog/product_visibility')->getVisibleInCatalogIds());
$products->addStoreFilter()->addAttributeToFilter('special_price', array('gt' => 0))->addAttributeToFilter('special_from_date', array('or' => array(0 => array('date' => true, 'to' => $todayEndOfDayDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')->addAttributeToFilter('special_to_date', array('or' => array(0 => array('date' => true, 'from' => $todayStartOfDayDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left')->addAttributeToFilter(array(array('attribute' => 'special_from_date', 'is' => new Zend_Db_Expr('not null')), array('attribute' => 'special_to_date', 'is' => new Zend_Db_Expr('not null'))));
} else {
$products = Mage::getModel('catalog/product')->getCollection();
}
}
}
}
}
if ($category = $this->getData('category')) {
$products->addCategoryFilter(Mage::getModel('catalog/category')->load(str_replace('category/', '', $category)));
}
$this->_addProductAttributesAndPrices($products);
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
/* For category page */
if (Mage::registry('current_category')) {
$products->addUrlRewrite(Mage::registry('current_category')->getId());
}
$pageSize = $this->getData('limit_count');
if (isset($pageSize)) {
$products->setPageSize($pageSize);
}
$products->setCurPage($this->getRequest()->getParam('p', 1));
$this->setCollection($products);
$this->setSize(count($this->_productCollection->getData()));
return $this->_productCollection;
}
示例2: getProductCollection
protected function getProductCollection()
{
$products = Mage::getModel('catalog/product')->getCollection();
$config1 = $this->getData('category');
if ($config1) {
$cat = Mage::getModel('catalog/category')->load(str_replace('category/', '', $config1));
$products->addCategoryFilter($cat);
}
$attrSetName = $this->getData('attribute_set');
if ($attrSetName) {
$attributeSetId = Mage::getModel('eav/entity_attribute_set')->load($attrSetName, 'attribute_set_name')->getAttributeSetId();
$products->addAttributeToFilter('attribute_set_id', $attributeSetId);
}
$products->addAttributeToSelect('*');
$products->addMinimalPrice()->addFinalPrice()->addTaxPercents();
Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
$asc = $this->getRequest()->getParam('dir');
$od = $this->getRequest()->getParam('order');
if (isset($od) && isset($asc)) {
$orders[0] = $od;
$orders[1] = $asc;
} else {
$config2 = $this->getData('order_by');
if (isset($config2)) {
//echo 'bb';
$orders = explode(' ', $config2);
}
}
$store_id = Mage::app()->getStore()->getId();
$field_condition = $this->getData('if');
$conditionIf = array();
if ($field_condition != '' && $field_condition != '#') {
$field_condition = strtolower($field_condition);
$field_condition = $this->standarStr($field_condition);
$array_field = $this->toArrExpression($field_condition);
$field_widget = '(';
foreach ($array_field as $a) {
$tmp = array();
$i = 0;
//check and process if exists attributes like a,ab,abc
foreach ($array_field as $a1) {
if ($a != $a1) {
if (strstr($a1->field, $a->field)) {
$field_condition = str_replace($a1->field, $this->encrypt . $i, $field_condition);
$tmp[] = $a1->field;
$i++;
}
}
}
$field_condition = str_replace($a->field, $a->field . '_table.value', $field_condition);
foreach ($tmp as $key => $t) {
$field_condition = str_replace($this->encrypt . $key, $t, $field_condition);
}
$field_widget .= '"' . $a->field . '",';
}
$field_widget = substr($field_widget, 0, strlen($field_widget) - 1) . ')';
$dem = 0;
$products->distinct(true);
$tableEntity = '`e`';
//Join if use catalog flat
if (Mage::helper('catalog/product_flat')->isEnabled()) {
$products->getSelect()->join(array('entity_table' => Mage::getSingleton('core/resource')->getTableName('catalog_product_entity')), 'e.entity_id=entity_table.entity_id', array());
$tableEntity = 'entity_table';
}
foreach ($array_field as $a) {
$field = $a->field;
$eavAttribute = Mage::getResourceSingleton('catalog/product')->getAttribute($field);
//->getData('frontend_input');
$backendType = $eavAttribute->getBackend()->getTable();
$frontendInput = $eavAttribute->getData('frontend_input');
if ($dem == count($array_field) - 1) {
if ($frontendInput == 'select') {
$products->getSelect()->join(array('cat_table' => $backendType), 'cat_table.entity_id=' . $tableEntity . '.entity_id
AND cat_table.store_id in (0,' . $store_id . ')
AND cat_table.attribute_id=' . $eavAttribute->getData('attribute_id') . '
AND cat_table.entity_type_id=' . $tableEntity . '.entity_type_id
INNER JOIN eav_attribute_option_value as ' . $field . '_table
ON cat_table.value=' . $field . '_table.option_id
AND (' . $field_condition . ')', array());
} else {
$products->getSelect()->join(array($field . '_table' => $backendType), $field . '_table.entity_id=' . $tableEntity . '.entity_id
AND ' . $field . '_table.store_id in (0,' . $store_id . ')
AND ' . $field . '_table.attribute_id=' . $eavAttribute->getData('attribute_id') . '
AND ' . $field . '_table.entity_type_id=' . $tableEntity . '.entity_type_id and (' . $field_condition . ')', array());
}
} else {
if ($frontendInput == 'select') {
$products->getSelect()->join(array('cat_table' => $backendType), 'cat_table.entity_id=' . $tableEntity . '.entity_id
AND cat_table.store_id in in (0,' . $store_id . ')
AND cat_table.attribute_id=' . $eavAttribute->getData('attribute_id') . '
AND cat_table.entity_type_id=' . $tableEntity . '.entity_type_id
INNER JOIN eav_attribute_option_value as ' . $field . '_table
ON cat_table.value=' . $field . '_table.option_id', array());
} else {
$products->getSelect()->join(array($field . '_table' => $backendType), $field . '_table.entity_id=' . $tableEntity . '.entity_id
AND ' . $field . '_table.store_id in in (0,' . $store_id . ')
AND ' . $field . '_table.attribute_id=' . $eavAttribute->getData('attribute_id') . '
AND ' . $field . '_table.entity_type_id=' . $tableEntity . '.entity_type_id', array());
}
//.........这里部分代码省略.........