Commit b775e801 by dhn

分层导航,sku排序

parent 2f6ca11c
...@@ -63,7 +63,6 @@ class SearchResultApplier implements SearchResultApplierInterface ...@@ -63,7 +63,6 @@ class SearchResultApplier implements SearchResultApplierInterface
return; return;
} }
$items = $this->sliceItems($this->searchResult->getItems(), $this->size, $this->currentPage); $items = $this->sliceItems($this->searchResult->getItems(), $this->size, $this->currentPage);
$ids = []; $ids = [];
foreach ($items as $item) { foreach ($items as $item) {
...@@ -74,17 +73,55 @@ class SearchResultApplier implements SearchResultApplierInterface ...@@ -74,17 +73,55 @@ class SearchResultApplier implements SearchResultApplierInterface
->reset(\Magento\Framework\DB\Select::ORDER); ->reset(\Magento\Framework\DB\Select::ORDER);
$sortOrder = $this->searchResult->getSearchCriteria() $sortOrder = $this->searchResult->getSearchCriteria()
->getSortOrders(); ->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()) { if (!empty($sortOrder['price']) && $this->collection->getLimitationFilters()->isUsingPriceIndex()) {
$sortDirection = $sortOrder['price']; $sortDirection = $sortOrder['price'];
$this->collection->getSelect() if(empty($skus))
->order( {
new \Zend_Db_Expr("price_index.min_price = 0, price_index.min_price {$sortDirection}") $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 { } else {
$orderList = join(',', $ids); $orderList = join(',', $ids);
$this->collection->getSelect() if(empty($skus))
->order(new \Zend_Db_Expr("FIELD(e.entity_id,$orderList)")); {
$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 @@ ...@@ -25,8 +25,14 @@
$isExpanded = false; $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"> <div class="block-title filter-title" tabindex="0">
<strong><?= $block->escapeHtml(__('Shop By')) ?></strong> <strong><?= $block->escapeHtml(__('Shop By')) ?></strong>
<?php if ($activeFilters) : ?> <?php if ($activeFilters) : ?>
...@@ -35,6 +41,7 @@ ...@@ -35,6 +41,7 @@
</div> </div>
<div class="block-content filter-content"> <div class="block-content filter-content">
<button class="button-close filter-content-close"></button>
<?= $block->getChildHtml('state') ?> <?= $block->getChildHtml('state') ?>
<?php if ($activeFilters) : ?> <?php if ($activeFilters) : ?>
...@@ -61,3 +68,24 @@ ...@@ -61,3 +68,24 @@
<?php endif; ?> <?php endif; ?>
</div> </div>
</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