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

PHP Mage_Catalog_Model_Layer_Filter_Price类代码示例

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

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



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

示例1: applyPriceRange

 /**
  * Apply price range filter to product collection
  *
  * @param Mage_Catalog_Model_Layer_Filter_Price $filter
  * @return Mage_Catalog_Model_Resource_Layer_Filter_Price
  */
 public function applyPriceRange($filter)
 {
     $interval = $filter->getInterval();
     if (!$interval) {
         return $this;
     }
     list($from, $to) = $interval;
     if ($from === '' && $to === '') {
         return $this;
     }
     $select = $filter->getLayer()->getProductCollection()->getSelect();
     $priceExpr = $this->_getPriceExpression($filter, $select, false);
     if ($to !== '') {
         $to = (double) $to;
         if ($from == $to) {
             $to += self::MIN_POSSIBLE_PRICE;
         }
     }
     if ($from !== '') {
         $select->where($priceExpr . ' >= ' . $this->_getComparingValue($from, $filter));
     }
     if ($to !== '') {
         $select->where($priceExpr . ' <= ' . $this->_getComparingValue($to, $filter));
     }
     return $this;
 }
开发者ID:santhosh400,项目名称:ecart,代码行数:32,代码来源:Price.php


示例2: setUp

 protected function setUp()
 {
     $this->_model = new Mage_Catalog_Model_Layer_Filter_Price_Algorithm();
     $this->_layer = new Mage_Catalog_Model_Layer();
     $this->_filter = new Mage_Catalog_Model_Layer_Filter_Price();
     $this->_filter->setLayer($this->_layer)->setAttributeModel(new Varien_Object(array('attribute_code' => 'price')));
 }
开发者ID:nemphys,项目名称:magento2,代码行数:7,代码来源:AlgorithmBaseTest.php


示例3: applyFilterToCollection

 /**
  * Apply attribute filter to product collection
  *
  * @param Mage_Catalog_Model_Layer_Filter_Price $filter
  * @param int $range
  * @param int $index    the range factor
  *
  * @return Celebros_Conversionpro_Model_Catalog_Layer_Filter_Decimal
  */
 public function applyFilterToCollection($filter, $range, $index)
 {
     $productCollection = $filter->getLayer()->getProductCollection();
     $attributeCode = $filter->getAttributeModel()->getAttributeCode();
     $field = 'attr_decimal_' . $attributeCode;
     $value = array($field => array('from' => $range * ($index - 1), 'to' => $range * $index - 0.001));
     $productCollection->addFqFilter($value);
     return $this;
 }
开发者ID:jokusafet,项目名称:MagentoSource,代码行数:18,代码来源:Decimal.php


示例4: apply

 /**
  * Apply price range filter to collection
  *
  * @param Zend_Controller_Request_Abstract $request
  * @param $filterBlock
  *
  * @return Mage_Catalog_Model_Layer_Filter_Price
  */
 public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
 {
     if (Mage::helper('mtfilter')->isPriceEnable() && version_compare(Mage::getVersion(), '1.7.0.0') < 0) {
         /**
          * Filter must be string: $index,$range
          */
         $filter = $request->getParam($this->getRequestVar());
         if (!$filter) {
             return $this;
         }
         $filter = explode('-', $filter);
         if (count($filter) != 2) {
             return $this;
         }
         list($index, $range) = $filter;
         if (is_numeric($index) && is_numeric($range)) {
             $this->setPriceRange((int) $range);
             $this->setPriceRangeCustom($filter);
             $this->_applyToCollection($range, $index);
             $this->getLayer()->getState()->addFilter($this->_createItem($this->_renderItemLabelCustom($index, $range), $filter));
             $this->_items = array();
         }
         return $this;
     } else {
         parent::apply($request, $filterBlock);
     }
 }
开发者ID:igorvasiliev4,项目名称:magento_code,代码行数:35,代码来源:Price.php


示例5: _dispatchPreparePriceEvent

 /**
  * Prepare response object and dispatch prepare price event
  *
  * Return response object
  *
  * @param Mage_Catalog_Model_Layer_Filter_Price $filter
  * @param Varien_Db_Select $select
  * @return Varien_Object
  */
 protected function _dispatchPreparePriceEvent($filter, $select)
 {
     // prepare response object for event
     $response = new Varien_Object();
     $response->setAdditionalCalculations(array());
     // prepare event arguments
     $eventArgs = array('select' => $select, 'table' => $this->_getIndexTableAlias(), 'store_id' => $filter->getStoreId(), 'response_object' => $response);
     /**
      * @deprecated since 1.3.2.2
      */
     Mage::dispatchEvent('catalogindex_prepare_price_select', $eventArgs);
     /**
      * @since 1.4
      */
     Mage::dispatchEvent('catalog_prepare_price_select', $eventArgs);
     return $response;
 }
开发者ID:xiaoguizhidao,项目名称:devfashion,代码行数:26,代码来源:Price.php


示例6: _prepareFilter

 /**
  * Prepare price filter model
  *
  * @param Magento_Test_Request|null $request
  * @return void
  */
 protected function _prepareFilter($request = null)
 {
     $layer = new Mage_Catalog_Model_Layer();
     $layer->setCurrentCategory(4);
     $layer->setState(new Mage_Catalog_Model_Layer_State());
     $filter = new Mage_Catalog_Model_Layer_Filter_Price();
     $filter->setLayer($layer)->setAttributeModel(new Varien_Object(array('attribute_code' => 'price')));
     if (!is_null($request)) {
         $filter->apply($request, new Mage_Core_Block_Text());
         $interval = $filter->getInterval();
         if ($interval) {
             $this->_model->setLimits($interval[0], $interval[1]);
         }
     }
     $collection = $layer->getProductCollection();
     $this->_model->setPricesModel($filter)->setStatistics($collection->getMinPrice(), $collection->getMaxPrice(), $collection->getPriceStandardDeviation(), $collection->getSize());
 }
开发者ID:NatashaOlut,项目名称:Mage_Test,代码行数:23,代码来源:AlgorithmAdvanced.php


示例7: applyFilterToCollection

 /**
  * Apply attribute filter to product collection
  *
  * @param Mage_Catalog_Model_Layer_Filter_Price $filter
  * @param int $range
  * @param int $index    the range factor
  * @return Mage_Catalog_Model_Resource_Layer_Filter_Price
  */
 public function applyFilterToCollection($filter, $range, $index)
 {
     $collection = $filter->getLayer()->getProductCollection();
     $collection->addPriceData($filter->getCustomerGroupId(), $filter->getWebsiteId());
     $select = $collection->getSelect();
     $response = $this->_dispatchPreparePriceEvent($filter, $select);
     $table = $this->_getIndexTableAlias();
     $additional = join('', $response->getAdditionalCalculations());
     $rate = $filter->getCurrencyRate();
     $priceExpr = new Zend_Db_Expr("(({$table}.min_price {$additional}) * {$rate})");
     $filters = $filter->getPriceRangeCustom();
     if ($filters) {
         $select->where($priceExpr . ' >= ?', (int) $filters[0])->where($priceExpr . ' < ?', (int) $filters[1]);
     } else {
         $select->where($priceExpr . ' >= ?', $range * ($index - 1))->where($priceExpr . ' < ?', $range * $index);
     }
     return $this;
 }
开发者ID:dragontheme1235,项目名称:project-1,代码行数:26,代码来源:Price.php


示例8: _getMaxMinPrice

 /**
  * Retrieve minimal and maximal prices
  * 
  * @param Mage_Catalog_Model_Layer_Filter_Price $filter
  * @return array (max, min)
  */
 protected function _getMaxMinPrice($filter)
 {
     if (!$this->_maxMinPrice) {
         $select = clone $filter->getLayer()->getProductCollection()->getSelect();
         $select->reset(Zend_Db_Select::LIMIT_OFFSET);
         $select->reset(Zend_Db_Select::COLUMNS);
         $select->reset(Zend_Db_Select::LIMIT_COUNT);
         $select->reset(Zend_Db_Select::ORDER);
         /* @var $collection Mage_Catalog_Model_Resource_Product_Collection */
         $collection = Mage::getResourceModel('catalog/product_collection');
         $priceExpression = $collection->getPriceExpression($select) . ' ' . $collection->getAdditionalPriceExpression($select);
         $select = $this->_removePriceFromSelect($select, $priceExpression);
         $sqlEndPart = ') * ' . $collection->getCurrencyRate() . ')';
         $select->columns('CEIL(MAX(' . $priceExpression . $sqlEndPart . ' as max_price');
         $select->columns('FLOOR(MIN(' . $priceExpression . $sqlEndPart . ' as min_price');
         $select->where($collection->getPriceExpression($select) . ' IS NOT NULL');
         $this->_maxMinPrice = $collection->getConnection()->fetchRow($select, array(), Zend_Db::FETCH_NUM);
     }
     return $this->_maxMinPrice;
 }
