Commit b775e801 by dhn

分层导航,sku排序

parent 2f6ca11c
......@@ -63,7 +63,6 @@ class SearchResultApplier implements SearchResultApplierInterface
return;
}
$items = $this->sliceItems($this->searchResult->getItems(), $this->size, $this->currentPage);
$ids = [];
foreach ($items as $item) {
......@@ -74,17 +73,55 @@ class SearchResultApplier implements SearchResultApplierInterface
->reset(\Magento\Framework\DB\Select::ORDER);
$sortOrder = $this->searchResult->getSearchCriteria()
->getSortOrders();
$skus = [];
if(isset($_GET['skus']) && !empty($_GET['skus']))
{
$skus = explode(',', $_GET['skus']);
$this->collection->getSelect()->orWhere("e.sku in ('" . implode("','",$skus)."')");
}
if (!empty($sortOrder['price']) && $this->collection->getLimitationFilters()->isUsingPriceIndex()) {
$sortDirection = $sortOrder['price'];
$this->collection->getSelect()
->order(
new \Zend_Db_Expr("price_index.min_price = 0, price_index.min_price {$sortDirection}")
);
if(empty($skus))
{
$this->collection->getSelect()
->order(
new \Zend_Db_Expr("price_index.min_price = 0, price_index.min_price {$sortDirection}")
);
}
else
{
foreach($skus as $sku)
{
$this->collection->getSelect()
->order(new \Zend_Db_Expr('e.sku = "'.$sku.'" desc'));
}
$this->collection->getSelect()
->order(
new \Zend_Db_Expr("price_index.min_price = 0, price_index.min_price {$sortDirection}")
);
}
} else {
$orderList = join(',', $ids);
$this->collection->getSelect()
->order(new \Zend_Db_Expr("FIELD(e.entity_id,$orderList)"));
if(empty($skus))
{
$this->collection->getSelect()
->order(new \Zend_Db_Expr("FIELD(e.entity_id,$orderList)"));
}
else
{
foreach($skus as $sku)
{
$this->collection->getSelect()
->order(new \Zend_Db_Expr('e.sku = "'.$sku.'" desc'));
}
$this->collection->getSelect()->order(new \Zend_Db_Expr("FIELD(e.entity_id,$orderList)"));
}
}
$this->collection->getSelect()->limit($this->size);
}
/**
......
......@@ -25,8 +25,14 @@
$isExpanded = false;
}
?>
<style>
.page-head-zindex
{
z-index:5!important;
}
<div class="block filter" data-mage-init='{"slideout":{"toggler":".filter-title","panel":".filter-content"}}'>
</style>
<div class="block filter" data-mage-init='{"slideout":{"toggler":".filter-title","panel":".filter-content"}}' data-breeze-processed="true">
<div class="block-title filter-title" tabindex="0">
<strong><?= $block->escapeHtml(__('Shop By')) ?></strong>
<?php if ($activeFilters) : ?>
......@@ -35,6 +41,7 @@
</div>
<div class="block-content filter-content">
<button class="button-close filter-content-close"></button>
<?= $block->getChildHtml('state') ?>
<?php if ($activeFilters) : ?>
......@@ -61,3 +68,24 @@
<?php endif; ?>
</div>
</div>
<script>
require([
'jquery'
], function ($) {
//footer
$(".filter-title").click(function () {
var isMobile = window.matchMedia("(pointer:coarse)").matches;
if (isMobile) {
$('.filter').addClass('active');
$('body').css({'overflow':'hidden','box-sizing':'border-box','padding-right':'0px'});
$('.page-header').addClass('page-head-zindex');
$('.filter-content-close').click(function () {
$('.filter').removeClass('active');
$('body').removeAttr("style");
$('.page-header').removeClass('page-head-zindex');
});
}
});
});
</script>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment