Element API and Shopify plugin Is there any way to translate this:

{% set shopify = craft.shopify.getProductById({ id: entry.shopifyProduct, fields: 'variants, id' }) %}


to the Element API? 

I've tried this, but obviously it doesn't work:

return [
  'endpoints' =&gt; [
  'api.json' =&gt; [
  'elementType' =&gt; 'Entry',
  'criteria' =&gt; [
    'section' =&gt; product,
  ],
  'transformer' =&gt; function (EntryModel $entry) {
    $shopify = craft()-&gt;shopify-&gt;getProductById({id:$entry-&gt;shopifyProduct});

    return [
      'id' =&gt; $entry-&gt;id,
      'title' =&gt; $entry-&gt;title,
      'url' =&gt; $entry-&gt;url,
      'shopifyId' =&gt; $entry-&gt;$shopify
    ];
  },
]
 ]
];
There are some issues with your PHP syntax – I didn't test this (not sure how the data model returned by craft()-&gt;shopify-&gt;getProductById() looks, and you'll need to verify that $entry-&gt;shopifyProduct returns a Shopify product ID), but at least the syntax errors should be fixed:

return [
    'endpoints' =&gt; [
        'api.json' =&gt; [
            'elementType' =&gt; 'Entry',
            'criteria' =&gt; [
                'section' =&gt; 'product',
            ],
            'transformer' =&gt; function (EntryModel $entry) {
                $shopify = craft()-&gt;shopify-&gt;getProductById([ 'id' =&gt; $entry-&gt;shopifyProduct ]);
                return [
                    'id' =&gt; $entry-&gt;id,
                    'title' =&gt; $entry-&gt;title,
                    'url' =&gt; $entry-&gt;url,
                    'shopifyId' =&gt; $shopify ? $shopify-&gt;id : null,
                ];
            },
        ]
    ]
];