ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Olegnax\ProductSlider\Model\Config\Source;
|
||||
|
||||
|
||||
use Magento\Framework\Option\ArrayInterface;
|
||||
|
||||
class SortOrder implements ArrayInterface
|
||||
{
|
||||
public const FIELD_DEFAULT = '';
|
||||
public const FIELD_NAME = 'name';
|
||||
public const FIELD_PRICE_ASC = 'price_asc';
|
||||
public const FIELD_PRICE_DESC = 'price_desc';
|
||||
public const FIELD_CREATED = 'created_at';
|
||||
|
||||
public function toOptionArray()
|
||||
{
|
||||
$optionArray = [];
|
||||
$array = $this->toArray();
|
||||
foreach ($array as $key => $value) {
|
||||
$optionArray[] = ['value' => $key, 'label' => $value];
|
||||
}
|
||||
|
||||
return $optionArray;
|
||||
}
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
return [
|
||||
self::FIELD_DEFAULT => __('Default'),
|
||||
self::FIELD_NAME => __('Name'),
|
||||
self::FIELD_PRICE_ASC => __('Price: high to low'),
|
||||
self::FIELD_PRICE_DESC => __('Price: low to high'),
|
||||
self::FIELD_CREATED => __('Created'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Olegnax\ProductSlider\Model\Config\Source;
|
||||
|
||||
|
||||
class SortOrderCat extends \Olegnax\ProductSlider\Model\Config\Source\SortOrder
|
||||
{
|
||||
public const FIELD_POSITION = 'position';
|
||||
|
||||
public function toArray()
|
||||
{
|
||||
$data = parent::toArray();
|
||||
$data[self::FIELD_POSITION] = __('Position');
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Olegnax
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Olegnax.com license that is
|
||||
* available through the world-wide-web at this URL:
|
||||
* https://www.olegnax.com/license
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade this extension to newer
|
||||
* version in the future.
|
||||
*
|
||||
* @category Olegnax
|
||||
* @package Olegnax_ProductSlider
|
||||
* @copyright Copyright (c) 2023 Olegnax (http://www.olegnax.com/)
|
||||
* @license https://www.olegnax.com/license
|
||||
*/
|
||||
|
||||
namespace Olegnax\ProductSlider\Model\ResourceModel\Report\Product;
|
||||
|
||||
class Collection extends \Magento\Reports\Model\ResourceModel\Product\Collection
|
||||
{
|
||||
|
||||
/**
|
||||
* Add views count.
|
||||
*
|
||||
* @param string $from
|
||||
* @param string $to
|
||||
* @return \Magento\Reports\Model\ResourceModel\Product\Collection
|
||||
*/
|
||||
public function addViewsCount($from = '', $to = '')
|
||||
{
|
||||
/**
|
||||
* Getting event type id for catalog_product_view event
|
||||
*/
|
||||
$eventTypes = $this->_eventTypeFactory->create()->getCollection();
|
||||
foreach ($eventTypes as $eventType) {
|
||||
if ($eventType->getEventName() == 'catalog_product_view') {
|
||||
$productViewEvent = (int)$eventType->getId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->getSelect()->reset()->from(
|
||||
['report_table_views' => $this->getTable('report_event')],
|
||||
['views' => 'COUNT(report_table_views.event_id)']
|
||||
)->join(
|
||||
['e' => $this->getProductEntityTableName()],
|
||||
'e.entity_id = report_table_views.object_id'
|
||||
)->where(
|
||||
'report_table_views.event_type_id = ?',
|
||||
$productViewEvent
|
||||
)->group(
|
||||
'e.entity_id'
|
||||
)->order(
|
||||
'views ' . self::SORT_ORDER_DESC
|
||||
)->having(
|
||||
'COUNT(report_table_views.event_id) > ?',
|
||||
0
|
||||
);
|
||||
|
||||
if ($from != '' && $to != '') {
|
||||
$this->getSelect()->where('logged_at >= ?', $from)->where('logged_at <= ?', $to);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user