Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #263 from DivanteLtd/develop
Browse files Browse the repository at this point in the history
Merge develop to master.
  • Loading branch information
afirlejczyk authored Apr 24, 2020
2 parents d9a22b9 + b186198 commit 3685526
Show file tree
Hide file tree
Showing 26 changed files with 958 additions and 16 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

### [1.16.0] (2020.20.24)

### Added
- Add option to export `parent_sku` for products ([#84](https://github.com/DivanteLtd/magento2-vsbridge-indexer/issues/84))
- Add `extension_attributes.downloadable_product_links` for downloadable products ([#142](https://github.com/DivanteLtd/magento2-vsbridge-indexer/issues/142))

## [1.15.1] (2020.04.14)

### Fixed
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ If you won't do that, you will get error when running

- Install with composer
```json
composer config repositories.divante vcs https://github.com/DivanteLtd/magento2-vsbridge-indexer
composer require divante/magento2-vsbridge-indexer
```

Expand All @@ -38,7 +37,7 @@ php bin/magento setup:upgrade
## Installation/Getting Started - MSI support
- Install second module which will support MSI
```json
composer require divante/magento2-vsbridge-indexer-msi:0.1.0
composer require divante/magento2-vsbridge-indexer-msi
```
Not fully supported, few fields are exported to ES.
From inventory indexer:
Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,16 @@
"src/module-vsbridge-indexer-catalog/registration.php",
"src/module-vsbridge-indexer-cms/registration.php",
"src/module-vsbridge-indexer-review/registration.php",
"src/module-vsbridge-indexer-tax/registration.php"
"src/module-vsbridge-indexer-tax/registration.php",
"src/module-vsbridge-downloadable/registration.php"
],
"psr-4": {
"Divante\\VsbridgeIndexerCore\\": "src/module-vsbridge-indexer-core",
"Divante\\VsbridgeIndexerCatalog\\": "src/module-vsbridge-indexer-catalog",
"Divante\\VsbridgeIndexerCms\\": "src/module-vsbridge-indexer-cms",
"Divante\\VsbridgeIndexerReview\\": "src/module-vsbridge-indexer-review",
"Divante\\VsbridgeIndexerTax\\": "src/module-vsbridge-indexer-tax"
"Divante\\VsbridgeIndexerTax\\": "src/module-vsbridge-indexer-tax",
"Divante\\VsbridgeDownloadable\\": "src/module-vsbridge-downloadable"
}
},
"minimum-stability": "dev",
Expand Down
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],
],
]
],
],
],
];
}
}
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;
}
}
Loading

0 comments on commit 3685526

Please sign in to comment.