Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

[FEATURE] Added addon prices to products api #335

Merged
merged 3 commits into from
Nov 4, 2016

Conversation

turbo-ele
Copy link
Contributor

@turbo-ele turbo-ele commented Nov 3, 2016

Q A
Bug fix? no
New feature? yes
BC breaks? yes
Deprecations? no
Fixed tickets none
Related issues/PRs none
License MIT

What's in this PR?

In this PR, addon-prices are introduced to products api. Before this PR you were able to define prices for Product-Addon relations but could not derive them through an API call.

Example Usage

yourdomain.com/admin/api/products/id

...
addons: [
    {
    ...
        addonPrices: [
            {
                id: 1
                currency: {
                    id: 2
                    name: "Euro"
                    number: "978"
                    code: "EUR"
                },
                price: 11
                priceFormatted: "11,00"
            }
        ]
    }
]

BC Breaks/Deprecations

  1. ProductFactoryInterface was extended by a new function createAddonProductApiEntity
  2. ApiProduct now needs a ProductFactory to be passed to the constructor.

@turbo-ele turbo-ele force-pushed the feature/product-addon-prices branch 2 times, most recently from 6cf6af2 to 27712e6 Compare November 3, 2016 14:39
Copy link
Member

@wachterjohannes wachterjohannes left a comment

Choose a reason for hiding this comment

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

Tests failing

* @param string $locale
* @param PriceFormatter $priceFormatter
*/
public function __construct(
Copy link
Member

Choose a reason for hiding this comment

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

should fit into a single line

);
$apiAddon->setAddonPrices(iterator_to_array($addon->getAddonPrices()));
Copy link
Member

Choose a reason for hiding this comment

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

why not passing to to the function call? maybe with default value?

/**
* {@inheritdoc}
*/
public function createAddonProductApiEntity(ProductInterface $product, $locale)
Copy link
Member

Choose a reason for hiding this comment

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

add prices with default value[]. and to the constructor.

/**
* {@inheritdoc}
*/
public function setAddonPrices(array $addonPrices)
Copy link
Member

Choose a reason for hiding this comment

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

add this to the constructor and remove this function.

@wachterjohannes wachterjohannes merged commit 745a538 into develop Nov 4, 2016
@wachterjohannes wachterjohannes deleted the feature/product-addon-prices branch November 4, 2016 12:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants