当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Eav_Model_Entity_Collection_Abstract::addAttributeToSelect方法代码示例

本文整理汇总了PHP中Mage_Eav_Model_Entity_Collection_Abstract::addAttributeToSelect方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Eav_Model_Entity_Collection_Abstract::addAttributeToSelect方法的具体用法?PHP Mage_Eav_Model_Entity_Collection_Abstract::addAttributeToSelect怎么用?PHP Mage_Eav_Model_Entity_Collection_Abstract::addAttributeToSelect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Eav_Model_Entity_Collection_Abstract的用法示例。


在下文中一共展示了Mage_Eav_Model_Entity_Collection_Abstract::addAttributeToSelect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _getGiveawayCollection

 /**
  * Retrieve loaded Giveaway Product Collection
  *
  * @return Mage_Eav_Model_Entity_Collection_Abstract
  */
 protected function _getGiveawayCollection()
 {
     if (is_null($this->_productCollection)) {
         $oProduct = Mage::getModel('catalog/product');
         /* @var $oCollection Mage_Catalog_Model_Resource_Product_Collection */
         $this->_productCollection = $oProduct->getResourceCollection();
         $oSitewardsGiveawayHelper = Mage::helper('sitewards_giveaway');
         $sGiveawayAttributeCode = $oSitewardsGiveawayHelper->getGiveawayIdentifierName();
         $this->_productCollection->addAttributeToFilter($sGiveawayAttributeCode, true);
         $this->_productCollection->addAttributeToSelect('*');
     }
     return $this->_productCollection;
 }
开发者ID:sitewards,项目名称:giveaway,代码行数:18,代码来源:Giveaway.php

示例2: getLoadedProductCollectionpro

 /**
  * Retrieve loaded category collection
  *
  * @return Mage_Eav_Model_Entity_Collection_Abstract
  */
 public function getLoadedProductCollectionpro($id)
 {
     // benchmarking
     $memory = memory_get_usage();
     $time = microtime();
     if (is_null($this->_productCollection)) {
         $layer = $this->getLayer();
         if ($this->getShowRootCategory()) {
             $this->setCategoryId(Mage::app()->getStore()->getRootCategoryId());
         }
         // if this is a product view page
         if (Mage::registry('product')) {
             // get collection of categories this product is associated with
             $categories = Mage::registry('product')->getCategoryCollection()->setPage(1, 1)->load();
             // if the product is associated with any category
             if ($categories->count()) {
                 // show products from this category
                 $this->setCategoryId(current($categories->getIterator()));
             }
         }
         $origCategory = null;
         if ($this->getCategoryId()) {
             $category = Mage::getModel('catalog/category')->load($this->getCategoryId());
             if ($category->getId()) {
                 $origCategory = $layer->getCurrentCategory();
                 $layer->setCurrentCategory($category);
                 $this->addModelTags($category);
             }
         }
         /* @var $layer Mage_Catalog_Model_Layer */
         /* @var $layer Mage_Catalog_Model_Layer */
         //$this->_productCollection = $layer->getProductCollection();
         /** @var $collection Mage_Catalog_Model_Resource_Product_Collection */
         $category = Mage::getModel('catalog/category')->load($this->_theCat);
         $this->_productCollection = Mage::getResourceModel('catalog/product_collection');
         // join sales order items column and count sold products
         $expression = new Zend_Db_Expr("SUM(oi.qty_ordered)");
         $condition = new Zend_Db_Expr("e.entity_id = oi.product_id AND oi.parent_item_id IS NULL");
         $this->_productCollection->addAttributeToSelect('*')->getSelect()->join(array('oi' => $this->_productCollection->getTable('sales/order_item')), $condition, array('sales_count' => $expression))->group('e.entity_id');
         //->order('sales_count' . ' ' . 'desc');
         $this->_productCollection->addFieldToFilter('status', '1');
         //join brand
         if ($this->getRequest()->getParam('brands_ids') != null and $this->getRequest()->getParam('brands_ids') != 0) {
             $brand_id = $this->getRequest()->getParam('brands_ids');
             $condition = new Zend_Db_Expr("br.option_id = {$brand_id} AND br.product_ids = e.entity_id");
             $this->_productCollection->getSelect()->join(array('br' => $this->_productCollection->getTable('shopbybrand/brand')), $condition, array('brand_id' => 'br.option_id'));
         }
         // join category
         $condition = new Zend_Db_Expr("e.entity_id = ccp.product_id");
         $condition2 = new Zend_Db_Expr("c.entity_id = ccp.category_id");
         $this->_productCollection->getSelect()->join(array('ccp' => $this->_productCollection->getTable('catalog/category_product')), $condition, array())->join(array('c' => $this->_productCollection->getTable('catalog/category')), $condition2, array('cat_id' => 'c.entity_id'));
         $condition = new Zend_Db_Expr("c.entity_id = cv.entity_id AND ea.attribute_id = cv.attribute_id");
         // cutting corners here by hardcoding 3 as Category Entiry_type_id
         $condition2 = new Zend_Db_Expr("ea.entity_type_id = 3 AND ea.attribute_code = 'name'");
         $this->_productCollection->getSelect()->join(array('ea' => $this->_productCollection->getTable('eav/attribute')), $condition2, array())->join(array('cv' => $this->_productCollection->getTable('catalog/category') . '_varchar'), $condition, array('cat_name' => 'cv.value'));
         $id = $this->getRequest()->getParam('id');
         $this->_productCollection->getSelect()->where('c.entity_id = ?', $id)->limit(20);
     }
     return $this->_productCollection;
 }
