-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from tuyennn/feature/Smile-SA-compatibility
Feature/smile sa compatibility
- Loading branch information
Showing
6 changed files
with
96 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
name: Bug report | ||
about: Technical issue with the Module | ||
|
||
--- | ||
|
||
### Preconditions (*) | ||
<!--- | ||
Provide the exact Magento version (example: 2.2.5) and any important information on the environment where bug is reproducible. | ||
--> | ||
1. | ||
2. | ||
|
||
### Steps to reproduce (*) | ||
<!--- | ||
Important: Provide a set of clear steps to reproduce this bug. We can not provide support without clear instructions on how to reproduce. | ||
--> | ||
1. | ||
2. | ||
|
||
### Expected result (*) | ||
<!--- Tell us what do you expect to happen. --> | ||
1. [Screenshots, logs or description] | ||
2. | ||
|
||
### Actual result (*) | ||
<!--- Tell us what happened instead. Include error messages and issues. --> | ||
1. [Screenshots, logs or description] | ||
2. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
Plugin/Model/Product/Indexer/Fulltext/Datasource/AttributeDataPlugin.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace GhoSter\OutOfStockAtLast\Plugin\Model\Product\Indexer\Fulltext\Datasource; | ||
|
||
use GhoSter\OutOfStockAtLast\Model\Elasticsearch\Adapter\DataMapper\Stock as StockDataMapper; | ||
use GhoSter\OutOfStockAtLast\Model\ResourceModel\Inventory; | ||
use Magento\Framework\Exception\NoSuchEntityException; | ||
|
||
class AttributeDataPlugin | ||
{ | ||
/** | ||
* @var StockDataMapper | ||
*/ | ||
protected $stockDataMapper; | ||
|
||
/** | ||
* @var Inventory | ||
*/ | ||
protected $inventory; | ||
|
||
/** | ||
* AttributeDataPlugin constructor. | ||
* @param StockDataMapper $stockDataMapper | ||
* @param Inventory $inventory | ||
*/ | ||
public function __construct(StockDataMapper $stockDataMapper, Inventory $inventory) | ||
{ | ||
$this->stockDataMapper = $stockDataMapper; | ||
$this->inventory = $inventory; | ||
} | ||
|
||
/** | ||
* @param $subject | ||
* @param array $result | ||
* @param $storeId | ||
* @param array $indexData | ||
* @return array | ||
* @throws NoSuchEntityException | ||
*/ | ||
public function afterAddData( | ||
$subject, | ||
array $result, | ||
$storeId, | ||
array $indexData | ||
): array { | ||
$this->inventory->saveRelation(array_keys($indexData)); | ||
foreach ($result as $productId => $item) { | ||
//@codingStandardsIgnoreLine | ||
$item = array_merge($item, $this->stockDataMapper->map($productId, $storeId)); | ||
$result[$productId] = $item; | ||
} | ||
$this->inventory->clearRelation(); | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
<?xml version="1.0"?> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | ||
<type name="Magento\Catalog\Model\ResourceModel\Product\Collection"> | ||
<plugin name="GhoSter_OutOfStockAtLast::SortingMethodsProcessor" type="GhoSter\OutOfStockAtLast\Plugin\Model\ResourceModel\Product\CollectionPlugin"/> | ||
<plugin sortOrder="10" name="GhoSter_OutOfStockAtLast::process_sort_collection" | ||
type="GhoSter\OutOfStockAtLast\Plugin\Model\ResourceModel\Product\CollectionPlugin"/> | ||
</type> | ||
</config> |