• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Mage_Catalog_Model_Layer_Filter_Attribute类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Mage_Catalog_Model_Layer_Filter_Attribute的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Layer_Filter_Attribute类的具体用法?PHP Mage_Catalog_Model_Layer_Filter_Attribute怎么用?PHP Mage_Catalog_Model_Layer_Filter_Attribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: getCount

 /**
  * Retrieve array with products counts per attribute option
  *
  * @param Mage_Catalog_Model_Layer_Filter_Attribute $filter Filter
  * @return array
  */
 public function getCount($filter)
 {
     // clone select from collection with filters
     $select = clone $filter->getLayer()->getProductCollection()->getSelect();
     // reset columns, order and limitation conditions
     $select->reset(Zend_Db_Select::COLUMNS);
     $select->reset(Zend_Db_Select::ORDER);
     $select->reset(Zend_Db_Select::LIMIT_COUNT);
     $select->reset(Zend_Db_Select::LIMIT_OFFSET);
     $select->reset(Zend_Db_Select::GROUP);
     $connection = $this->_getReadAdapter();
     $attribute = $filter->getAttributeModel();
     $tableAlias = sprintf('%s_idx', $attribute->getAttributeCode());
     $conditions = array("{$tableAlias}.entity_id = e.entity_id", $connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()), $connection->quoteInto("{$tableAlias}.store_id = ?", $filter->getStoreId()));
     $conditions = join(' AND ', $conditions);
     $fromParts = $select->getPart(Zend_Db_Select::FROM);
     if (isset($fromParts[$tableAlias])) {
         $conditionArray = explode(' AND ', $fromParts[$tableAlias]['joinCondition']);
         unset($conditionArray[count($conditionArray) - 1]);
         $conditions = implode(' AND ', $conditionArray);
         unset($fromParts[$tableAlias]);
         $select->setPart(Zend_Db_Select::FROM, $fromParts);
     }
     $select->join(array($tableAlias => $this->getMainTable()), $conditions, array('value', 'count' => new Zend_Db_Expr("COUNT(distinct {$tableAlias}.entity_id)")))->group("{$tableAlias}.value");
     return $connection->fetchPairs($select);
 }
开发者ID:kumardhirendra1,项目名称:Magento_Filter,代码行数:32,代码来源:Attribute.php


示例2: getCount

 /**
  * Retrieve array with products counts per attribute option
  *
  * @param Mage_Catalog_Model_Layer_Filter_Attribute $filter
  * @return array
  */
 public function getCount($filter)
 {
     // clone select from collection with filters
     $select = clone $filter->getLayer()->getProductCollection()->getSelect();
     // reset columns, order and limitation conditions
     $select->reset(Zend_Db_Select::COLUMNS);
     $select->reset(Zend_Db_Select::ORDER);
     $select->reset(Zend_Db_Select::LIMIT_COUNT);
     $select->reset(Zend_Db_Select::LIMIT_OFFSET);
     // Removed below as this was causing wrong counts
     // Not sure if this will break other functionality
     // $select->reset(Zend_Db_Select::WHERE);
     $connection = $this->_getReadAdapter();
     $attribute = $filter->getAttributeModel();
     $tableAlias = sprintf('%s_idx', $attribute->getAttributeCode());
     $conditions = array("{$tableAlias}.entity_id = e.entity_id", $connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()), $connection->quoteInto("{$tableAlias}.store_id = ?", $filter->getStoreId()));
     $from = $select->getPart('from');
     if (array_key_exists($tableAlias, $from)) {
         $select->reset(Zend_Db_Select::FROM);
         unset($from[$tableAlias]);
         $select->setPart(Zend_Db_Select::FROM, $from);
     }
     $select->join(array($tableAlias => $this->getMainTable()), join(' AND ', $conditions), array('value', 'count' => new Zend_Db_Expr("COUNT({$tableAlias}.entity_id)")))->group("{$tableAlias}.value");
     return $connection->fetchPairs($select);
 }
开发者ID:sivabupathy,项目名称:edge-magento-module-catalogfilter,代码行数:31,代码来源:Attribute.php