开发者ID:santhosh400,项目名称:ecart,代码行数:65,代码来源:Ajaxbestseller.php

示例3: _prepareEntityCollection

 /**
  * Apply filter to collection and add not skipped attributes to select.
  *
  * @param Mage_Eav_Model_Entity_Collection_Abstract $collection
  * @return Mage_Eav_Model_Entity_Collection_Abstract
  */
 protected function _prepareEntityCollection(Mage_Eav_Model_Entity_Collection_Abstract $collection)
 {
     if (!isset($this->_parameters[Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP]) || !is_array($this->_parameters[Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP])) {
         $exportFilter = array();
     } else {
         $exportFilter = $this->_parameters[Mage_ImportExport_Model_Export::FILTER_ELEMENT_GROUP];
     }
     $exportAttrCodes = $this->_getExportAttrCodes();
     foreach ($this->filterAttributeCollection($this->getAttributeCollection()) as $attribute) {
         $attrCode = $attribute->getAttributeCode();
         // filter applying
         if (isset($exportFilter[$attrCode])) {
             $attrFilterType = Mage_ImportExport_Model_Export::getAttributeFilterType($attribute);
             if ($attrCode == 'sku') {
                 $collection->addAttributeToFilter($attrCode, array('in' => $exportFilter[$attrCode]));
             } elseif (Mage_ImportExport_Model_Export::FILTER_TYPE_SELECT == $attrFilterType) {
                 if (is_scalar($exportFilter[$attrCode]) && trim($exportFilter[$attrCode])) {
                     $collection->addAttributeToFilter($attrCode, array('eq' => $exportFilter[$attrCode]));
                 }
             } elseif (Mage_ImportExport_Model_Export::FILTER_TYPE_INPUT == $attrFilterType) {
                 if (is_scalar($exportFilter[$attrCode]) && trim($exportFilter[$attrCode])) {
                     $collection->addAttributeToFilter($attrCode, array('like' => "%{$exportFilter[$attrCode]}%"));
                 }
             } elseif (Mage_ImportExport_Model_Export::FILTER_TYPE_DATE == $attrFilterType) {
                 if (is_array($exportFilter[$attrCode]) && count($exportFilter[$attrCode]) == 2) {
                     $from = array_shift($exportFilter[$attrCode]);
                     $to = array_shift($exportFilter[$attrCode]);
                     if (is_scalar($from) && !empty($from)) {
                         $date = Mage::app()->getLocale()->date($from, null, null, false)->toString('MM/dd/YYYY');
                         $collection->addAttributeToFilter($attrCode, array('from' => $date, 'date' => true));
                     }
                     if (is_scalar($to) && !empty($to)) {
                         $date = Mage::app()->getLocale()->date($to, null, null, false)->toString('MM/dd/YYYY');
                         $collection->addAttributeToFilter($attrCode, array('to' => $date, 'date' => true));
                     }
                 }
             } elseif (Mage_ImportExport_Model_Export::FILTER_TYPE_NUMBER == $attrFilterType) {
                 if (is_array($exportFilter[$attrCode]) && count($exportFilter[$attrCode]) == 2) {
                     $from = array_shift($exportFilter[$attrCode]);
                     $to = array_shift($exportFilter[$attrCode]);
                     if (is_numeric($from)) {
                         $collection->addAttributeToFilter($attrCode, array('from' => $from));
                     }
                     if (is_numeric($to)) {
                         $collection->addAttributeToFilter($attrCode, array('to' => $to));
                     }
                 }
             }
         }
         if (in_array($attrCode, $exportAttrCodes)) {
             $collection->addAttributeToSelect($attrCode);
         }
     }
     return $collection;
 }
