Commit a32673c3 by 王东红

fix

parent 18b9d8b6
<?php
namespace JTool\toolbar\Plugin\Catalog\Block;
class Toolbar
{
public function aroundSetCollection(\Magento\Catalog\Block\Product\ProductList\Toolbar $subject,
\Closure $proceed, $collection)
{
//ordered_qty
$currentOrder = $subject->getCurrentOrder();
$this->_collection = $collection;
$result = $proceed($collection);
if($currentOrder)
{
if($currentOrder == 'high_to_low')
{
$subject->getCollection()->setOrder('price', 'desc');
}
elseif ($currentOrder == 'low_to_high')
{
$subject->getCollection()->setOrder('price', 'asc');
}
elseif ($currentOrder == 'new_arrivals')
{
$this->_collection->getSelect()->order('e.created_at DESC');
}
}
return $result;
}
}
\ No newline at end of file
<?php
namespace JTool\toolbar\Plugin\Catalog\Model;
class Config
{
public function afterGetAttributeUsedForSortByArray(\Magento\Catalog\Model\Config $catalogConfig, $options)
{
$options['new_arrivals'] = __('New Arrivals');
$options['low_to_high'] = __('Price Low To High');
$options['high_to_low'] = __('Price High To Low');
unset($options['price']);
return $options;
}
}
\ No newline at end of file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Catalog\Block\Product\ProductList\Toolbar">
<plugin name="custom_custom_block_toolbar" type="JTool\toolbar\Plugin\Catalog\Block\Toolbar"/>
</type>
<type name="Magento\Catalog\Model\Config">
<plugin name="custom_catalog_model_config" type="JTool\toolbar\Plugin\Catalog\Model\Config"/>
</type>
</config>
\ No newline at end of file
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="JTool_toolbar" setup_version="1.0.0"/>
</config>
\ No newline at end of file
<?php
\Magento\Framework\Component\ComponentRegistrar::register(\Magento\Framework\Component\ComponentRegistrar::MODULE,
'JTool_toolbar',
__DIR__
);
\ No newline at end of file
......@@ -577,12 +577,12 @@ define([
// Color
html += '<div class="' + optionClass + ' color" ' + attr +
' style="background: ' + value +
' no-repeat center; background-size: initial;">' + '' +
' no-repeat center; background-size: cover;">' + '' +
'</div>';
} else if (type === 2) {
// Image
html += '<div class="' + optionClass + ' image" ' + attr +
' style="background: url(' + value + ') no-repeat center; background-size: initial;width:' +
' style="background: url(' + value + ') no-repeat center; background-size: cover;width:' +
swatchImageWidth + 'px; height:' + swatchImageHeight + 'px">' + '' +
'</div>';
} else if (type === 3) {
......
......@@ -95,6 +95,11 @@
<height>110</height>
</image>
<image id="swatch_image" type="swatch_image">
<width>40</width>
<height>50</height>
</image>
<!-- These lists use category_page_grid fallback. Not need to declare srcset for them -->
<image id="related_products_list" type="small_image">
<width>300</width>
......
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