示例3: getCount

 /**
  * Retrieve array with products counts per attribute option
  *
  * @param Mage_Catalog_Model_Layer_Filter_Attribute $filter The current catalog filter
  *
  * @return array
  */
 public function getCount($filter)
 {
     $catalogResource = Mage::getResourceModel("catalog/product");
     $attribute = $filter->getAttributeModel();
     /**
      * For legacy SQL based attributes, Magento based the query on "catalog/product_index_eav", let him do
      */
     if (in_array($attribute->getAttributeCode(), $catalogResource->getSqlAttributesCodes())) {
         return parent::getCount($filter);
     }
     /**
      * Since we have MongoDB, nothing is stored on eav index table for other attributes
      * Let's build the query with an aggregation
      *
      * @see http://docs.mongodb.org/manual/reference/operator/aggregation/
      */
     $collection = clone $filter->getLayer()->getProductCollection();
     /** @var Smile_MongoCore_Model_Resource_Connection_Adapter $adapter */
     $adapter = Mage::getSingleton('mongocore/resource_connection_adapter');
     $queryBuilder = $adapter->getQueryBuilder();
     $collectionName = Mage::getResourceModel('catalog/product')->getEntityTable();
     $docCollection = $adapter->getCollection($collectionName);
     /** Build a condition to have all products which have the specified attribute as "notnull" AND not an empty string */
     $scopedAttributeName = 'attr_' . $filter->getStoreId() . '.' . $attribute->getAttributeCode();
     $globalAttributeName = 'attr_' . Mage_Core_Model_App::ADMIN_STORE_ID . '.' . $attribute->getAttributeCode();
     $filterCascade = array('$or' => array(array('$and' => array(array($scopedAttributeName => array('$exists' => 1)))), array('$and' => array(array($scopedAttributeName => array('$exists' => 0)), array($globalAttributeName => array('$exists' => 1))))));
     $documentFilter = $filterCascade;
     $documentFilter['$or'][0]['$and'][] = array($scopedAttributeName => array('$' . "ne" => 'null'));
     $documentFilter['$or'][0]['$and'][] = array($scopedAttributeName => array('$' . "ne" => ''));
     $documentFilter['$or'][1]['$and'][] = array($globalAttributeName => array('$' . "ne" => 'null'));
     $documentFilter['$or'][1]['$and'][] = array($globalAttributeName => array('$' . "ne" => ''));
     /** First, the matching, current product ids, and our calculated document filter **/
     $match = array('$and' => array($queryBuilder->getIdsFilter($collection->getAllIds()), $documentFilter));
     /** And then, the grouping, by attribute values, and calculating a sum */
     $group = array("_id" => array("{$scopedAttributeName}" => '$' . $scopedAttributeName, "{$globalAttributeName}" => '$' . $globalAttributeName), "total" => array('$sum' => 1));
     /** Building aggregation pipeline based on match and group previously built */
     $pipeline = array(array('$match' => $match), array('$group' => $group));
     $aggregation = $docCollection->aggregate($pipeline);
     /**
      * Now parse the aggregation result
      * Goal is to obtain an array like this :
      *
      * <attribute option id> => <total number of occurences>
      */
     $aggregationResult = array();
     if ($aggregation['ok'] == 1 && isset($aggregation["result"])) {
         foreach ($aggregation["result"] as $aggregate) {
             if (isset($aggregate["_id"]) && isset($aggregate['total'])) {
                 $option = null;
                 foreach ($aggregate["_id"] as $value) {
                     $option = $value;
                 }
                 if (!is_null($option)) {
                     $aggregationResult[$option] = $aggregate['total'];
                 }
             }
         }
     }
     return ksort($aggregationResult);
 }
开发者ID:keyur-iksula,项目名称:mongogento,代码行数:67,代码来源:Attribute.php


