{"action":"created","issue":{"url":"https://api.github.com/repos/reggi/shopify/issues/5","labels_url":"https://api.github.com/repos/reggi/shopify/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/reggi/shopify/issues/5/comments","events_url":"https://api.github.com/repos/reggi/shopify/issues/5/events","html_url":"https://github.com/reggi/shopify/issues/5","id":56567693,"number":5,"title":"Products global","user":{"login":"reggi","id":296798,"avatar_url":"https://avatars.githubusercontent.com/u/296798?v=3","gravatar_id":"","url":"https://api.github.com/users/reggi","html_url":"https://github.com/reggi","followers_url":"https://api.github.com/users/reggi/followers","following_url":"https://api.github.com/users/reggi/following{/other_user}","gists_url":"https://api.github.com/users/reggi/gists{/gist_id}","starred_url":"https://api.github.com/users/reggi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/reggi/subscriptions","organizations_url":"https://api.github.com/users/reggi/orgs","repos_url":"https://api.github.com/users/reggi/repos","events_url":"https://api.github.com/users/reggi/events{/privacy}","received_events_url":"https://api.github.com/users/reggi/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/reggi/shopify/labels/feature","name":"feature","color":"009800"},{"url":"https://api.github.com/repos/reggi/shopify/labels/hack","name":"hack","color":"eb6420"},{"url":"https://api.github.com/repos/reggi/shopify/labels/liquid","name":"liquid","color":"207de5"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-02-04T18:33:04Z","updated_at":"2015-03-12T18:54:29Z","closed_at":null,"body":"> I originally posted this here https://github.com/Shopify/liquid/issues/438. The discussion should be followed there.\r\n\r\nWe should be able to do this:\r\n```\r\n{{ products[\"austin-leaf-map-poster\"].url }}\r\n```\r\n\r\nBut we (developers) don't have access to a `products` global.\r\n\r\nInstead of having access to the global. I have to hack something together like this:\r\n\r\n`function.get_product.liquid`\r\n\r\n```\r\n{% assign return = false %}\r\n{% if pass_product_handle and collections[\"all\"] %}\r\n  {% for product in collections[\"all\"].products %}\r\n    {% if pass_product_handle == product.handle %}\r\n      {% assign return = product %}\r\n    {% endif %}\r\n  {% endfor %}\r\n{% endif %}\r\n```\r\n\r\n`usage.liquid`\r\n\r\n```\r\n{% assign pass_product_handle = \"austin-leaf-map-poster\" %}\r\n{% include \"function.get_product\" %}\r\n{% assign product = return %}\r\n{{ product.url }}\r\n \r\n{% assign pass_product_handle = \"boston-leaf-map-poster\" %}\r\n{% include \"function.get_product\" %}\r\n{% assign product = return %}\r\n{{ product.url }}\r\n```\r\n\r\nIt can't be good for Shopify to have to interpret this loop every time I need product information, no?\r\n"},"comment":{"url":"https://api.github.com/repos/reggi/shopify/issues/comments/78567171","html_url":"https://github.com/reggi/shopify/issues/5#issuecomment-78567171","issue_url":"https://api.github.com/repos/reggi/shopify/issues/5","id":78567171,"user":{"login":"rickydazla","id":486590,"avatar_url":"https://avatars.githubusercontent.com/u/486590?v=3","gravatar_id":"","url":"https://api.github.com/users/rickydazla","html_url":"https://github.com/rickydazla","followers_url":"https://api.github.com/users/rickydazla/followers","following_url":"https://api.github.com/users/rickydazla/following{/other_user}","gists_url":"https://api.github.com/users/rickydazla/gists{/gist_id}","starred_url":"https://api.github.com/users/rickydazla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rickydazla/subscriptions","organizations_url":"https://api.github.com/users/rickydazla/orgs","repos_url":"https://api.github.com/users/rickydazla/repos","events_url":"https://api.github.com/users/rickydazla/events{/privacy}","received_events_url":"https://api.github.com/users/rickydazla/received_events","type":"User","site_admin":false},"created_at":"2015-03-12T18:54:29Z","updated_at":"2015-03-12T18:54:29Z","body":"@reggi I just modified your snippet to use IDs instead of handles, which are not quite as _set-in-stone_\r\n```\r\n{% assign return = false %}\r\n{% if pass_product_id and collections[\"all\"] %}\r\n  {% for product in collections[\"all\"].products %}\r\n    {% if pass_product_id == product.id %}\r\n      {% assign return = product %}\r\n    {% endif %}\r\n  {% endfor %}\r\n{% endif %}\r\n```"}}