{"action":"created","comment":{"url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/comments/72053870","id":72053870,"diff_hunk":"@@ -103,13 +109,34 @@ public function saveAll(array $products, array $options = [])\n         $itemOptions['flush'] = false;\n \n         foreach ($products as $product) {\n+            /*\n+            B.\n+            Here is where the save function is called multiple times for a batch when we use mass edit.\n+            The function save will dispatch post_save events without flushing the changes into the database.\n+\n+            If saveAll function would not base on save function, everything should work as I expect:\n+            - saveAll will flush every batch and dispatch the post_save_all event, which I am listening when I do imports\n+            or mass edits.\n+            - save will flush every time and dispatch the events with the correct change set.\n+            */\n             $this->save($product, $itemOptions);\n         }\n \n         if (true === $options['flush']) {\n             $this->objectManager->flush();\n         }\n-\n+        /*\n+         * C.\n+         * 1. If we listen for both post_save and post_save_all events all the events are duplicated right now.\n+         * - From post_save I have the event with a wrong change set.\n+         * - From post_save_all I have the correct event.","path":"src/Pim/Bundle/CatalogBundle/Doctrine/Common/Saver/ProductSaver.php","position":40,"original_position":40,"commit_id":"1c6e5ee2db2aad01fdcff99e1041cb9207b03b55","original_commit_id":"1c6e5ee2db2aad01fdcff99e1041cb9207b03b55","user":{"login":"nidup","id":2104359,"avatar_url":"https://avatars.githubusercontent.com/u/2104359?v=3","gravatar_id":"","url":"https://api.github.com/users/nidup","html_url":"https://github.com/nidup","followers_url":"https://api.github.com/users/nidup/followers","following_url":"https://api.github.com/users/nidup/following{/other_user}","gists_url":"https://api.github.com/users/nidup/gists{/gist_id}","starred_url":"https://api.github.com/users/nidup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nidup/subscriptions","organizations_url":"https://api.github.com/users/nidup/orgs","repos_url":"https://api.github.com/users/nidup/repos","events_url":"https://api.github.com/users/nidup/events{/privacy}","received_events_url":"https://api.github.com/users/nidup/received_events","type":"User","site_admin":false},"body":"Ok, no pb. I'd love to work with you on this topic, you can re-work your original community edition PR to match the new scenario, I'll help you with tests and running CI to be able to merge it quickly. About contribution on EE it will be a bit more complicated but we'll find a way to discuss through \"fake\" PR on CE or gist files.","created_at":"2016-07-25T12:22:14Z","updated_at":"2016-07-25T12:22:14Z","html_url":"https://github.com/akeneo/pim-community-dev/pull/4767#discussion_r72053870","pull_request_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/4767","_links":{"self":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/comments/72053870"},"html":{"href":"https://github.com/akeneo/pim-community-dev/pull/4767#discussion_r72053870"},"pull_request":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/4767"}}},"pull_request":{"url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/4767","id":78461324,"html_url":"https://github.com/akeneo/pim-community-dev/pull/4767","diff_url":"https://github.com/akeneo/pim-community-dev/pull/4767.diff","patch_url":"https://github.com/akeneo/pim-community-dev/pull/4767.patch","issue_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues/4767","number":4767,"state":"closed","locked":false,"title":"Example of eventstore events","user":{"login":"iulyanp","id":6533422,"avatar_url":"https://avatars.githubusercontent.com/u/6533422?v=3","gravatar_id":"","url":"https://api.github.com/users/iulyanp","html_url":"https://github.com/iulyanp","followers_url":"https://api.github.com/users/iulyanp/followers","following_url":"https://api.github.com/users/iulyanp/following{/other_user}","gists_url":"https://api.github.com/users/iulyanp/gists{/gist_id}","starred_url":"https://api.github.com/users/iulyanp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iulyanp/subscriptions","organizations_url":"https://api.github.com/users/iulyanp/orgs","repos_url":"https://api.github.com/users/iulyanp/repos","events_url":"https://api.github.com/users/iulyanp/events{/privacy}","received_events_url":"https://api.github.com/users/iulyanp/received_events","type":"User","site_admin":false},"body":"Hello @nidup \r\n\r\nThank you very much for your response.\r\nYes I'm talking about the versioning change set and yes we use data from the $event->getEventType() directly.\r\n\r\n- What is the format of the event you want to send? (paste sample json/xml please)\r\n\r\n     We use json. I pasted in some example.\r\n\r\n- Do you want to put only the updated product fields in this event or the whole product data?\r\n\r\n     We want to put all the product data + the change set.\r\n\r\n- How do you plan to build the content of this event in your listener/subscriber?\r\n\r\n     We use Normalizers to build the content of the events that we send to EventStore. We extended your Pim\\Bundle\\TransformBundle\\Normalizer\\Structured\\ProductNormalizer and perform some formatting on its response so we don't send data which is only important for PIM (like validation rules).\r\n\r\nI added some examples and comments in \"Pim\\Bundle\\CatalogBundle\\Doctrine\\Common\\Saver\\ProductSaver\" class A. B. and C.\r\nPlease let me know what do you think.\r\n\r\nThank you,\r\n\r\n| Q                                 | A\r\n| --------------------------------- | ---\r\n| Added Specs                       |\r\n| Added Behats                      |\r\n| Changelog updated                 |\r\n| Review and 2 GTM                  |\r\n| Micro Demo to the PO (Story only) |\r\n| Migration script                  |\r\n| Tech Doc                          |\r\n\r\n","created_at":"2016-07-22T11:12:26Z","updated_at":"2016-07-25T12:22:14Z","closed_at":"2016-07-22T12:13:10Z","merged_at":"2016-07-22T12:13:10Z","merge_commit_sha":"8adbf77f3886c12d2b4fde7be8eb0f125fd42cfc","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/4767/commits","review_comments_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/4767/comments","review_comment_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues/4767/comments","statuses_url":"https://api.github.com/repos/akeneo/pim-community-dev/statuses/1c6e5ee2db2aad01fdcff99e1041cb9207b03b55","head":{"label":"iulyanp:poc-geteventstore","ref":"poc-geteventstore","sha":"1c6e5ee2db2aad01fdcff99e1041cb9207b03b55","user":{"login":"iulyanp","id":6533422,"avatar_url":"https://avatars.githubusercontent.com/u/6533422?v=3","gravatar_id":"","url":"https://api.github.com/users/iulyanp","html_url":"https://github.com/iulyanp","followers_url":"https://api.github.com/users/iulyanp/followers","following_url":"https://api.github.com/users/iulyanp/following{/other_user}","gists_url":"https://api.github.com/users/iulyanp/gists{/gist_id}","starred_url":"https://api.github.com/users/iulyanp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iulyanp/subscriptions","organizations_url":"https://api.github.com/users/iulyanp/orgs","repos_url":"https://api.github.com/users/iulyanp/repos","events_url":"https://api.github.com/users/iulyanp/events{/privacy}","received_events_url":"https://api.github.com/users/iulyanp/received_events","type":"User","site_admin":false},"repo":{"id":63171676,"name":"pim-community-dev","full_name":"iulyanp/pim-community-dev","owner":{"login":"iulyanp","id":6533422,"avatar_url":"https://avatars.githubusercontent.com/u/6533422?v=3","gravatar_id":"","url":"https://api.github.com/users/iulyanp","html_url":"https://github.com/iulyanp","followers_url":"https://api.github.com/users/iulyanp/followers","following_url":"https://api.github.com/users/iulyanp/following{/other_user}","gists_url":"https://api.github.com/users/iulyanp/gists{/gist_id}","starred_url":"https://api.github.com/users/iulyanp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/iulyanp/subscriptions","organizations_url":"https://api.github.com/users/iulyanp/orgs","repos_url":"https://api.github.com/users/iulyanp/repos","events_url":"https://api.github.com/users/iulyanp/events{/privacy}","received_events_url":"https://api.github.com/users/iulyanp/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/iulyanp/pim-community-dev","description":"[Community Development Repository] The open source Product Information Management (PIM)","fork":true,"url":"https://api.github.com/repos/iulyanp/pim-community-dev","forks_url":"https://api.github.com/repos/iulyanp/pim-community-dev/forks","keys_url":"https://api.github.com/repos/iulyanp/pim-community-dev/keys{/key_id}","collaborators_url":"https://api.github.com/repos/iulyanp/pim-community-dev/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/iulyanp/pim-community-dev/teams","hooks_url":"https://api.github.com/repos/iulyanp/pim-community-dev/hooks","issue_events_url":"https://api.github.com/repos/iulyanp/pim-community-dev/issues/events{/number}","events_url":"https://api.github.com/repos/iulyanp/pim-community-dev/events","assignees_url":"https://api.github.com/repos/iulyanp/pim-community-dev/assignees{/user}","branches_url":"https://api.github.com/repos/iulyanp/pim-community-dev/branches{/branch}","tags_url":"https://api.github.com/repos/iulyanp/pim-community-dev/tags","blobs_url":"https://api.github.com/repos/iulyanp/pim-community-dev/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/iulyanp/pim-community-dev/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/iulyanp/pim-community-dev/git/refs{/sha}","trees_url":"https://api.github.com/repos/iulyanp/pim-community-dev/git/trees{/sha}","statuses_url":"https://api.github.com/repos/iulyanp/pim-community-dev/statuses/{sha}","languages_url":"https://api.github.com/repos/iulyanp/pim-community-dev/languages","stargazers_url":"https://api.github.com/repos/iulyanp/pim-community-dev/stargazers","contributors_url":"https://api.github.com/repos/iulyanp/pim-community-dev/contributors","subscribers_url":"https://api.github.com/repos/iulyanp/pim-community-dev/subscribers","subscription_url":"https://api.github.com/repos/iulyanp/pim-community-dev/subscription","commits_url":"https://api.github.com/repos/iulyanp/pim-community-dev/commits{/sha}","git_commits_url":"https://api.github.com/repos/iulyanp/pim-community-dev/git/commits{/sha}","comments_url":"https://api.github.com/repos/iulyanp/pim-community-dev/comments{/number}","issue_comment_url":"https://api.github.com/repos/iulyanp/pim-community-dev/issues/comments{/number}","contents_url":"https://api.github.com/repos/iulyanp/pim-community-dev/contents/{+path}","compare_url":"https://api.github.com/repos/iulyanp/pim-community-dev/compare/{base}...{head}","merges_url":"https://api.github.com/repos/iulyanp/pim-community-dev/merges","archive_url":"https://api.github.com/repos/iulyanp/pim-community-dev/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/iulyanp/pim-community-dev/downloads","issues_url":"https://api.github.com/repos/iulyanp/pim-community-dev/issues{/number}","pulls_url":"https://api.github.com/repos/iulyanp/pim-community-dev/pulls{/number}","milestones_url":"https://api.github.com/repos/iulyanp/pim-community-dev/milestones{/number}","notifications_url":"https://api.github.com/repos/iulyanp/pim-community-dev/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/iulyanp/pim-community-dev/labels{/name}","releases_url":"https://api.github.com/repos/iulyanp/pim-community-dev/releases{/id}","deployments_url":"https://api.github.com/repos/iulyanp/pim-community-dev/deployments","created_at":"2016-07-12T15:53:43Z","updated_at":"2016-07-12T15:53:53Z","pushed_at":"2016-07-22T11:02:46Z","git_url":"git://github.com/iulyanp/pim-community-dev.git","ssh_url":"git@github.com:iulyanp/pim-community-dev.git","clone_url":"https://github.com/iulyanp/pim-community-dev.git","svn_url":"https://github.com/iulyanp/pim-community-dev","homepage":"http://www.akeneo.com","size":89932,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"akeneo:poc-geteventstore","ref":"poc-geteventstore","sha":"0a7fd23262266b96a09c0293883a6ab7251e7584","user":{"login":"akeneo","id":2510186,"avatar_url":"https://avatars.githubusercontent.com/u/2510186?v=3","gravatar_id":"","url":"https://api.github.com/users/akeneo","html_url":"https://github.com/akeneo","followers_url":"https://api.github.com/users/akeneo/followers","following_url":"https://api.github.com/users/akeneo/following{/other_user}","gists_url":"https://api.github.com/users/akeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/akeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akeneo/subscriptions","organizations_url":"https://api.github.com/users/akeneo/orgs","repos_url":"https://api.github.com/users/akeneo/repos","events_url":"https://api.github.com/users/akeneo/events{/privacy}","received_events_url":"https://api.github.com/users/akeneo/received_events","type":"Organization","site_admin":false},"repo":{"id":5367323,"name":"pim-community-dev","full_name":"akeneo/pim-community-dev","owner":{"login":"akeneo","id":2510186,"avatar_url":"https://avatars.githubusercontent.com/u/2510186?v=3","gravatar_id":"","url":"https://api.github.com/users/akeneo","html_url":"https://github.com/akeneo","followers_url":"https://api.github.com/users/akeneo/followers","following_url":"https://api.github.com/users/akeneo/following{/other_user}","gists_url":"https://api.github.com/users/akeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/akeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akeneo/subscriptions","organizations_url":"https://api.github.com/users/akeneo/orgs","repos_url":"https://api.github.com/users/akeneo/repos","events_url":"https://api.github.com/users/akeneo/events{/privacy}","received_events_url":"https://api.github.com/users/akeneo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/akeneo/pim-community-dev","description":"[Community Development Repository] The open source Product Information Management (PIM)","fork":false,"url":"https://api.github.com/repos/akeneo/pim-community-dev","forks_url":"https://api.github.com/repos/akeneo/pim-community-dev/forks","keys_url":"https://api.github.com/repos/akeneo/pim-community-dev/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akeneo/pim-community-dev/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akeneo/pim-community-dev/teams","hooks_url":"https://api.github.com/repos/akeneo/pim-community-dev/hooks","issue_events_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues/events{/number}","events_url":"https://api.github.com/repos/akeneo/pim-community-dev/events","assignees_url":"https://api.github.com/repos/akeneo/pim-community-dev/assignees{/user}","branches_url":"https://api.github.com/repos/akeneo/pim-community-dev/branches{/branch}","tags_url":"https://api.github.com/repos/akeneo/pim-community-dev/tags","blobs_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/refs{/sha}","trees_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akeneo/pim-community-dev/statuses/{sha}","languages_url":"https://api.github.com/repos/akeneo/pim-community-dev/languages","stargazers_url":"https://api.github.com/repos/akeneo/pim-community-dev/stargazers","contributors_url":"https://api.github.com/repos/akeneo/pim-community-dev/contributors","subscribers_url":"https://api.github.com/repos/akeneo/pim-community-dev/subscribers","subscription_url":"https://api.github.com/repos/akeneo/pim-community-dev/subscription","commits_url":"https://api.github.com/repos/akeneo/pim-community-dev/commits{/sha}","git_commits_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/commits{/sha}","comments_url":"https://api.github.com/repos/akeneo/pim-community-dev/comments{/number}","issue_comment_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues/comments{/number}","contents_url":"https://api.github.com/repos/akeneo/pim-community-dev/contents/{+path}","compare_url":"https://api.github.com/repos/akeneo/pim-community-dev/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akeneo/pim-community-dev/merges","archive_url":"https://api.github.com/repos/akeneo/pim-community-dev/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akeneo/pim-community-dev/downloads","issues_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues{/number}","pulls_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls{/number}","milestones_url":"https://api.github.com/repos/akeneo/pim-community-dev/milestones{/number}","notifications_url":"https://api.github.com/repos/akeneo/pim-community-dev/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akeneo/pim-community-dev/labels{/name}","releases_url":"https://api.github.com/repos/akeneo/pim-community-dev/releases{/id}","deployments_url":"https://api.github.com/repos/akeneo/pim-community-dev/deployments","created_at":"2012-08-10T09:27:26Z","updated_at":"2016-07-15T15:18:11Z","pushed_at":"2016-07-25T12:17:26Z","git_url":"git://github.com/akeneo/pim-community-dev.git","ssh_url":"git@github.com:akeneo/pim-community-dev.git","clone_url":"https://github.com/akeneo/pim-community-dev.git","svn_url":"https://github.com/akeneo/pim-community-dev","homepage":"http://www.akeneo.com","size":150408,"stargazers_count":325,"watchers_count":325,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":167,"mirror_url":null,"open_issues_count":116,"forks":167,"open_issues":116,"watchers":325,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/4767"},"html":{"href":"https://github.com/akeneo/pim-community-dev/pull/4767"},"issue":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/issues/4767"},"comments":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/issues/4767/comments"},"review_comments":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/4767/comments"},"review_comment":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/4767/commits"},"statuses":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/statuses/1c6e5ee2db2aad01fdcff99e1041cb9207b03b55"}}}}
{"actor":{"display_login":"nidup"}}