This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 91
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 #263 from DivanteLtd/develop
Merge develop to master.
- Loading branch information
Showing
26 changed files
with
958 additions
and
16 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
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
61 changes: 61 additions & 0 deletions
61
src/module-vsbridge-downloadable/Index/Mapping/Product/DownloadableOptionsMapping.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,61 @@ | ||
<?php | ||
/** | ||
* Copyright Divante Sp. z o.o. | ||
* See LICENSE_DIVANTE.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Divante\VsbridgeDownloadable\Index\Mapping\Product; | ||
|
||
use Divante\VsbridgeIndexerCatalog\Index\Mapping\FieldMappingInterface; | ||
use Divante\VsbridgeIndexerCore\Api\Mapping\FieldInterface; | ||
|
||
/** | ||
* Class DownloadableOptionsMapping | ||
*/ | ||
class DownloadableOptionsMapping implements FieldMappingInterface | ||
{ | ||
/** | ||
* @return array | ||
*/ | ||
public function get(): array | ||
{ | ||
return [ | ||
'properties' => [ | ||
'extension_attributes' => [ | ||
'properties' => [ | ||
'downloadable_product_links' => [ | ||
'properties' => [ | ||
'id' => ['type' => FieldInterface::TYPE_LONG], | ||
'product_id' => ['type' => FieldInterface::TYPE_LONG], | ||
'sort_order' => ['type' => FieldInterface::TYPE_INTEGER], | ||
'number_of_downloads' => ['type' => FieldInterface::TYPE_LONG], | ||
'is_shareable' => ['type' => FieldInterface::TYPE_INTEGER], | ||
'link_url' => ['type' => FieldInterface::TYPE_TEXT], | ||
'link_file' => ['type' => FieldInterface::TYPE_TEXT], | ||
'link_type' => ['type' => FieldInterface::TYPE_KEYWORD], | ||
'sample_url' => ['type' => FieldInterface::TYPE_TEXT], | ||
'sample_file' => ['type' => FieldInterface::TYPE_TEXT], | ||
'sample_type' => ['type' => FieldInterface::TYPE_KEYWORD], | ||
'title' => ['type' => FieldInterface::TYPE_TEXT], | ||
'price' => ['type' => FieldInterface::TYPE_DOUBLE], | ||
], | ||
], | ||
'downloadable_product_samples' => [ | ||
'properties' => [ | ||
'id' => ['type' => FieldInterface::TYPE_LONG], | ||
'product_id' => ['type' => FieldInterface::TYPE_LONG], | ||
'sample_url' => ['type' => FieldInterface::TYPE_TEXT], | ||
'sample_file' => ['type' => FieldInterface::TYPE_TEXT], | ||
'sample_type' => ['type' => FieldInterface::TYPE_KEYWORD], | ||
'sort_order' => ['type' => FieldInterface::TYPE_INTEGER], | ||
'title' => ['type' => FieldInterface::TYPE_TEXT], | ||
], | ||
] | ||
], | ||
], | ||
], | ||
]; | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
src/module-vsbridge-downloadable/Model/Indexer/DataProvider/Product/DownloadableData.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,69 @@ | ||
<?php | ||
/** | ||
* Copyright Divante Sp. z o.o. | ||
* See LICENSE_DIVANTE.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Divante\VsbridgeDownloadable\Model\Indexer\DataProvider\Product; | ||
|
||
use Divante\VsbridgeIndexerCore\Api\DataProviderInterface; | ||
use Divante\VsbridgeDownloadable\Model\ResourceModel\Product\Downloadable as DownloadableResource; | ||
|
||
/** | ||
* Class DownloadableData | ||
*/ | ||
class DownloadableData implements DataProviderInterface | ||
{ | ||
/** | ||
* @const string | ||
*/ | ||
const EXTENSION_ATTRIBUTES = 'extension_attributes'; | ||
|
||
/** | ||
* @const string | ||
*/ | ||
const LINKS_FIELD_NAME = 'downloadable_product_links'; | ||
|
||
/** | ||
* @const string | ||
*/ | ||
const SAMPLES_FIELD_NAME = 'downloadable_product_samples'; | ||
|
||
/** | ||
* @var DownloadableResource | ||
*/ | ||
private $downloadableResource; | ||
|
||
/** | ||
* DownloadableData constructor. | ||
* | ||
* @param DownloadableResource $downloadableResource | ||
*/ | ||
public function __construct(DownloadableResource $downloadableResource) | ||
{ | ||
$this->downloadableResource = $downloadableResource; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function addData(array $indexData, $storeId) | ||
{ | ||
$this->downloadableResource->setProducts($indexData); | ||
|
||
$groupedLinks = $this->downloadableResource->getDownloadableLinksByProductId($storeId); | ||
$groupedSamples = $this->downloadableResource->getDownloadableSamplesByProductId($storeId); | ||
|
||
foreach ($groupedLinks as $productId => $productLinks) { | ||
$indexData[$productId][self::EXTENSION_ATTRIBUTES][self::LINKS_FIELD_NAME] = $productLinks; | ||
} | ||
|
||
foreach ($groupedSamples as $productId => $productLinks) { | ||
$indexData[$productId][self::EXTENSION_ATTRIBUTES][self::SAMPLES_FIELD_NAME] = $productLinks; | ||
} | ||
|
||
return $indexData; | ||
} | ||
} |
Oops, something went wrong.