示例4: getCount

 /**
  * @param Mage_Catalog_Model_Layer_Filter_Attribute $filter
  * @return array
  */
 public function getCount($filter)
 {
     // clone select from collection with filters
     $select = clone $filter->getLayer()->getProductCollection()->getSelect();
     // reset columns, order and limitation conditions
     $select->reset(Zend_Db_Select::COLUMNS);
     $select->reset(Zend_Db_Select::ORDER);
     $select->reset(Zend_Db_Select::LIMIT_COUNT);
     $select->reset(Zend_Db_Select::LIMIT_OFFSET);
     // Redefining join type to allow multiple attribute values on currently filtered attribute
     $fromPart = $select->getPart(Zend_Db_Select::FROM);
     foreach ($fromPart as $key => &$part) {
         if ($key == $filter->getAttributeModel()->getAttributeCode() . '_idx') {
             $part['joinType'] = Zend_Db_Select::LEFT_JOIN;
         }
     }
     unset($part);
     $select->reset(Zend_Db_Select::FROM);
     $select->setPart(Zend_Db_Select::FROM, $fromPart);
     $connection = $this->_getReadAdapter();
     $attribute = $filter->getAttributeModel();
     $tableAlias = sprintf('%s_index', $attribute->getAttributeCode());
     $conditions = array("{$tableAlias}.entity_id = e.entity_id", $connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()), $connection->quoteInto("{$tableAlias}.store_id = ?", $filter->getStoreId()));
     $select->join(array($tableAlias => $this->getMainTable()), join(' AND ', $conditions), array('value', 'count' => new Zend_Db_Expr("COUNT(DISTINCT {$tableAlias}.entity_id)")))->group("{$tableAlias}.value");
     return $connection->fetchPairs($select);
 }
开发者ID:technomagegithub,项目名称:magento,代码行数:30,代码来源:Attribute.php


示例5: getCount

 /**
  * Retrieve array with products counts per attribute option
  *
  * @param Mage_Catalog_Model_Layer_Filter_Attribute $filter
  * @return array
  */
 public function getCount($filter)
 {
     /** @var $layer EcommerceTeam_Sln_Model_Layer */
     $layer = $filter->getLayer();
     $connection = $this->_getReadAdapter();
     $select = $layer->getSelectWithoutFilter('cat');
     if (!$select) {
         $select = clone $filter->getLayer()->getProductCollection()->getSelect();
     }
     $where = array();
     $catIds = array();
     if ($this->_categories) {
         $catIds = $this->_categories;
     } else {
         $categories = $layer->getCurrentCategory()->getChildrenCategories();
         foreach ($categories as $category) {
             $catIds[] = $category->getEntityId();
         }
     }
     $select->reset(Zend_Db_Select::COLUMNS);
     $select->reset(Zend_Db_Select::ORDER);
     $select->reset(Zend_Db_Select::LIMIT_COUNT);
     $select->reset(Zend_Db_Select::LIMIT_OFFSET);
     $select->reset(Zend_Db_Select::GROUP);
     $select->join(array('child_cat_index' => Mage::getSingleton('core/resource')->getTableName('catalog/category_product_index')), 'child_cat_index.category_id IN (' . implode(',', $catIds) . ') AND child_cat_index.product_id = e.entity_id', array('value' => 'category_id'));
     $fields = array('count' => 'COUNT(DISTINCT child_cat_index.product_id)');
     $select->columns($fields);
     $select->group('child_cat_index.category_id');
     return $connection->fetchPairs($select);
 }
开发者ID:xiaoguizhidao,项目名称:devfashion,代码行数:36,代码来源:Category.php


示例6: getCount

 /**
  * Retrieve array with products counts per attribute option
  *
  * @param Mage_Catalog_Model_Layer_Filter_Attribute $filter
  * @return array
  */
 public function getCount($filter)
 {
     $categories = $filter->getLayer()->getCurrentCategory()->getAllChildren(true);
     $connection = $this->_getReadAdapter();
     $base_select = $filter->getLayer()->getBaseSelect();
     if (isset($base_select['cat'])) {
         $select = $base_select['cat'];
     } else {
         $select = clone $filter->getLayer()->getProductCollection()->getSelect();
     }
     $where = array();
     $catIds = array();
     foreach ($categories as $category) {
         $catIds[] = $category;
     }
     $select->reset(Zend_Db_Select::COLUMNS);
     $select->reset(Zend_Db_Select::ORDER);
     $select->reset(Zend_Db_Select::LIMIT_COUNT);
     $select->reset(Zend_Db_Select::LIMIT_OFFSET);
     $select->reset(Zend_Db_Select::GROUP);
     $select->join(array('child_cat_index' => Mage::getSingleton('core/resource')->getTableName('catalog/category_product_index')), 'child_cat_index.category_id IN (' . implode(',', $catIds) . ') AND child_cat_index.product_id = e.entity_id', array('value' => 'category_id'));
     $fields = array('count' => 'COUNT(DISTINCT child_cat_index.product_id)');
     $select->columns($fields);
     $select->group('child_cat_index.category_id');
     return $connection->fetchPairs($select);
 }
