Skip to content

How can i pass product attribute manufacturer and SKU to javascript?

I have the following script which i need to add the product brand/manufacturer and SKU

<script>
    window.addEventListener('liveload', function() {
        IcecatLive.getDatasheet(
            {           
                'reasonstobuy':'#Container5',
            }, 
            {
            Brand: **$manufacturer**,
            PartCode: **$sku**,
            UserName: 'myusername'
        }, 'en')               
    });
</script>

I have added custom.phtml in web/magento/app/design/frontend/MyTemplate/default/Magento_Catalog/templates/product/view

which contains

<?php $_product = $this->getProduct(); 
/* YOU CAN GET ANY PRODUCT ATTRIBUTE HERE. */
echo $_product->getAttributeText('manufacturer') 
echo $_product->getSku(); 
?>

I can display the manufacturer and sku in a block on the front end but cant pass the attributes into the above script, how can i pass the php output manufacturer/sku to the javascript?