开发者ID:korbax,项目名称:Magento-Import-Export,代码行数:61,代码来源:export_product.php

示例4: _prepareCollection

 /**
  * Add image attribute and apply sort fields to product collection
  *
  * @param Mage_Eav_Model_Entity_Collection_Abstract $collection
  * @return Mage_XmlConnect_Block_Catalog_Product_List
  */
 protected function _prepareCollection($collection)
 {
     /**
      * Apply sort params
      */
     $request = $this->getRequest();
     $isOrderValueExist = false;
     foreach ($request->getParams() as $key => $value) {
         if (0 === strpos($key, parent::REQUEST_SORT_ORDER_PARAM_PREFIX)) {
             $key = str_replace(parent::REQUEST_SORT_ORDER_PARAM_PREFIX, '', $key);
             if ($value != 'desc') {
                 $value = 'asc';
             }
             if ($key == 'relevance') {
                 $collection->getSelect()->order("relevance {$value}");
             } else {
                 $collection->addAttributeToSort($key, $value);
             }
             $isOrderValueExist = true;
         }
     }
     if (!$isOrderValueExist && $collection instanceof Mage_CatalogSearch_Model_Resource_Fulltext_Collection) {
         $collection->getSelect()->order("relevance desc");
     }
     $collection->addAttributeToSelect(array('image', 'name', 'description'));
     return $this;
 }
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:33,代码来源:List.php

示例5: _prepareCollection

 /**
  * Add image attribute and apply sort fields to product collection
  *
  * @param Mage_Eav_Model_Entity_Collection_Abstract $collection
  * @return Mage_XmlConnect_Block_Catalog_Product_List
  */
 protected function _prepareCollection($collection)
 {
     /**
      * Apply sort params
      */
     $reguest = $this->getRequest();
     foreach ($reguest->getParams() as $key => $value) {
         if (0 === strpos($key, parent::REQUEST_SORT_ORDER_PARAM_REFIX)) {
             $key = str_replace(parent::REQUEST_SORT_ORDER_PARAM_REFIX, '', $key);
             if ($value != 'desc') {
                 $value = 'asc';
             }
             $collection->addAttributeToSort($key, $value);
         }
     }
     $collection->addAttributeToSelect(array('image', 'name', 'description'));
     return $this;
 }
开发者ID:hazaeluz,项目名称:magento_connect,代码行数:24,代码来源:List.php


注:本文中的Mage_Eav_Model_Entity_Collection_Abstract::addAttributeToSelect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。