开发者ID:evinw,项目名称:project_bloom_magento,代码行数:32,代码来源:Category.php


示例7: getCount

 /**
  * Retrieve array with products counts per attribute option
  *
  * @param Mage_Catalog_Model_Layer_Filter_Attribute $filter
  * @return array
  */
 public function getCount($filter)
 {
     $connection = $this->_getReadAdapter();
     $base_select = $filter->getLayer()->getBaseSelect();
     if (isset($base_select['stock_status'])) {
         $select = $base_select['stock_status'];
     } else {
         $select = clone $filter->getLayer()->getProductCollection()->getSelect();
     }
     $select->reset(Zend_Db_Select::LIMIT_COUNT);
     $select->reset(Zend_Db_Select::LIMIT_OFFSET);
     $sql = $connection->fetchAll($select);
     $productCollection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
     $product_ids = array();
     foreach ($sql as $item) {
         $product_ids[] = $item['entity_id'];
     }
     $collection = $productCollection->addAttributeToFilter('entity_id', array('in' => $product_ids));
     $collection->joinField('is_in_stock', 'cataloginventory/stock_item', 'is_in_stock', 'product_id=entity_id');
     $stockCount = array('instock' => 0, 'outofstock' => 0);
     foreach ($collection as $product) {
         if ((int) $product->getIsInStock() > 0) {
             $stockCount['instock']++;
         } else {
             $stockCount['outofstock']++;
         }
     }
     return $stockCount;
 }
开发者ID:vstorm83,项目名称:ausport,代码行数:35,代码来源:Stock.php


示例8: getCount

 /**
  * Retrieve array with products counts per attribute option
  *
  * @param Mage_Catalog_Model_Layer_Filter_Attribute $filter
  * @return array
  */
 public function getCount($filter)
 {
     // clone select from collection with filters
     $select = clone $filter->getLayer()->getProductCollection()->getSelect();
     // reset columns, order and limitation conditions
     $select->reset(Zend_Db_Select::COLUMNS);
     $select->reset(Zend_Db_Select::ORDER);
     $select->reset(Zend_Db_Select::LIMIT_COUNT);
     $select->reset(Zend_Db_Select::LIMIT_OFFSET);
     $connection = $this->_getReadAdapter();
     $attribute = $filter->getAttributeModel();
     $tableAlias = $attribute->getAttributeCode() . '_idx';
     $conditions = array("{$tableAlias}.entity_id = e.entity_id", $connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()), $connection->quoteInto("{$tableAlias}.store_id = ?", $filter->getStoreId()));
     $select->join(array($tableAlias => $this->getMainTable()), join(' AND ', $conditions), array('value', 'count' => "COUNT({$tableAlias}.entity_id)"))->group("{$tableAlias}.value");
     return $connection->fetchPairs($select);
 }
开发者ID:codercv,项目名称:urbansurprisedev,代码行数:22,代码来源:Attribute.php


