qrs
qrs

Reputation: 177

Getting one product information from category page in Magento

¡Hola,

I'm trying to set up this darn Google trusted stores script on my Magento website. I seems Google wants me to add the below javascript to every page and call only one product from each page. That's okay for product page but I'm having some trouble on other pages like the category pages. I suppose I could somehow add the script to template/catalog/product/list.phtml So anyway, I was wondering if I could add the just the first product listing on each category page with PHP to the Google javascript?

Has anyone have figured out how to add the script like Google wants to Magento or is there a tutorial about it somewhere?

Here's the Google javascript:

<!-- BEGIN: Google Trusted Stores -->
<script type="text/javascript">
  var gts = gts || [];
  gts.push(["id", "xxxxxx"]);
  gts.push(["google_base_offer_id", "<?php echo $this->htmlEscape($_product->getSku()) ?>"]);
  gts.push(["google_base_subaccount_id", "xxxxxxxx"]);
  gts.push(["google_base_country", "US"]);
  gts.push(["google_base_language", "EN"]);
  (function() {
    var scheme = (("https:" == document.location.protocol) ? "https://" : "http://");
    var gts = document.createElement("script");
    gts.type = "text/javascript";
    gts.async = true;
    gts.src = scheme + "www.googlecommerce.com/trustedstores/gtmp_compiled.js";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(gts, s);
  })();
</script>
<!-- END: Google Trusted Stores -->

Thanks

Upvotes: 0

Views: 69

Answers (1)

qrs
qrs

Reputation: 177

I'm such a dummy the code is already in the Google Trusted Stores Module. :)

Upvotes: 0

Related Questions