开发者ID:nilshopsahl,项目名称:hasla.local,代码行数:26,代码来源:Price17.php


示例9: apply

 /**
  * Apply price range filter
  *
  * @param Zend_Controller_Request_Abstract $request
  * @param $filterBlock
  *
  * @return Mage_Catalog_Model_Layer_Filter_Price
  */
 public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
 {
     if (!Mage::helper('catalogfilter')->priceIsSlider()) {
         return parent::apply($request, $filterBlock);
     }
     /**
      * Filter must be string: $fromPrice-$toPrice
      */
     $filter = $request->getParam($this->getRequestVar());
     if (!$filter) {
         return $this;
     }
     //validate filter
     $filterParams = explode(',', $filter);
     $filter = $this->_validateFilter($filterParams[0]);
     if (!$filter) {
         return $this;
     }
     list($from, $to) = $filter;
     $this->setInterval(array($from, $to));
     $priorFilters = array();
     for ($i = 1; $i < count($filterParams); ++$i) {
         $priorFilter = $this->_validateFilter($filterParams[$i]);
         if ($priorFilter) {
             $priorFilters[] = $priorFilter;
         } else {
             //not valid data
             $priorFilters = array();
             break;
         }
     }
     if ($priorFilters) {
         $this->setPriorIntervals($priorFilters);
     }
     $this->_applyPriceRange();
     Mage::getSingleton('catalogfilter/layer_state')->addFilter($this->getRequestVar(), $filter);
     return $this;
 }
开发者ID:sivabupathy,项目名称:edge-magento-module-catalogfilter,代码行数:46,代码来源:Price.php


示例10: applyPriceRange

 /**
  * Apply price range filter to product collection
  *
  * @param Mage_Catalog_Model_Layer_Filter_Price $filter
  * @return Mage_Catalog_Model_Resource_Layer_Filter_Price
  */
 public function applyPriceRange($filter)
 {
     $interval = $filter->getInterval();
     if (!$interval) {
         return $this;
     }
     list($from, $to) = $interval;
     if ($from === '' && $to === '') {
         return $this;
     }
     list($select, $priceExpr) = $this->_prepareApply($filter);
     if ($from == $to && !empty($to)) {
         $select->where($priceExpr . ' = ?', $from);
     } else {
         if ($from !== '') {
             $select->where($priceExpr . ' >= ?', $from);
         }
         if ($to !== '') {
             $select->where($priceExpr . ' < ?', $to);
         }
     }
     return $this;
 }
开发者ID:relue,项目名称:magento2,代码行数:29,代码来源:Price.php


示例11: applyFilterToCollection

 /**
  * Apply attribute filter to product collection
  *
  * @param Mage_Catalog_Model_Layer_Filter_Price $filter
  * @param int $range
  * @param int $index    the range factor
  * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Layer_Filter_Attribute
  */
 public function applyFilterToCollection($filter, $value)
 {
     $collection = $filter->getLayer()->getProductCollection();
     //$collection->addPriceData($filter->getCustomerGroupId(), $filter->getWebsiteId());
     $select = $collection->getSelect();
     $this->prepareSelect($filter, $value, $select);
     $attribute_code = 'price';
     $base_select = $filter->getLayer()->getBaseSelect();
     foreach ($base_select as $code => $select) {
         if ($attribute_code != $code) {
             $this->prepareSelect($filter, $value, $select);
         }
     }
     return $this;
 }
开发者ID:vstorm83,项目名称:ausport,代码行数:23,代码来源:Price.php


示例12: applyPriceRange

 /**
  * Apply price range filter to product collection
  *
  * @param Mage_Catalog_Model_Layer_Filter_Price $filter Filter
  * @return Mage_Catalog_Model_Resource_Layer_Filter_Price
  */
 public function applyPriceRange($filter)
 {
     $intervals = $filter->getPriorIntervals();
     if (!$intervals) {
         return $this;
     }
     $select = $filter->getLayer()->getProductCollection()->getSelect();
     $priceExpr = $this->_getPriceExpression($filter, $select, false);
     $whereArray = array();
     foreach ($intervals as $interval) {
         list($from, $to) = $interval;
         if ($from === '' && $to === '') {
             return $this;
         }
         if ($to !== '') {
             $to = (double) $to;
             if ($from == $to) {
                 $to += self::MIN_POSSIBLE_PRICE;
             }
         }
         if ($from !== '' && $to !== '') {
             $whereArray[] = "({$priceExpr} >= {$this->_getComparingValue($from, $filter)} AND {$priceExpr} <= " . "{$this->_getComparingValue($to, $filter, false)})";
         } else {
             if ($from !== '') {
                 $whereArray[] = "({$priceExpr} >= {$this->_getComparingValue($from, $filter)})";
             }
             if ($to !== '') {
                 $whereArray[] = "({$priceExpr} <= {$this->_getComparingValue($to, $filter, false)})";
             }
         }
     }
     $select->where(new Zend_db_Expr(implode(' OR ', $whereArray)));
     return $this;
 }
开发者ID:kumardhirendra1,项目名称:Magento_Filter,代码行数:40,代码来源:Price.php


示例13: getCountAttributePrice

 /**
  * Retrieve array with products counts per price range
  *
  * @param Mage_Catalog_Model_Layer_Filter_Price $filter
  * @param int $range
  * @return array
  */
 public function getCountAttributePrice($filter, $range)
 {
     $ret = array();
     $rate = $this->getCurrentCurrencyRate($this->store);
     if (empty($filter) || empty($rate)) {
         return $ret;
     }
     $attribute = $filter->getAttributeModel();
     if (empty($attribute)) {
         return $ret;
     }
     // hook, it is need for 'union' and this attribute defined in the 'price' field
     if ($attribute->getAttributeCode() == 'price') {
         $label = 'price';
     } else {
         $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) {
                             // Example
                             //~ [value] => 1000-2000
                             //~ [title] => 1000 - 2000
                             //~ [from] => 1000
                             //~ [to] => 2000
                             //~ [count] => 2
                             $numberStep = round($bucket['to'] * $rate / $range);
                             if ($numberStep > 0) {
                                 $vals[$numberStep] = $bucket['count'];
                             }
                         }
                     }
                 }
             }
         }
         $this->setAttributesCountLabel($vals, $label);
     }
     return $this->getAttributesCountLabel($label);
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:51,代码来源:Request.php


示例14: _getItemsData

 /**
  * Get data for build price filter items
  *
  * @return array
  */
 protected function _getItemsData()
 {
     if (!Mage::getStoreConfig('amshopby/general/use_custom_ranges')) {
         return parent::_getItemsData();
     }
     $key = $this->_getCacheKey();
     $data = $this->getLayer()->getAggregator()->getCacheData($key);
     if ($data === null) {
         $ranges = $this->_getCustomRanges();
         $counts = $this->_getResource()->getFromToCount($this, $ranges);
         $data = array();
         foreach ($counts as $index => $count) {
             if (!$index) {
                 // index may be NULL if some products has price out of all ranges
                 continue;
             }
             $from = $ranges[$index][0];
             $to = $ranges[$index][1];
             $data[] = array('label' => $this->_renderFromToItemLabel($from, $to), 'value' => $from . '-' . $to, 'count' => $count, 'pos' => $from);
         }
         usort($data, array($this, '_srt'));
         $tags = array(Mage_Catalog_Model_Product_Type_Price::CACHE_TAG);
         $tags = $this->getLayer()->getStateTags($tags);
         $this->getLayer()->getAggregator()->saveCacheData($data, $key, $tags);
     }
     return $data;
 }
开发者ID:rcclaudrey,项目名称:dev,代码行数:32,代码来源:Price14ce.php


示例15: testGetSetCurrencyRate

 public function testGetSetCurrencyRate()
 {
     $this->assertEquals(1, $this->_model->getCurrencyRate());
     $currencyRate = 42;
     $this->_model->setCurrencyRate($currencyRate);
     $this->assertEquals($currencyRate, $this->_model->getCurrencyRate());
 }
开发者ID:nemphys,项目名称:magento2,代码行数:7,代码来源:PriceTest.php


