-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc3b5f7
commit 25eb7ba
Showing
4 changed files
with
84 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
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
42 changes: 42 additions & 0 deletions
42
...lugin/ProductPageSearch/Elasticsearch/ProductAbstractMap/StyleUniqueMapExpanderPlugin.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,42 @@ | ||
<?php | ||
|
||
namespace FondOfSpryker\Zed\ProductPageSearchExpander\Communication\Plugin\ProductPageSearch\Elasticsearch\ProductAbstractMap; | ||
|
||
use FondOfSpryker\Shared\ProductPageSearchExpander\ProductPageSearchExpanderConstants; | ||
use Generated\Shared\Transfer\LocaleTransfer; | ||
use Generated\Shared\Transfer\PageMapTransfer; | ||
use Spryker\Zed\Kernel\Communication\AbstractPlugin; | ||
use Spryker\Zed\ProductPageSearchExtension\Dependency\PageMapBuilderInterface; | ||
use Spryker\Zed\ProductPageSearchExtension\Dependency\Plugin\ProductAbstractMapExpanderPluginInterface; | ||
|
||
/** | ||
* @method \FondOfSpryker\Zed\ProductPageSearchExpander\Communication\ProductPageSearchExpanderCommunicationFactory getFactory() | ||
*/ | ||
class StyleUniqueMapExpanderPlugin extends AbstractPlugin implements ProductAbstractMapExpanderPluginInterface | ||
{ | ||
/** | ||
* Specification: | ||
* - Expands and returns the provided PageMapTransfer objects data. | ||
* | ||
* @api | ||
* | ||
* @param \Generated\Shared\Transfer\PageMapTransfer $pageMapTransfer | ||
* @param \Spryker\Zed\ProductPageSearchExtension\Dependency\PageMapBuilderInterface $pageMapBuilder | ||
* @param array $productData | ||
* @param \Generated\Shared\Transfer\LocaleTransfer $localeTransfer | ||
* | ||
* @return \Generated\Shared\Transfer\PageMapTransfer | ||
*/ | ||
public function expandProductMap( | ||
PageMapTransfer $pageMapTransfer, | ||
PageMapBuilderInterface $pageMapBuilder, | ||
array $productData, | ||
LocaleTransfer $localeTransfer | ||
): PageMapTransfer { | ||
if (isset($productData[ProductPageSearchExpanderConstants::STYLE_UNIQUE])) { | ||
$pageMapTransfer->setStyleKey($productData[ProductPageSearchExpanderConstants::STYLE_UNIQUE]); | ||
} | ||
|
||
return $pageMapTransfer; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
.../Plugin/ProductPageSearch/Elasticsearch/ProductPageData/StyleUniqueDataExpanderPlugin.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,40 @@ | ||
<?php | ||
|
||
namespace FondOfSpryker\Zed\ProductPageSearchExpander\Communication\Plugin\ProductPageSearch\Elasticsearch\ProductPageData; | ||
|
||
use FondOfSpryker\Shared\ProductPageSearchExpander\ProductPageSearchExpanderConstants; | ||
use Generated\Shared\Transfer\ProductPageSearchTransfer; | ||
use Spryker\Zed\Kernel\Communication\AbstractPlugin; | ||
use Spryker\Zed\ProductPageSearch\Dependency\Plugin\ProductPageDataExpanderInterface; | ||
|
||
/** | ||
* @method \FondOfSpryker\Zed\ProductPageSearchExpander\Communication\ProductPageSearchExpanderCommunicationFactory getFactory() | ||
*/ | ||
class StyleUniqueDataExpanderPlugin extends AbstractPlugin implements ProductPageDataExpanderInterface | ||
{ | ||
/** | ||
* Specification: | ||
* - Expands the provided ProductAbstractPageSearch transfer object's data by reference. | ||
* | ||
* @api | ||
* | ||
* @param array $productData | ||
* @param \Generated\Shared\Transfer\ProductPageSearchTransfer $productAbstractPageSearchTransfer | ||
* | ||
* @return void | ||
*/ | ||
public function expandProductPageData( | ||
array $productData, | ||
ProductPageSearchTransfer $productAbstractPageSearchTransfer | ||
): void { | ||
if (!isset($productData[ProductPageSearchExpanderConstants::PRODUCT_ATTRIBUTES])) { | ||
return; | ||
} | ||
|
||
$productAttributes = json_decode($productData[ProductPageSearchExpanderConstants::PRODUCT_ATTRIBUTES], true); | ||
|
||
if (array_key_exists(ProductPageSearchExpanderConstants::STYLE_UNIQUE, $productAttributes)) { | ||
$productAbstractPageSearchTransfer->setStyleKey($productAttributes[ProductPageSearchExpanderConstants::STYLE_UNIQUE]); | ||
} | ||
} | ||
} |