示例9: generateNewRewrite

 /**
  * In case we could not find a fitting dataset in database we generate a new one from given filter and option_id.
  * The current store's normalized and lowercased option label is used as speaking url segment for the current url.
  *
  * The process checks, whether the given option_id value belongs to the given filter's attribute model and whether
  * the attribute model is filterable (though this should work anyways as only filterable attributes can be used to
  * create attribute filters).
  *
  * @param Mage_Catalog_Model_Layer_Filter_Attribute $filter The given attribute Filter.
  * @param int $optionId The wanted option id.
  * @param int $storeId Id of the currently active store
  * @return Flagbit_FilterUrls_Model_Rewrite|false On success Self, otherwise false.
  */
 public function generateNewRewrite($filter, $optionId, $storeId)
 {
     if (empty($filter) || !(int) $optionId) {
         return FALSE;
     }
     // load option from option_id
     $optionCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')->setStoreFilter($storeId, true);
     // normally this should be done using the setIdFilter option of the collection. Unfortunately this results in an
     // error in Magento version 1.6.2.0
     $optionCollection->getSelect()->where('`main_table`.`option_id` = ?', $optionId);
     $option = $optionCollection->getFirstItem();
     // get all currently filterable attributes
     $category = Mage::registry('current_category');
     $filterableAttributes = Mage::getSingleton('filterurls/catalog_layer')->setCurrentCategory($category)->getFilterableAttributes()->getItems();
     // failure, if current attribute not filterable or the option does not belong to the given attribute model
     if (!in_array($option['attribute_id'], array_keys($filterableAttributes)) || $filterableAttributes[$option['attribute_id']]->getAttributeCode() != $filter->getAttributeModel()->getAttributeCode()) {
         return FALSE;
     }
     // get normalized and lowercased version of the options label
     $label = mb_strtolower(Mage::helper('filterurls')->normalize($option->getValue()));
     // try to load the label, try to avoid duplication of rewrite strings by simple alternations
     $rewrite = Mage::getModel('filterurls/rewrite')->loadByRewriteString($label);
     $addition = 0;
     while ($rewrite->getId()) {
         $rewrite = Mage::getModel('filterurls/rewrite')->loadByRewriteString($label . '_' . ++$addition);
     }
     if ($addition) {
         $label .= '_' . $addition;
     }
     //set data, save to database and return new values
     $this->setAttributeCode($filter->getAttributeModel()->getAttributeCode())->setOptionId($optionId)->setRewrite($label)->setStoreId($storeId)->save();
     return $this;
 }
开发者ID:konstantins90,项目名称:Magento-FilterUrls,代码行数:46,代码来源:Rewrite.php


示例10: getCount

 /**
  * Retrieve array with products counts per attribute option
  *
  * @param Mage_Catalog_Model_Layer_Filter_Attribute $filter
  * @return array
  */
 public function getCount($filter)
 {
     $connection = $this->_getReadAdapter();
     $attribute = $filter->getAttributeModel();
     $tableAlias = $attribute->getAttributeCode() . '_idx';
     $base_select = $filter->getLayer()->getBaseSelect();
     if (isset($base_select[$attribute->getAttributeCode()])) {
         $select = $base_select[$attribute->getAttributeCode()];
     } else {
         $select = clone $filter->getLayer()->getProductCollection()->getSelect();
     }
     // reset columns, order and limitation conditions
     $select->reset(Zend_Db_Select::COLUMNS);
     $select->reset(Zend_Db_Select::ORDER);
     $select->reset(Zend_Db_Select::LIMIT_COUNT);
     $select->reset(Zend_Db_Select::LIMIT_OFFSET);
     $select->reset(Zend_Db_Select::GROUP);
     $conditions = array("{$tableAlias}.entity_id = e.entity_id", $connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()), $connection->quoteInto("{$tableAlias}.store_id = ?", $filter->getStoreId()));
     $select->join(array($tableAlias => $this->getMainTable()), join(' AND ', $conditions), array('value', 'count' => "COUNT(DISTINCT {$tableAlias}.entity_id)"))->group("{$tableAlias}.value");
     $_collection = clone $filter->getLayer()->getProductCollection();
     $searched_entity_ids = $_collection->load()->getSearchedEntityIds();
     if ($searched_entity_ids && is_array($searched_entity_ids) && count($searched_entity_ids)) {
         $select->where('e.entity_id IN (?)', $searched_entity_ids);
     }
     return $connection->fetchPairs($select);
 }
开发者ID:vstorm83,项目名称:ausport,代码行数:32,代码来源:Attribute.php


