{"action":"created","comment":{"url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/comments/27999128","id":27999128,"diff_hunk":"@@ -379,39 +393,36 @@ public function valueExists(ProductValueInterface $value)\n      */\n     public function getEligibleProductIdsForVariantGroup($variantGroupId)\n     {\n-        $sql = 'SELECT count(ga.attribute_id) as nb '.\n-            'FROM pim_catalog_group_attribute as ga '.\n-            'WHERE ga.group_id = :groupId;';\n-        $stmt = $this->getEntityManager()->getConnection()->prepare($sql);\n-        $stmt->bindValue('groupId', $variantGroupId);\n-        $stmt->execute();\n-        $nbAxes = $stmt->fetch()['nb'];\n-\n-        $elligibleProductsSQL = 'SELECT v.entity_id as product_id '.\n-            'FROM pim_catalog_group_attribute as ga '.\n-            'LEFT JOIN %product_value_table% as v ON v.attribute_id = ga.attribute_id '.\n-            'WHERE ga.group_id = :groupId '.\n-            'GROUP BY v.entity_id '.\n-            'having count(v.option_id) = :nbAxes';\n-\n-        $alreadyInGroupSQL = 'SELECT p.id as product_id ' .\n-            'FROM pim_catalog_product as p ' .\n-            'JOIN pim_catalog_group_product as gp on p.id = gp.product_id ' .\n-            'JOIN pim_catalog_group as g on g.id = gp.group_id ' .\n-            'JOIN pim_catalog_group_type as gt on gt.id = g.type_id ' .\n-            'WHERE gt.code = \"VARIANT\" ' .\n-            'AND g.id != :groupId';\n-\n-        $sql = sprintf(\n-            'SELECT * FROM (%s) as p WHERE p.product_id NOT IN (%s);',\n-            $elligibleProductsSQL,\n-            $alreadyInGroupSQL\n-        );\n-        $sql = QueryBuilderUtility::prepareDBALQuery($this->_em, $this->_entityName, $sql);\n+        $sql = 'SELECT v.entity_id AS product_id, gp.group_id, ga.group_id ' .\n+            'FROM pim_catalog_group g ' .\n+            'INNER JOIN pim_catalog_group_attribute ga ON ga.group_id = g.id ' .\n+            'INNER JOIN %product_value_table% v ON v.attribute_id = ga.attribute_id ' .\n+            'LEFT JOIN pim_catalog_group_product gp ON (v.entity_id = gp.product_id) ' .\n+            'INNER JOIN pim_catalog_group_type gt on gt.id = g.type_id ' .\n+            'WHERE ga.group_id = :groupId AND gt.code = \"VARIANT\" ' .\n+            'AND (v.option_id IS NOT NULL';\n+\n+        $references = $this->referenceDataRegistry->all();\n+        if (!empty($references)) {\n+            $valueMetadata = QueryBuilderUtility::getProductValueMetadata($this->_em, $this->_entityName);\n+\n+            foreach ($references as $code => $referenceData) {\n+                if ('simple' === $referenceData->getType()) {\n+                    if ($valueMetadata->isAssociationWithSingleJoinColumn($code)) {","path":"src/Pim/Bundle/CatalogBundle/Doctrine/ORM/Repository/ProductRepository.php","position":83,"original_position":83,"commit_id":"5a371a3f8419123cb18caacd637aa4a318af33e5","original_commit_id":"5a371a3f8419123cb18caacd637aa4a318af33e5","user":{"login":"jjanvier","id":3691804,"avatar_url":"https://avatars.githubusercontent.com/u/3691804?v=3","gravatar_id":"","url":"https://api.github.com/users/jjanvier","html_url":"https://github.com/jjanvier","followers_url":"https://api.github.com/users/jjanvier/followers","following_url":"https://api.github.com/users/jjanvier/following{/other_user}","gists_url":"https://api.github.com/users/jjanvier/gists{/gist_id}","starred_url":"https://api.github.com/users/jjanvier/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jjanvier/subscriptions","organizations_url":"https://api.github.com/users/jjanvier/orgs","repos_url":"https://api.github.com/users/jjanvier/repos","events_url":"https://api.github.com/users/jjanvier/events{/privacy}","received_events_url":"https://api.github.com/users/jjanvier/received_events","type":"User","site_admin":false},"body":"`null !== ` or `false !== ` ?","created_at":"2015-04-08T18:32:44Z","updated_at":"2015-04-08T18:32:44Z","html_url":"https://github.com/akeneo/pim-community-dev/pull/2478#discussion_r27999128","pull_request_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/2478","_links":{"self":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/comments/27999128"},"html":{"href":"https://github.com/akeneo/pim-community-dev/pull/2478#discussion_r27999128"},"pull_request":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/2478"}}},"pull_request":{"url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/2478","id":32875762,"html_url":"https://github.com/akeneo/pim-community-dev/pull/2478","diff_url":"https://github.com/akeneo/pim-community-dev/pull/2478.diff","patch_url":"https://github.com/akeneo/pim-community-dev/pull/2478.patch","issue_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues/2478","number":2478,"state":"open","locked":false,"title":"PIM-4016: Be able to use Simple Reference Data as Variant Group Axis","user":{"login":"skeleton","id":1131230,"avatar_url":"https://avatars.githubusercontent.com/u/1131230?v=3","gravatar_id":"","url":"https://api.github.com/users/skeleton","html_url":"https://github.com/skeleton","followers_url":"https://api.github.com/users/skeleton/followers","following_url":"https://api.github.com/users/skeleton/following{/other_user}","gists_url":"https://api.github.com/users/skeleton/gists{/gist_id}","starred_url":"https://api.github.com/users/skeleton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skeleton/subscriptions","organizations_url":"https://api.github.com/users/skeleton/orgs","repos_url":"https://api.github.com/users/skeleton/repos","events_url":"https://api.github.com/users/skeleton/events{/privacy}","received_events_url":"https://api.github.com/users/skeleton/received_events","type":"User","site_admin":false},"body":"| Q                    | A\r\n| -------------------- | ---\r\n| Bug fix?             | N\r\n| New feature?         | Y\r\n| BC breaks?           | Y\r\n| CI currently passes? | ?\r\n| Tests pass?          | Y\r\n| Scenarios pass?      | Y\r\n| Checkstyle issues?*  | N\r\n| PMD issues?**        | N\r\n| Changelog updated?   |  N\r\n| Fixed tickets        | PIM-4016\r\n| DB schema updated?   | N\r\n| Migration script?    | N\r\n| Doc PR               | N","created_at":"2015-04-08T16:08:44Z","updated_at":"2015-04-08T18:32:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d4e829c04414a989085087aae20b62319b0b4276","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/2478/commits","review_comments_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/2478/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/2478/comments","statuses_url":"https://api.github.com/repos/akeneo/pim-community-dev/statuses/5a371a3f8419123cb18caacd637aa4a318af33e5","head":{"label":"akeneo:PIM-4016","ref":"PIM-4016","sha":"5a371a3f8419123cb18caacd637aa4a318af33e5","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":"Akeneo PIM development repository","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}","created_at":"2012-08-10T09:27:26Z","updated_at":"2015-04-08T12:19:03Z","pushed_at":"2015-04-08T16:08:45Z","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://akeneo.com","size":158660,"stargazers_count":215,"watchers_count":215,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":102,"mirror_url":null,"open_issues_count":55,"forks":102,"open_issues":55,"watchers":215,"default_branch":"master"}},"base":{"label":"akeneo:feature/reference_data","ref":"feature/reference_data","sha":"bf6a1462eb5e86972d9a48e3fa79cff73716e40a","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":"Akeneo PIM development repository","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}","created_at":"2012-08-10T09:27:26Z","updated_at":"2015-04-08T12:19:03Z","pushed_at":"2015-04-08T16:08:45Z","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://akeneo.com","size":158660,"stargazers_count":215,"watchers_count":215,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":102,"mirror_url":null,"open_issues_count":55,"forks":102,"open_issues":55,"watchers":215,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/2478"},"html":{"href":"https://github.com/akeneo/pim-community-dev/pull/2478"},"issue":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/issues/2478"},"comments":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/issues/2478/comments"},"review_comments":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/2478/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/2478/commits"},"statuses":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/statuses/5a371a3f8419123cb18caacd637aa4a318af33e5"}}}}