{"action":"created","comment":{"url":"https://api.github.com/repos/sphereio/sphere-product-import/pulls/comments/41257563","id":41257563,"diff_hunk":"@@ -150,33 +153,57 @@ class ProductImport\n   _createOrUpdate: (productsToProcess, existingProducts) ->\n     debug 'Products to process: %j', {toProcess: productsToProcess, existing: existingProducts}\n     enumUpdateActions = {}\n-    posts = _.map productsToProcess, (prodToProcess) =>\n-      existingProduct = @_isExistingEntry(prodToProcess, existingProducts)\n-      if existingProduct?\n-        @_fetchSameForAllAttributesOfProductType(prodToProcess.productType)\n-        .then (sameForAllAttributes) =>\n-          @_validateEnums(prodToProcess, @_cache.productType[prodToProcess.productType.id])\n-          .then (updateActions) =>\n-            if updateActions and _.size(updateActions.actions) > 0 then @_updateEnumUpdateActions(enumUpdateActions, updateActions)\n-            @_prepareUpdateProduct(prodToProcess, existingProduct).then (preparedProduct) =>\n-              synced = @sync.buildActions(preparedProduct, existingProduct, sameForAllAttributes)\n-              if synced.shouldUpdate()\n-                @client.products.byId(synced.getUpdateId()).update(synced.getUpdatePayload())\n-              else\n-                Promise.resolve statusCode: 304\n-      else\n-        @_prepareNewProduct(prodToProcess)\n-        .then (product) =>\n-          @_validateEnums(product, @_cache.productType[product.productType.id])\n-          .then (updateActions) =>\n-            if updateActions and _.size(updateActions) > 0 then @_updateEnumUpdateActions(enumUpdateActions, updateActions)\n-            @client.products.create(product)\n+    posts = _.map productsToProcess, (product) =>\n+      @_filterAttributes(product)\n+      .then (prodToProcess) =>\n+        existingProduct = @_isExistingEntry(prodToProcess, existingProducts)\n+        if existingProduct?\n+          @_fetchSameForAllAttributesOfProductType(prodToProcess.productType)\n+          .then (sameForAllAttributes) =>\n+            @_validateEnums(prodToProcess, @_cache.productType[prodToProcess.productType.id])\n+            .then (updateActions) =>\n+              if updateActions and _.size(updateActions.actions) > 0 then @_updateEnumUpdateActions(enumUpdateActions, updateActions)\n+              @_prepareUpdateProduct(prodToProcess, existingProduct).then (preparedProduct) =>\n+                synced = @sync.buildActions(preparedProduct, existingProduct, sameForAllAttributes)\n+                if synced.shouldUpdate()\n+                  @client.products.byId(synced.getUpdateId()).update(synced.getUpdatePayload())\n+                else\n+                  Promise.resolve statusCode: 304\n+        else\n+          @_prepareNewProduct(prodToProcess)\n+          .then (product) =>\n+            @_validateEnums(product, @_cache.productType[product.productType.id])\n+            .then (updateActions) =>\n+              if updateActions and _.size(updateActions) > 0 then @_updateEnumUpdateActions(enumUpdateActions, updateActions)\n+              @client.products.create(product)\n \n     @_updateProductType(enumUpdateActions)\n     .then ->\n       debug 'About to send %s requests', _.size(posts)\n       Promise.settle(posts)\n \n+  _filterAttributes: (product) =>\n+    new Promise (resolve) =>\n+      if @filterUnknownAttributes\n+        @_ensureProductTypeInMemory(product.productType.id)\n+        .then =>\n+          @unknownAttributesFilter.filter(@_cache.productType[product.productType.id],product)\n+        .then (filteredProduct) ->\n+          resolve(filteredProduct)\n+      else\n+        resolve(product)\n+\n+  _ensureProductTypeInMemory: (productTypeId) =>\n+    new Promise (resolve) =>\n+      if @_cache.productType[productTypeId]\n+        resolve()\n+      else\n+        productType =\n+          id: productTypeId\n+        @_resolveReference(@client.productTypes, 'productType', productType, \"name=\\\"#{productType?.id}\\\"\")\n+        .then ->\n+          resolve()","path":"lib/product-import.coffee","position":95,"original_position":102,"commit_id":"65bb510694d77f0804881a4b46bb383ddd3e65aa","original_commit_id":"8350103d2db3811662f14783d0ad1afae88b1055","user":{"login":"panshul007","id":745298,"avatar_url":"https://avatars.githubusercontent.com/u/745298?v=3","gravatar_id":"","url":"https://api.github.com/users/panshul007","html_url":"https://github.com/panshul007","followers_url":"https://api.github.com/users/panshul007/followers","following_url":"https://api.github.com/users/panshul007/following{/other_user}","gists_url":"https://api.github.com/users/panshul007/gists{/gist_id}","starred_url":"https://api.github.com/users/panshul007/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/panshul007/subscriptions","organizations_url":"https://api.github.com/users/panshul007/orgs","repos_url":"https://api.github.com/users/panshul007/repos","events_url":"https://api.github.com/users/panshul007/events{/privacy}","received_events_url":"https://api.github.com/users/panshul007/received_events","type":"User","site_admin":false},"body":"updated","created_at":"2015-10-06T12:36:51Z","updated_at":"2015-10-06T12:36:51Z","html_url":"https://github.com/sphereio/sphere-product-import/pull/46#discussion_r41257563","pull_request_url":"https://api.github.com/repos/sphereio/sphere-product-import/pulls/46","_links":{"self":{"href":"https://api.github.com/repos/sphereio/sphere-product-import/pulls/comments/41257563"},"html":{"href":"https://github.com/sphereio/sphere-product-import/pull/46#discussion_r41257563"},"pull_request":{"href":"https://api.github.com/repos/sphereio/sphere-product-import/pulls/46"}}},"pull_request":{"url":"https://api.github.com/repos/sphereio/sphere-product-import/pulls/46","id":46633477,"html_url":"https://github.com/sphereio/sphere-product-import/pull/46","diff_url":"https://github.com/sphereio/sphere-product-import/pull/46.diff","patch_url":"https://github.com/sphereio/sphere-product-import/pull/46.patch","issue_url":"https://api.github.com/repos/sphereio/sphere-product-import/issues/46","number":46,"state":"open","locked":false,"title":"WIP: Ignore undefined attributes","user":{"login":"panshul007","id":745298,"avatar_url":"https://avatars.githubusercontent.com/u/745298?v=3","gravatar_id":"","url":"https://api.github.com/users/panshul007","html_url":"https://github.com/panshul007","followers_url":"https://api.github.com/users/panshul007/followers","following_url":"https://api.github.com/users/panshul007/following{/other_user}","gists_url":"https://api.github.com/users/panshul007/gists{/gist_id}","starred_url":"https://api.github.com/users/panshul007/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/panshul007/subscriptions","organizations_url":"https://api.github.com/users/panshul007/orgs","repos_url":"https://api.github.com/users/panshul007/repos","events_url":"https://api.github.com/users/panshul007/events{/privacy}","received_events_url":"https://api.github.com/users/panshul007/received_events","type":"User","site_admin":false},"body":"[ ] Add filter class - done\r\n[ ] Add tests  for the the filter class - done\r\n[ ] Integrate filter into the product-importer - WIP ","created_at":"2015-10-02T13:11:56Z","updated_at":"2015-10-06T12:36:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"901a66d583098e69a6fed376c87c3b492ea20a70","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sphereio/sphere-product-import/pulls/46/commits","review_comments_url":"https://api.github.com/repos/sphereio/sphere-product-import/pulls/46/comments","review_comment_url":"https://api.github.com/repos/sphereio/sphere-product-import/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sphereio/sphere-product-import/issues/46/comments","statuses_url":"https://api.github.com/repos/sphereio/sphere-product-import/statuses/65bb510694d77f0804881a4b46bb383ddd3e65aa","head":{"label":"sphereio:ignore-undefined-attributes","ref":"ignore-undefined-attributes","sha":"65bb510694d77f0804881a4b46bb383ddd3e65aa","user":{"login":"sphereio","id":4119130,"avatar_url":"https://avatars.githubusercontent.com/u/4119130?v=3","gravatar_id":"","url":"https://api.github.com/users/sphereio","html_url":"https://github.com/sphereio","followers_url":"https://api.github.com/users/sphereio/followers","following_url":"https://api.github.com/users/sphereio/following{/other_user}","gists_url":"https://api.github.com/users/sphereio/gists{/gist_id}","starred_url":"https://api.github.com/users/sphereio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sphereio/subscriptions","organizations_url":"https://api.github.com/users/sphereio/orgs","repos_url":"https://api.github.com/users/sphereio/repos","events_url":"https://api.github.com/users/sphereio/events{/privacy}","received_events_url":"https://api.github.com/users/sphereio/received_events","type":"Organization","site_admin":false},"repo":{"id":34815423,"name":"sphere-product-import","full_name":"sphereio/sphere-product-import","owner":{"login":"sphereio","id":4119130,"avatar_url":"https://avatars.githubusercontent.com/u/4119130?v=3","gravatar_id":"","url":"https://api.github.com/users/sphereio","html_url":"https://github.com/sphereio","followers_url":"https://api.github.com/users/sphereio/followers","following_url":"https://api.github.com/users/sphereio/following{/other_user}","gists_url":"https://api.github.com/users/sphereio/gists{/gist_id}","starred_url":"https://api.github.com/users/sphereio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sphereio/subscriptions","organizations_url":"https://api.github.com/users/sphereio/orgs","repos_url":"https://api.github.com/users/sphereio/repos","events_url":"https://api.github.com/users/sphereio/events{/privacy}","received_events_url":"https://api.github.com/users/sphereio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sphereio/sphere-product-import","description":"Manage product data","fork":false,"url":"https://api.github.com/repos/sphereio/sphere-product-import","forks_url":"https://api.github.com/repos/sphereio/sphere-product-import/forks","keys_url":"https://api.github.com/repos/sphereio/sphere-product-import/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sphereio/sphere-product-import/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sphereio/sphere-product-import/teams","hooks_url":"https://api.github.com/repos/sphereio/sphere-product-import/hooks","issue_events_url":"https://api.github.com/repos/sphereio/sphere-product-import/issues/events{/number}","events_url":"https://api.github.com/repos/sphereio/sphere-product-import/events","assignees_url":"https://api.github.com/repos/sphereio/sphere-product-import/assignees{/user}","branches_url":"https://api.github.com/repos/sphereio/sphere-product-import/branches{/branch}","tags_url":"https://api.github.com/repos/sphereio/sphere-product-import/tags","blobs_url":"https://api.github.com/repos/sphereio/sphere-product-import/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sphereio/sphere-product-import/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sphereio/sphere-product-import/git/refs{/sha}","trees_url":"https://api.github.com/repos/sphereio/sphere-product-import/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sphereio/sphere-product-import/statuses/{sha}","languages_url":"https://api.github.com/repos/sphereio/sphere-product-import/languages","stargazers_url":"https://api.github.com/repos/sphereio/sphere-product-import/stargazers","contributors_url":"https://api.github.com/repos/sphereio/sphere-product-import/contributors","subscribers_url":"https://api.github.com/repos/sphereio/sphere-product-import/subscribers","subscription_url":"https://api.github.com/repos/sphereio/sphere-product-import/subscription","commits_url":"https://api.github.com/repos/sphereio/sphere-product-import/commits{/sha}","git_commits_url":"https://api.github.com/repos/sphereio/sphere-product-import/git/commits{/sha}","comments_url":"https://api.github.com/repos/sphereio/sphere-product-import/comments{/number}","issue_comment_url":"https://api.github.com/repos/sphereio/sphere-product-import/issues/comments{/number}","contents_url":"https://api.github.com/repos/sphereio/sphere-product-import/contents/{+path}","compare_url":"https://api.github.com/repos/sphereio/sphere-product-import/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sphereio/sphere-product-import/merges","archive_url":"https://api.github.com/repos/sphereio/sphere-product-import/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sphereio/sphere-product-import/downloads","issues_url":"https://api.github.com/repos/sphereio/sphere-product-import/issues{/number}","pulls_url":"https://api.github.com/repos/sphereio/sphere-product-import/pulls{/number}","milestones_url":"https://api.github.com/repos/sphereio/sphere-product-import/milestones{/number}","notifications_url":"https://api.github.com/repos/sphereio/sphere-product-import/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sphereio/sphere-product-import/labels{/name}","releases_url":"https://api.github.com/repos/sphereio/sphere-product-import/releases{/id}","created_at":"2015-04-29T20:01:14Z","updated_at":"2015-06-03T08:11:17Z","pushed_at":"2015-10-06T12:23:41Z","git_url":"git://github.com/sphereio/sphere-product-import.git","ssh_url":"git@github.com:sphereio/sphere-product-import.git","clone_url":"https://github.com/sphereio/sphere-product-import.git","svn_url":"https://github.com/sphereio/sphere-product-import","homepage":null,"size":760,"stargazers_count":1,"watchers_count":1,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":1,"default_branch":"master"}},"base":{"label":"sphereio:master","ref":"master","sha":"8aaa8f96db9c733de9f2057e5adb1f6357afdd8c","user":{"login":"sphereio","id":4119130,"avatar_url":"https://avatars.githubusercontent.com/u/4119130?v=3","gravatar_id":"","url":"https://api.github.com/users/sphereio","html_url":"https://github.com/sphereio","followers_url":"https://api.github.com/users/sphereio/followers","following_url":"https://api.github.com/users/sphereio/following{/other_user}","gists_url":"https://api.github.com/users/sphereio/gists{/gist_id}","starred_url":"https://api.github.com/users/sphereio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sphereio/subscriptions","organizations_url":"https://api.github.com/users/sphereio/orgs","repos_url":"https://api.github.com/users/sphereio/repos","events_url":"https://api.github.com/users/sphereio/events{/privacy}","received_events_url":"https://api.github.com/users/sphereio/received_events","type":"Organization","site_admin":false},"repo":{"id":34815423,"name":"sphere-product-import","full_name":"sphereio/sphere-product-import","owner":{"login":"sphereio","id":4119130,"avatar_url":"https://avatars.githubusercontent.com/u/4119130?v=3","gravatar_id":"","url":"https://api.github.com/users/sphereio","html_url":"https://github.com/sphereio","followers_url":"https://api.github.com/users/sphereio/followers","following_url":"https://api.github.com/users/sphereio/following{/other_user}","gists_url":"https://api.github.com/users/sphereio/gists{/gist_id}","starred_url":"https://api.github.com/users/sphereio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sphereio/subscriptions","organizations_url":"https://api.github.com/users/sphereio/orgs","repos_url":"https://api.github.com/users/sphereio/repos","events_url":"https://api.github.com/users/sphereio/events{/privacy}","received_events_url":"https://api.github.com/users/sphereio/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sphereio/sphere-product-import","description":"Manage product data","fork":false,"url":"https://api.github.com/repos/sphereio/sphere-product-import","forks_url":"https://api.github.com/repos/sphereio/sphere-product-import/forks","keys_url":"https://api.github.com/repos/sphereio/sphere-product-import/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sphereio/sphere-product-import/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sphereio/sphere-product-import/teams","hooks_url":"https://api.github.com/repos/sphereio/sphere-product-import/hooks","issue_events_url":"https://api.github.com/repos/sphereio/sphere-product-import/issues/events{/number}","events_url":"https://api.github.com/repos/sphereio/sphere-product-import/events","assignees_url":"https://api.github.com/repos/sphereio/sphere-product-import/assignees{/user}","branches_url":"https://api.github.com/repos/sphereio/sphere-product-import/branches{/branch}","tags_url":"https://api.github.com/repos/sphereio/sphere-product-import/tags","blobs_url":"https://api.github.com/repos/sphereio/sphere-product-import/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sphereio/sphere-product-import/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sphereio/sphere-product-import/git/refs{/sha}","trees_url":"https://api.github.com/repos/sphereio/sphere-product-import/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sphereio/sphere-product-import/statuses/{sha}","languages_url":"https://api.github.com/repos/sphereio/sphere-product-import/languages","stargazers_url":"https://api.github.com/repos/sphereio/sphere-product-import/stargazers","contributors_url":"https://api.github.com/repos/sphereio/sphere-product-import/contributors","subscribers_url":"https://api.github.com/repos/sphereio/sphere-product-import/subscribers","subscription_url":"https://api.github.com/repos/sphereio/sphere-product-import/subscription","commits_url":"https://api.github.com/repos/sphereio/sphere-product-import/commits{/sha}","git_commits_url":"https://api.github.com/repos/sphereio/sphere-product-import/git/commits{/sha}","comments_url":"https://api.github.com/repos/sphereio/sphere-product-import/comments{/number}","issue_comment_url":"https://api.github.com/repos/sphereio/sphere-product-import/issues/comments{/number}","contents_url":"https://api.github.com/repos/sphereio/sphere-product-import/contents/{+path}","compare_url":"https://api.github.com/repos/sphereio/sphere-product-import/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sphereio/sphere-product-import/merges","archive_url":"https://api.github.com/repos/sphereio/sphere-product-import/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sphereio/sphere-product-import/downloads","issues_url":"https://api.github.com/repos/sphereio/sphere-product-import/issues{/number}","pulls_url":"https://api.github.com/repos/sphereio/sphere-product-import/pulls{/number}","milestones_url":"https://api.github.com/repos/sphereio/sphere-product-import/milestones{/number}","notifications_url":"https://api.github.com/repos/sphereio/sphere-product-import/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sphereio/sphere-product-import/labels{/name}","releases_url":"https://api.github.com/repos/sphereio/sphere-product-import/releases{/id}","created_at":"2015-04-29T20:01:14Z","updated_at":"2015-06-03T08:11:17Z","pushed_at":"2015-10-06T12:23:41Z","git_url":"git://github.com/sphereio/sphere-product-import.git","ssh_url":"git@github.com:sphereio/sphere-product-import.git","clone_url":"https://github.com/sphereio/sphere-product-import.git","svn_url":"https://github.com/sphereio/sphere-product-import","homepage":null,"size":760,"stargazers_count":1,"watchers_count":1,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":10,"forks":0,"open_issues":10,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sphereio/sphere-product-import/pulls/46"},"html":{"href":"https://github.com/sphereio/sphere-product-import/pull/46"},"issue":{"href":"https://api.github.com/repos/sphereio/sphere-product-import/issues/46"},"comments":{"href":"https://api.github.com/repos/sphereio/sphere-product-import/issues/46/comments"},"review_comments":{"href":"https://api.github.com/repos/sphereio/sphere-product-import/pulls/46/comments"},"review_comment":{"href":"https://api.github.com/repos/sphereio/sphere-product-import/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sphereio/sphere-product-import/pulls/46/commits"},"statuses":{"href":"https://api.github.com/repos/sphereio/sphere-product-import/statuses/65bb510694d77f0804881a4b46bb383ddd3e65aa"}}}}