Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search across all active variant prices #229

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -339,18 +339,25 @@ $ bin/console debug:container --parameters | grep bitbag

## Testing
```bash
$ composer install
$ cd tests/Application
$ APP_ENV=test bin/console doctrine:database:create
$ APP_ENV=test bin/console doctrine:schema:create
// run elasticsearch
$ APP_ENV=test bin/console sylius:fixtures:load
$ APP_ENV=test bin/console fos:elastica:populate
$ APP_ENV=test symfony server:run 127.0.0.1:8080 -d
$ APP_ENV=test bin/console assets:install
$ open http://localhost:8080
$ vendor/bin/behat
$ vendor/bin/phpspec run
composer install
cd tests/Application
APP_ENV=test bin/console doctrine:database:create
APP_ENV=test bin/console doctrine:schema:create
# run elasticsearch
APP_ENV=test bin/console sylius:fixtures:load
APP_ENV=test bin/console fos:elastica:populate
# How to get symfony CLI https://symfony.com/download
# To get working https use `symfony server:ca:install`
APP_ENV=test symfony server:start --port=8080 --dir=public --daemon
APP_ENV=test bin/console assets:install public
# copy config of your choice tests/Application/package.json.~X.Y.Z.dist as tests/Application/package.json
yarn install
yarn encore production
open https://localhost:8080
cd ../..
APP_ENV=test vendor/bin/behat
vendor/bin/phpspec run

```

# About us
Expand Down
18 changes: 15 additions & 3 deletions src/PropertyBuilder/ChannelPricingBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,31 @@
return;
}

/** @var array<string, array<int>> $pricesPerChannel */
$pricesPerChannel = [];

/** @var ProductVariantInterface $productVariant */
$productVariant = $product->getVariants()->first();
foreach ($product->getVariants() as $productVariant) {
foreach ($productVariant->getChannelPricings() as $variantChannelPricing) {
$channelCode = $variantChannelPricing->getChannelCode();
if (null === $channelCode) {
continue;
}
$elasticFieldName = $this->channelPricingNameResolver->resolvePropertyName($channelCode);
$channelPrice = $variantChannelPricing->getPrice();

foreach ($productVariant->getChannelPricings() as $channelPricing) {
/** @var string $channelCode */
$channelCode = $channelPricing->getChannelCode();

$propertyName = $this->channelPricingNameResolver
->resolvePropertyName($channelCode);

$document->set($propertyName, $channelPricing->getPrice());
}

foreach ($pricesPerChannel as $elasticFieldName => $channelVariantPrices) {
$document->set($elasticFieldName, array_values(array_unique($channelVariantPrices)));
}
}
);

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^5.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^5.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^6.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.13, PHP 8.1, Symfony ^6.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.13, PHP 8.1, Symfony ^5.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.13, PHP 8.1, Symfony ^5.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.2, Symfony ^5.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.13, PHP 8.1, Symfony ^6.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.1, Symfony ^6.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.2, Symfony ^5.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.2, Symfony ^6.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.2, Symfony ^6.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.13, PHP 8.2, Symfony ^6.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.13, PHP 8.2, Symfony ^5.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.3, Symfony ^5.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.13, PHP 8.3, Symfony ^5.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.13, PHP 8.2, Symfony ^5.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.13, PHP 8.2, Symfony ^6.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.13, PHP 8.3, Symfony ^5.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.3, Symfony ^6.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.3, Symfony ^6.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.12, PHP 8.3, Symfony ^5.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.13, PHP 8.3, Symfony ^6.4

Syntax error, unexpected ')' on line 63

Check failure on line 63 in src/PropertyBuilder/ChannelPricingBuilder.php

View workflow job for this annotation

GitHub Actions / Sylius ^1.13, PHP 8.3, Symfony ^6.4

Syntax error, unexpected ')' on line 63
}
}
Loading