-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix order number generation #1560
Conversation
You need to update local config after V3 update. |
Ahah, yes you're right... |
OK tests are passing locally. Should be merged asap. |
Tests pass because order is flushed more then once. Try to load fixtures and you will see that order number is null. |
@umpirsky I don't have the same results at all. I tried with my old data set and with a fresh fixtures load: it's always the same. I see only 1 flush and order number is well generated when using |
@winzou So, after ? |
Aah, I didn't understand you were talking about the fixtures data itself. This is because fixtures are out-dated: it uses |
@winzou OK, now move flush out of for loop and try to load fixtures. --- a/src/Sylius/Bundle/FixturesBundle/DataFixtures/ORM/LoadOrdersData.php
+++ b/src/Sylius/Bundle/FixturesBundle/DataFixtures/ORM/LoadOrdersData.php
@@ -67,8 +68,9 @@ class LoadOrdersData extends DataFixture
$this->setReference('Sylius.Order-'.$i, $order);
$manager->persist($order);
- $manager->flush();
}
+
+ $manager->flush();
}
|
It seems that the NumberListener is not supporting when you flush several enabled entities of the same sequenceType at the same time :) |
Good, and now change: --- a/src/Sylius/Bundle/FixturesBundle/DataFixtures/ORM/LoadOrdersData.php
+++ b/src/Sylius/Bundle/FixturesBundle/DataFixtures/ORM/LoadOrdersData.php
@@ -33,7 +34,7 @@ class LoadOrdersData extends DataFixture
$orderRepository = $this->getOrderRepository();
$orderItemRepository = $this->getOrderItemRepository();
- for ($i = 1; $i <= 50; $i++) {
+ for ($i = 1; $i <= 1; $i++) { and try to load fixtures. |
Guys, maybe stop depending on flush, and try to depend on persist? i.e. |
@umpirsky ahah interesting! So I have:
I would say that we don't care about fixtures, the normal way is the manual checkout which is good with this PR. If there is a problem in the fixtures, we should fix them and not the whole way numbers are generated. @stloyd we use flush because we need transaction here (if order creation fails, no number should be taken). |
@winzou The problem is that number is generated on flush, but it is not flushed to database until next flush. Order is flushed several times during checkout and that's why your scenario is green, just a lucky coincidence. I fixed this with preFlush. Please put back preFlush now and you will see that fixtures will work. |
@umpirsky fixed everything :) |
OK, thanks @winzou. I can't wait to see it merged and test it for Taxon number in my project. |
Plus, this should work faster. |
Fix order number generation
Thank you guys! I like how Sequence works. |
Thanks @umpirsky for having found this tricky and unpredictable issue ;) |
Tricky in deed! |
@pjedrzejewski When will this be available in https://github.com/Sylius/SyliusSequenceBundle? |
Script should run soonish. |
@umpirsky what about your taxon numbers? |
@winzou I must avoid using NumberListener because number is incremented by number of taxons because onFlufh is triggered as many times as count of taxons in database. Probably because of its hierarchical structure. |
Uhm I don't get your point. You can call the listener as many time as you want on the same entity, the first pass will fill in |
@winzou LooooooooooooooooooooooL: public function getNumber()
{
$this->number;
} |
And add a scenario to cover it.
Haven't tested the scenario because I have issue running behat here:
I have updated vendors, do you guys have the same error?