示例11: getCount

 /**
  * Retrieve array with products counts per attribute option
  *
  * @param Mage_Catalog_Model_Layer_Filter_Attribute $filter
  * @return array
  */
 public function getCount($filter, $requestVar = null)
 {
     // clone select from collection with filters
     $select = clone $filter->getLayer()->getProductCollection()->getSelect();
     // reset columns, order and limitation conditions
     $select->reset(Zend_Db_Select::COLUMNS);
     $select->reset(Zend_Db_Select::ORDER);
     $select->reset(Zend_Db_Select::LIMIT_COUNT);
     $select->reset(Zend_Db_Select::LIMIT_OFFSET);
     $connection = $this->_getReadAdapter();
     $attribute = $filter->getAttributeModel();
     $tableAlias = sprintf('%s_idxcount', $attribute->getAttributeCode());
     $conditions = array("{$tableAlias}.entity_id = e.entity_id", $connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()), $connection->quoteInto("{$tableAlias}.store_id = ?", $filter->getStoreId()));
     if (isset($requestVar)) {
         $options = $select->getPart('from');
         $select->reset(Zend_Db_Select::FROM);
         unset($options[$requestVar . '_idx']);
         $select->forFrom($options);
     }
     $select->join(array($tableAlias => $this->getMainTable()), join(' AND ', $conditions), array('value', 'count' => new Zend_Db_Expr("COUNT({$tableAlias}.entity_id)")))->group("{$tableAlias}.value");
     return $connection->fetchPairs($select);
 }
开发者ID:aayushKhandpur,项目名称:aayush-renting,代码行数:28,代码来源:Attribute.php


示例12: getCount

 /**
  * Retrieve array with products counts per attribute option
  *
  * @param Mage_Catalog_Model_Layer_Filter_Attribute $filter
  * @return array
  */
 public function getCount($filter)
 {
     // clone select from collection with filters
     $select = clone $filter->getLayer()->getProductCollection()->getSelect();
     // reset columns, order and limitation conditions
     //
     $fromPart = $select->getPart(Zend_Db_Select::FROM);
     if (!empty($fromPart['cat_index']['joinCondition'])) {
         $fromPart['cat_index']['joinCondition'] = str_replace('cat_index.visibility IN(2, 4)', 'cat_index.visibility IN(2, 3, 4)', $fromPart['cat_index']['joinCondition']);
     }
     $select->setPart(Zend_Db_Select::FROM, $fromPart);
     //
     $select->reset(Zend_Db_Select::COLUMNS);
     $select->reset(Zend_Db_Select::ORDER);
     $select->reset(Zend_Db_Select::LIMIT_COUNT);
     $select->reset(Zend_Db_Select::LIMIT_OFFSET);
     $connection = $this->_getReadAdapter();
     $attribute = $filter->getAttributeModel();
     $tableAlias = $attribute->getAttributeCode() . '_idx';
     $conditions = array("{$tableAlias}.entity_id = e.entity_id", $connection->quoteInto("{$tableAlias}.attribute_id = ?", $attribute->getAttributeId()));
     $select->join(array($tableAlias => $this->textfieldTable), join(' AND ', $conditions), array('value', 'count' => "COUNT({$tableAlias}.entity_id)"))->group("{$tableAlias}.value");
     return $connection->fetchPairs($select);
 }
开发者ID:CherylMuniz,项目名称:fashion,代码行数:29,代码来源:Textfield.php


示例13: applyFilterToCollection

 /**
  * Apply attribute filter to solr query
  *
  * @param Mage_Catalog_Model_Layer_Filter_Attribute $filter
  * @param int $value
  */
 public function applyFilterToCollection($filter, $value)
 {
     if (empty($value)) {
         $value = array();
     } else {
         if (!is_array($value)) {
             $value = array($value);
         }
     }
     $productCollection = $this->getLayer()->getProductCollection();
     $attribute = $filter->getAttributeModel();
     $param = Mage::helper('enterprise_search')->getSearchParam($productCollection, $attribute, $value);
     $productCollection->addSearchQfFilter($param);
     return $this;
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:21,代码来源:Attribute.php


示例14: getCountAttribute

 /**
  * 
  *
  * @param Mage_Catalog_Model_Layer_Filter_Attribute $filter
  * @return array
  */
 public function getCountAttribute($filter)
 {
     $ret = array();
     if (empty($filter)) {
         return $ret;
     }
     $attribute = $filter->getAttributeModel();
     if (empty($attribute)) {
         return $ret;
     }
     $label = 'attribute_' . $attribute->getId();
     if (!$this->checkAttributesCountLabel($label)) {
         $vals = array();
         $res = $this->getSearchResult();
         if (!empty($res['facets'])) {
             foreach ($res['facets'] as $facet) {
                 if ($facet['attribute'] == $label) {
                     if (!empty($facet['buckets'])) {
                         foreach ($facet['buckets'] as $bucket) {
                             if ($bucket['count'] > 0) {
                                 $vals[$bucket['value']] = $bucket['count'];
                             }
                         }
                     }
                 }
             }
         }
         $this->setAttributesCountLabel($vals, $label);
     }
     return $this->getAttributesCountLabel($label);
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:37,代码来源:Request.php


示例15: applyFilterToCollection

 /**
  * Apply attribute filter to solr query
  *
  * @param   Mage_Catalog_Model_Layer_Filter_Attribute $filter
  * @param   int $value
  *
  * @return  Celebros_Conversionpro_Model_Catalog_Layer_Filter_Attribute
  */
 public function applyFilterToCollection($filter, $value)
 {
     if (empty($value) || isset($value['from']) && empty($value['from']) && isset($value['to']) && empty($value['to'])) {
         $value = array();
     }
     if (!is_array($value)) {
         $value = array($value);
     }
     $collection = Mage::helper('conversionpro')->getCurrentLayer()->getProductCollection();
     $engine = Mage::getResourceSingleton('conversionpro/fulltext_engine');
     $fieldName = $engine->getSearchEngineFieldName($filter->getAttributeModel(), 'nav');
     foreach ($value as $answerId) {
         $collection->addFqFilter(array($fieldName => $answerId));
     }
     return $this;
 }
开发者ID:jokusafet,项目名称:MagentoSource,代码行数:24,代码来源:Attribute.php


示例16: applyFilterToCollection

 /**
  * Apply attribute filter to solr query
  *
  * @param   Mage_Catalog_Model_Layer_Filter_Attribute $filter
  * @param   int $value
  *
  * @return  Enterprise_Search_Model_Catalog_Layer_Filter_Attribute
  */
 public function applyFilterToCollection($filter, $value)
 {
     if (empty($value) || isset($value['from']) && empty($value['from']) && isset($value['to']) && empty($value['to'])) {
         $value = array();
     }
     if (!is_array($value)) {
         $value = array($value);
     }
     $attribute = $filter->getAttributeModel();
     $options = $attribute->getSource()->getAllOptions();
     foreach ($value as &$valueText) {
         foreach ($options as $option) {
             if ($option['label'] == $valueText) {
                 $valueText = $option['value'];
             }
         }
     }
     $fieldName = Mage::getResourceSingleton('enterprise_search/engine')->getSearchEngineFieldName($attribute, 'nav');
     $this->getLayer()->getProductCollection()->addFqFilter(array($fieldName => $value));
     return $this;
 }
开发者ID:QiuLihua83,项目名称:magento-enterprise-1.13.1.0,代码行数:29,代码来源:Attribute.php


示例17: testGetItems

 public function testGetItems()
 {
     $items = $this->_model->getItems();
     $this->assertInternalType('array', $items);
     $this->assertEquals(1, count($items));
     /** @var $item Mage_Catalog_Model_Layer_Filter_Item */
     $item = $items[0];
     $this->assertInstanceOf('Mage_Catalog_Model_Layer_Filter_Item', $item);
     $this->assertSame($this->_model, $item->getFilter());
     $this->assertEquals('Option Label', $item->getLabel());
     $this->assertEquals($this->_attributeOptionId, $item->getValue());
     $this->assertEquals(1, $item->getCount());
 }
开发者ID:relue,项目名称:magento2,代码行数:13,代码来源:AttributeTest.php


示例18: _getBaseCollectionSql

 protected function _getBaseCollectionSql()
 {
     $alias = 'attr_index_' . $this->getAttributeModel()->getId();
     // Varien_Db_Select
     $baseSelect = clone parent::_getBaseCollectionSql();
     // 1) remove from conditions
     $oldWhere = $baseSelect->getPart(Varien_Db_Select::WHERE);
     $newWhere = array();
     foreach ($oldWhere as $cond) {
         if (!strpos($cond, $alias)) {
             $newWhere[] = $cond;
         }
     }
     if ($newWhere && substr($newWhere[0], 0, 3) == 'AND') {
         $newWhere[0] = substr($newWhere[0], 3);
     }
     $baseSelect->setPart(Varien_Db_Select::WHERE, $newWhere);
     // 2) remove from joins
     $oldFrom = $baseSelect->getPart(Varien_Db_Select::FROM);
     $newFrom = array();
     foreach ($oldFrom as $name => $val) {
         if ($name != $alias) {
             $newFrom[$name] = $val;
         }
     }
     //it assumes we have at least one table
     $baseSelect->setPart(Varien_Db_Select::FROM, $newFrom);
     return $baseSelect;
 }
开发者ID:monarcmoso,项目名称:beta2,代码行数:29,代码来源:MMD_Multiselectnavigation_Model_Catalog_Layer_Filter_Attribute.php


示例19: apply

 public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
 {
     if (Mage::getStoreConfig('mageworx_seo/seosuite/disable_layered_rewrites')) {
         return parent::apply($request, $filterBlock);
     }
     $text = $request->getParam($this->_requestVar);
     if (is_array($text)) {
         return $this;
     }
     $filter = $this->_getOptionId($text);
     if ($filter && $text) {
         $layeredNavigationCanonical = $this->getAttributeModel()->getLayeredNavigationCanonical();
         if ($layeredNavigationCanonical == 1) {
             $layerCanonicalFilter = Mage::registry('layer_canonical_filter');
             if (!$layerCanonicalFilter) {
                 $layerCanonicalFilter = array();
             }
             $attributeCode = $this->getAttributeModel()->getAttributeCode();
             $layerCanonicalFilter[$attributeCode] = $text;
             //$layeredNavigationCanonical;
             Mage::unregister('layer_canonical_filter');
             Mage::register('layer_canonical_filter', $layerCanonicalFilter);
         }
         if (method_exists($this, '_getResource')) {
             $this->_getResource()->applyFilterToCollection($this, $filter);
         } else {
             Mage::getSingleton('catalogindex/attribute')->applyFilterToCollection($this->getLayer()->getProductCollection(), $this->getAttributeModel(), $filter);
         }
         $this->getLayer()->getState()->addFilter($this->_createItem($text, $filter));
         $this->_items = array();
     }
     return $this;
 }
开发者ID:protechhelp,项目名称:gamamba,代码行数:33,代码来源:Attribute.php


示例20: _getItemsData

 /**
  * Get data array for building attribute filter items
  *
  * @return array
  */
 protected function _getItemsData()
 {
     if (!Mage::helper('catalin_seo')->isEnabled()) {
         return parent::_getItemsData();
     }
     $attribute = $this->getAttributeModel();
     $this->_requestVar = $attribute->getAttributeCode();
     $key = $this->getLayer()->getStateKey() . '_' . $this->_requestVar;
     $data = $this->getLayer()->getAggregator()->getCacheData($key);
     if ($data === null) {
         $attrUrlKeyModel = Mage::getResourceModel('catalin_seo/attribute_urlkey');
         $options = $attribute->getFrontend()->getSelectOptions();
         $optionsCount = $this->_getResource()->getCount($this);
         $data = array();
         foreach ($options as $option) {
             if (is_array($option['value'])) {
                 continue;
             }
             if (Mage::helper('core/string')->strlen($option['value'])) {
                 // Check filter type
                 if ($this->_getIsFilterableAttribute($attribute) == self::OPTIONS_ONLY_WITH_RESULTS) {
                     if (!empty($optionsCount[$option['value']])) {
                         $data[] = array('label' => $option['label'], 'value' => $attrUrlKeyModel->getUrlKey($attribute->getId(), $option['value']), 'count' => $optionsCount[$option['value']]);
                     }
                 } else {
                     $data[] = array('label' => $option['label'], 'value' => $attrUrlKeyModel->getUrlKey($attribute->getId(), $option['value']), 'count' => isset($optionsCount[$option['value']]) ? $optionsCount[$option['value']] : 0);
                 }
             }
         }
         $tags = array(Mage_Eav_Model_Entity_Attribute::CACHE_TAG . ':' . $attribute->getId());
         $tags = $this->getLayer()->getStateTags($tags);
         $this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
     }
     return $data;
 }
开发者ID:santhosh400,项目名称:ecart,代码行数:40,代码来源:Attribute.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Mage_Catalog_Model_Layer_Filter_Price类代码示例发布时间:2022-05-23
下一篇:
PHP Mage_Catalog_Model_Layer_Filter_Abstract类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap