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

[API][Shop] Viewing only the enabled variants of a product #13863

Merged

Conversation

TheMilek
Copy link
Member

Q A
Branch? master
Bug fix? no
New feature? no
BC breaks? no
Deprecations? no
License MIT

We haven't got any API scenarios for seeing only enabled variants in shop

@TheMilek TheMilek requested a review from a team as a code owner April 12, 2022 12:04
@probot-autolabeler probot-autolabeler bot added the API APIs related issues and PRs. label Apr 12, 2022
Copy link
Contributor

@AdamKasp AdamKasp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should add/update contract test too 💯

src/Sylius/Behat/Context/Api/Shop/ProductContext.php Outdated Show resolved Hide resolved
src/Sylius/Behat/Context/Api/Shop/ProductContext.php Outdated Show resolved Hide resolved
src/Sylius/Behat/Context/Api/Shop/ProductContext.php Outdated Show resolved Hide resolved
src/Sylius/Behat/Context/Api/Shop/ProductContext.php Outdated Show resolved Hide resolved
src/Sylius/Behat/Context/Api/Shop/ProductContext.php Outdated Show resolved Hide resolved
src/Sylius/Behat/Context/Api/Shop/ProductContext.php Outdated Show resolved Hide resolved
src/Sylius/Behat/Context/Api/Shop/ProductContext.php Outdated Show resolved Hide resolved
src/Sylius/Behat/Context/Api/Shop/ProductContext.php Outdated Show resolved Hide resolved
@TheMilek TheMilek force-pushed the seeing-enabled-variants-of-a-product branch 5 times, most recently from c61110c to c899c74 Compare April 13, 2022 09:36
@TheMilek TheMilek added the Shop ShopBundle related issues and PRs. label Apr 13, 2022
@TheMilek TheMilek force-pushed the seeing-enabled-variants-of-a-product branch from c899c74 to 90d01dc Compare April 13, 2022 21:22
@probot-autolabeler probot-autolabeler bot added the Maintenance CI configurations, READMEs, releases, etc. label Apr 13, 2022
@TheMilek TheMilek force-pushed the seeing-enabled-variants-of-a-product branch from 90d01dc to 6355efc Compare April 13, 2022 21:30
@TheMilek TheMilek changed the title [WIP][API][Shop] Viewing only the enabled variants of a product [API][Shop] Viewing only the enabled variants of a product Apr 13, 2022
@TheMilek TheMilek force-pushed the seeing-enabled-variants-of-a-product branch from 6355efc to 2323962 Compare April 14, 2022 06:07
src/Sylius/Behat/Context/Api/Shop/ProductContext.php Outdated Show resolved Hide resolved
tests/Api/Admin/ProductTest.php Outdated Show resolved Hide resolved
tests/Api/Admin/ProductTest.php Outdated Show resolved Hide resolved
tests/Api/Shop/ProductsTest.php Outdated Show resolved Hide resolved
@TheMilek TheMilek force-pushed the seeing-enabled-variants-of-a-product branch from 2323962 to aabd3d0 Compare April 14, 2022 08:32
Comment on lines +47 to +48
$variantsIris = array_map(fn(ProductVariantInterface $variant): string => $this->iriConverter->getIriFromItem($variant), $object->getEnabledVariants()->toArray());
$data['variants'] = array_values($variantsIris);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be equivalent:

Suggested change
$variantsIris = array_map(fn(ProductVariantInterface $variant): string => $this->iriConverter->getIriFromItem($variant), $object->getEnabledVariants()->toArray());
$data['variants'] = array_values($variantsIris);
$data['variants'] = $object
->getEnabledVariants()
->map(fn(ProductVariantInterface $variant): string => $this->iriConverter->getIriFromItem($variant))
->getValues()
;

and seems to me to be more object-oriented and more readable

@lchrusciel lchrusciel merged commit 7bb5510 into Sylius:master Apr 14, 2022
@lchrusciel
Copy link
Member

Thank you, Kamil! 🥇

GSadee added a commit that referenced this pull request May 6, 2022
…duct fixes (TheMilek)

This PR was merged into the 1.12-dev branch.

Discussion
----------

| Q               | A
| --------------- | -----
| Branch?         | master <!-- see the comment below -->
| Bug fix?        | no
| New feature?    | no
| BC breaks?      | no
| Related tickets | fixes to [PR](#13863)
| License         | MIT

<!--
 - Bug fixes must be submitted against the 1.10 or 1.11 branch(the lowest possible)
 - Features and deprecations must be submitted against the master branch
 - Make sure that the correct base branch is set

 To be sure you are not breaking any Backward Compatibilities, check the documentation:
 https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->
This PR contains missing QueryItemExtension for ProductVariants that shows only enabled variants and corrects comments from [this](#13863) PR

Commits
-------

c864bb2 [API][Shop] viewing only enabled variants fixed
e366148 Upgrade API file updated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API APIs related issues and PRs. Maintenance CI configurations, READMEs, releases, etc. Shop ShopBundle related issues and PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants