Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Merge branch 'release'
Browse files Browse the repository at this point in the history
  • Loading branch information
Edwin Jacobs committed Oct 14, 2020
2 parents d33426d + dd8cf9c commit 9df433c
Show file tree
Hide file tree
Showing 88 changed files with 2,846 additions and 871 deletions.
26 changes: 23 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
## 0.1.0-beta (2017-02-01)
## 3.0.0
1) Ajax filtering implemented
2) methods and property visibility updated to "protected" (to allow easier preferences).

Features:
- Supported Magento versions 100.1.*|100.0.*,
BC breaks:
1) Template src/view/frontend/templates/product/navigation/view.phtml moved to src/view/frontend/templates/layer/view.phtml
as that is the template it replaces
2) Complete overhaul of js components, if you have any changes in those you will need to redo them.
3) Overhauled slider template: src/view/frontend/templates/product/layered/slider.phtml the javascript part has been moved to a separate js component, namely
src/view/frontend/web/js/navigation-slider.js
4) Removed deprecated methods from src/Block/LayeredNavigation/RenderLayered/SliderRenderer.php
5) All data-mage-init statements now go through model: src/Model/NavigationConfig.php this class will resolve the correct js components based on your configuration
This means yet more bc breaks on your template overrides (if any)
6) References to "Zend\Http\Request as HttpRequest" have been removed, we now depend on the concrete magento request object. This is because of the move from zend to laminas.
7) Added methods
```php
public function getClearUrl(MagentoHttpRequest $request, array $activeFilterItems): string;
public function buildFilterUrl(MagentoHttpRequest $request, array $filters = []): string;
```
To interface UrlInterface to facilitate ajax filtering

Furthermore: various code style fixes, simplifications and general "cleanup".


8 changes: 4 additions & 4 deletions src/Block/Catalog/Product/ProductList/Featured.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ class Featured extends ListProduct
/**
* @var RecommendationsContext
*/
private $recommendationsContext;
protected $recommendationsContext;

/**
* @var Config
*/
private $config;
protected $config;

/**
* @var TemplateFinder
*/
private $templateFinder;
protected $templateFinder;

/**
* @var PreparePostDataFactory
*/
private $preparePostDataFactory;
protected $preparePostDataFactory;

/**
* Featured constructor.
Expand Down
19 changes: 18 additions & 1 deletion src/Block/Catalog/Product/ProductList/Toolbar/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,21 @@ public function aroundGetAvailableOrders(Toolbar $subject, Closure $proceed)
}
return $result;
}
}

/**
* @param Toolbar $subject
* @param string $result
* @return false|string
*/
public function afterGetWidgetOptionsJson(Toolbar $subject, string $result)
{
if (!$this->config->isAjaxFilters()) {
return $result;
}

$options = json_decode($result, true);
$options['productListToolbarForm']['ajaxFilters'] = true;

return json_encode($options);
}
}
37 changes: 0 additions & 37 deletions src/Block/LayeredNavigation/Navigation/Plugin.php

This file was deleted.

112 changes: 112 additions & 0 deletions src/Block/LayeredNavigation/Navigation/State.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?php

/**
* @author : Edwin Jacobs, email: ejacobs@emico.nl.
* @copyright : Copyright Emico B.V. 2020.
*/

namespace Emico\Tweakwise\Block\LayeredNavigation\Navigation;

use Emico\Tweakwise\Model\Catalog\Layer\Filter\Item;
use Emico\Tweakwise\Model\Client\Request\ProductSearchRequest;
use Emico\Tweakwise\Model\Client\Type\FacetType\SettingsType;
use Emico\Tweakwise\Model\Config;
use Emico\Tweakwise\Model\Catalog\Layer\Url;
use Emico\Tweakwise\Model\Catalog\Layer\NavigationContext\CurrentContext;
use Magento\Catalog\Model\Layer\Resolver;
use Magento\Framework\View\Element\Template\Context;
use Magento\LayeredNavigation\Block\Navigation\State as MagentoStateBlock;

class State extends MagentoStateBlock
{
/**
* @var Config
*/
protected $config;

/**
* @var Url
*/
protected $url;

/**
* State constructor.
* @param Context $context
* @param Resolver $layerResolver
* @param Config $config
* @param Url $url
* @param CurrentContext $currentContext
* @param array $data
*/
public function __construct(
Context $context,
Resolver $layerResolver,
Config $config,
Url $url,
CurrentContext $currentContext,
array $data = []
) {
parent::__construct(
$context,
$layerResolver,
$data
);

$this->config = $config;
$this->url = $url;
$this->updateTemplate($currentContext);
}

/**
* Use our template if applicable
* If you want to change this behaviour use a plugin on afterGetTemplate
*
* @param CurrentContext $currentContext
*/
protected function updateTemplate(CurrentContext $currentContext)
{
if ($this->config->getUseDefaultLinkRenderer()) {
return;
}

$searchEnabled = $this->config->isSearchEnabled();
$navigationEnabled = $this->config->isLayeredEnabled();

$isSearch = $currentContext->getRequest() instanceof ProductSearchRequest;
$isNavigation = !$isSearch;

if ($isSearch && $searchEnabled) {
$this->_template = 'Emico_Tweakwise::layer/state.phtml';
}

if ($isNavigation && $navigationEnabled) {
$this->_template = 'Emico_Tweakwise::layer/state.phtml';
}
}

/**
* @return string
*/
public function getClearUrl()
{
if (!$this->config->isLayeredEnabled()) {
return parent::getClearUrl();
}

return $this->url->getClearUrl($this->getActiveFilters());
}

/**
* @param Item $item
* @return string|void
*/
public function getActiveFilterCssId(Item $item)
{
$facetSettings = $item->getFilter()->getFacet()->getFacetSettings();
if ($facetSettings->getSelectionType() === SettingsType::SELECTION_TYPE_SLIDER) {
return 'slider-' . $facetSettings->getUrlKey();
}

return spl_object_hash($item);
}
}
49 changes: 0 additions & 49 deletions src/Block/LayeredNavigation/Navigation/State/Plugin.php

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

namespace Emico\Tweakwise\Block\LayeredNavigation\RenderLayered;

use Emico\Tweakwise\Model\Seo\FilterHelper;
use Emico\Tweakwise\Model\Catalog\Layer\Filter\Item;
use Emico\Tweakwise\Model\Seo\FilterHelper;

trait AnchorRendererTrait
{
Expand Down Expand Up @@ -52,4 +52,4 @@ protected function getItemUrl(Item $item)
{
return $this->escapeHtml($item->getUrl());
}
}
}
Loading

0 comments on commit 9df433c

Please sign in to comment.