示例16: getPriceRange

 /**
  * Get price range for building filter steps
  *
  * @return int
  */
 public function getPriceRange()
 {
     if ($range = intval(Mage::helper('ecommerceteam_sln')->getConfigData('pricerange'))) {
         if ($range > 0) {
             return $range;
         }
     }
     return parent::getPriceRange();
 }
开发者ID:xiaoguizhidao,项目名称:devfashion,代码行数:14,代码来源:Price.php


示例17: _renderRangeLabel

 protected function _renderRangeLabel($fromPrice, $toPrice)
 {
     //if (method_exists(get_parent_class($this), "_renderRangeLabel")) {
     // return parent::_renderRangeLabel($fromPrice, $toPrice);
     // } else {
     $range = $toPrice - $fromPrice;
     $value = $toPrice / $range;
     return parent::_renderItemLabel($range, $value);
     //}
 }
开发者ID:mSupply,项目名称:runnable_test_repo,代码行数:10,代码来源:Price.php


示例18: apply

 public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
 {
     return parent::apply($request, $filterBlock);
     //        $filter = $request->getParam($this->getRequestVar());
     //        if (!$filter) return $this;
     //
     //	$layeredNavigationCanonical = $this->getAttributeModel()->getLayeredNavigationCanonical();
     //        if ($layeredNavigationCanonical==1) {
     //            $layerCanonicalFilter = Mage::registry('layer_canonical_filter');
     //            if (!$layerCanonicalFilter) $layerCanonicalFilter = array();
     //            $attributeCode = $this->getAttributeModel()->getAttributeCode();
     //            $layerCanonicalFilter[$attributeCode] = $filter; //$layeredNavigationCanonical;
     //            Mage::unregister('layer_canonical_filter');
     //            Mage::register('layer_canonical_filter', $layerCanonicalFilter);
     //        }
 }
开发者ID:protechhelp,项目名称:gamamba,代码行数:16,代码来源:Price.php


示例19: getMaxPriceInt

 /**
  * Retrieves max price for ranges definition.
  *
  * @return float
  */
 public function getMaxPriceInt()
 {
     $searchParams = $this->getLayer()->getProductCollection()->getExtendedSearchParams();
     $uniquePart = strtoupper(md5(serialize($searchParams)));
     $cacheKey = 'MAXPRICE_' . $this->getLayer()->getStateKey() . '_' . $uniquePart;
     $cachedData = Mage::app()->loadCache($cacheKey);
     if (!$cachedData) {
         $stats = $this->getLayer()->getProductCollection()->getStats($this->_getFilterField());
         $max = $this->_isFacetMaxPriceSet($stats) ? $stats['facets'][$this->_getFilterField()]['max'] : null;
         if (!is_numeric($max)) {
             $max = parent::getMaxPriceInt();
         }
         $cachedData = (double) $max;
         $tags = $this->getLayer()->getStateTags();
         $tags[] = self::CACHE_TAG;
         Mage::app()->saveCache($cachedData, $cacheKey, $tags);
     }
     return $cachedData;
 }
开发者ID:adrianoaguiar,项目名称:magento-elasticsearch-module,代码行数:24,代码来源:Price.php


示例20: getPriceRange

 /**
  * Get price range for building filter steps
  *
  * @return int
  */
 public function getPriceRange()
 {
     if (!Mage::helper('searchanise/ApiSe')->checkSearchaniseResult(true)) {
         return parent::getPriceRange();
     }
     $collection = $this->getLayer()->getProductCollection();
     if (!method_exists($collection, 'checkSearchaniseResult') || !$collection->checkSearchaniseResult()) {
         return parent::getPriceRange();
     }
     $newRange = $collection->getSearchaniseRequest()->getPriceRangeFromAttribute($this->getAttributeModel());
     if (!$newRange) {
         return parent::getPriceRange();
     }
     $rate = Mage::app()->getStore()->getCurrentCurrencyRate();
     if (!$rate || $rate == 1) {
         // nothing
     } else {
         $newRange *= $rate;
     }
     return $newRange;
 }
开发者ID:kozinthetdbp,项目名称:shopmyar,代码行数:26,代码来源:Price.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP Mage_Catalog_Model_Product类代码示例发布时间:2022-05-23
下一篇:
PHP Mage_Catalog_Model_Layer_Filter_Attribute类代码示例发布时间: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