php - Extend Model class for Price Filter Layered Navigation in Magento2 -




i have created custom module thought override function handles pricerender price filter (layered navigation).

for example, instead of showing price filters such 0 - 99.99, 100 - 199.99, show 0 - 100, 100 - 200 , forth.

my module stands...

di.xml:

<?xml version="1.0"?>  <config xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="urn:magento:framework:objectmanager/etc/config.xsd"> <preference for="magento\catalog\model\layer\filter\price" type="rf\roundpricefilter\model\layer\filter\price" /> </config> 

and module.xml file is:

<?xml version="1.0"?><config xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="../../../../../lib/internal/magento/framework/module/etc/module.xsd"> <module name="rf_roundpricefilter" setup_version="1.0.0"</module> </config> 

and in model/layer/filter/price.php file is...

<?php namespace rf\roundpricefilter\model\layer\filter; class price extends \magento\catalog\model\layer\filter\abstractfilter {       /**      * rf prepare text of range label      *      * @param float|string $fromprice      * @param float|string $toprice      * @return float|\magento\framework\phrase      */     public function _renderrangelabel($fromprice, $toprice)     {         $formattedfromprice = $this->pricecurrency->format($fromprice);         if ($toprice === '') {             return __('%1 , above', $formattedfromprice);         } elseif ($fromprice == $toprice && $this->dataprovider->getonepriceintervalvalue()         ) {             return $formattedfromprice;         } else {             //if ($fromprice != $toprice) {            //     $toprice -= .01;          //   }              return __('%1 - %2', $formattedfromprice, $this->pricecurrency->format($toprice));         }     }   } 

any appreciated!





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -