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

added the export for orders #107

Merged
merged 8 commits into from
May 25, 2018

Conversation

enesaktay
Copy link
Contributor

#103 had unwanted commits in it so this is the same PR without the unwanted commits

Copy link
Collaborator

@mattagohni mattagohni left a comment

Choose a reason for hiding this comment

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

Thanks for this PR, seems to be very useful. I added some comments about minor changes, that would be cool.

- "@sylius.exporters_transformer_pool"
tags:
- { name: sylius.exporter, type: sylius.order, format: csv }

Copy link
Collaborator

Choose a reason for hiding this comment

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

Here is a blank line missing at the end of the file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For me at row 30 I have a blank line?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, I don't know what's then the problem there. Github does mention it.
bildschirmfoto 2018-05-25 um 10 48 45
Maybe there is some Whitespace in this line?

- "@sylius.exporters_transformer_pool"
tags:
- { name: sylius.exporter, type: sylius.order, format: xlsx }

Copy link
Collaborator

Choose a reason for hiding this comment

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

same here.

parent::init($idsToExport);

/** @var OrderInterface $resource */
foreach ($this->resources as $resource) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you refactor this foreach a bit, so it gets a bit smaller? I would recommend to move the contents of the different if-conditionals to private methods, that would make the code of this init-method a bit clearer to understand.

$items = [];

/** @var OrderItemInterface $orderItem */
foreach ($resource->getItems() as $orderItem) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also the following both foreach-loops could be relatively easy extracted to a private-method like 'addOrderItemInformation' or something like that, I think.

* @param PropertyAccessorInterface $propertyAccessor
* @param EntityManagerInterface $entityManager
*/
public function __construct(
Copy link
Collaborator

Choose a reason for hiding this comment

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

this looks redundant and covered by the parent constructor

@enesaktay
Copy link
Contributor Author

Thanks for the reviews and help, I did the requested changes.. its open for review again :)

/**
* @param OrderInterface $resource
*/
private function addCustomerData(OrderInterface $resource)
Copy link
Collaborator

Choose a reason for hiding this comment

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

bit nitpicking, but can you add a TypeHint for the retrun-value of all added private Methods?
e.g. private function addCustomerData(OrderInterface $resource): void

We should typeHint as much as we can... :-)

@enesaktay enesaktay mentioned this pull request May 25, 2018
@mattagohni mattagohni merged commit b8de255 into FriendsOfSylius:master May 25, 2018
$items[$product->getName()] = 0;
}

$items[$product->getName()] += $orderItem->getQuantity();
Copy link
Member

Choose a reason for hiding this comment

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

How does this with products with the same name but not the same product ID? Basically different product, but the count on the name gets upped.

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah .. this is risky .. should use something unique for the key

Copy link
Collaborator

@mattagohni mattagohni May 28, 2018

Choose a reason for hiding this comment

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

Since I already merged this, I think we should open an issue for that. I have totally overseen this..

if (null !== $shippingAddress) {
$this->addDataForResource($resource, 'Shipping_address', sprintf(
'%s, %s, %s, %s, %s',
$shippingAddress->getFullName() ? $shippingAddress->getFullName() : '',
Copy link
Member

Choose a reason for hiding this comment

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

Can't we use ?? here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am not sure if anything is even needed here .. I assume the return value is either a string or null and then it will just silently get cast to an empty string.

Copy link
Member

Choose a reason for hiding this comment

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

@enesaktay is this something we can make easier to read/use?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@stefandoorn could potentially remove the ternary operators since with row 58 we are already checking if shippingadress exists
other than that i could also put sprintf inside another method since it is used 2 times in this class

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, might be worth trying if we need the operator at all as the methods probably return useful information anyway..

private function addShippingAddressData(OrderInterface $resource): void
{
$shippingAddress = $resource->getShippingAddress();
if (null !== $shippingAddress) {
Copy link
Member

Choose a reason for hiding this comment

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

What about early returns? if (null !== $shippingAddress) { return; }

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1 for return early

@stefandoorn
Copy link
Member

I moved some comments to separate issues with cc to @enesaktay.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants