简体   繁体   English

Google Affiliate与Magento 1.7的集成

[英]Google Affiliate Integration with Magento 1.7

So maybe you guys can help me out here, im trying to integrate googles tracking pixel for their Google Affiliate program. 因此,也许你们可以在这里为我提供帮助,我正在尝试将Google跟踪像素集成到其Google Affiliate计划中。 Im using the following code from here http://www.studio1909.com/2009/10/16/google-affiliate-network-conversion-tracking-pixel-magento-ecommerce/ However, after going back and forth with google they aren't so excited about the way the code from the above link is printing out the data when it comes to configurable products. 我从这里使用以下代码http://www.studio1909.com/2009/10/16/google-affiliate-network-conversion-tracking-pixel-magento-ecommerce/但是,与Google来回交流之后,对于涉及可配置产品的上述链接中的代码打印数据的方式,我并不感到兴奋。

<!--Start Google Affiliate Integration-->

<?php 
$lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
$order = Mage::getSingleton('sales/order');
$order->load($lastOrderId);

$order = Mage::getModel('sales/order')->load($lastOrderId);
foreach ($order->getAllItems() as $item) {
        $productArray[] = array(
                "product_sku" => $item->getSku(),
                "product_magento_id" => $item->getProductId(),
                "product_name" => $item->getName(),
                "product_qty" => $item->getQtyOrdered(),
                "product_price" => $item->getPrice(),
                "product_discount_amount" => $item->getDiscountAmount(),
                "product_row_price" => $item->getPrice() - $item->getDiscountAmount(),
                 );

        };
?>

<?php
$_totalData = $order->getData();

$_subtotal = $_totalData['subtotal'];

$_orderID = $_totalData['increment_id'];

?>

<img src="https://clickserve.cc-dt.com/link/
order?vid=KVENDORID&oid=<?php echo "$_orderID"; ?>&amt=<?php echo "$_subtotal"?>&prdsku=<?php foreach ($productArray as $key) {echo $key['product_sku']."^";}; 
?>&prdnm=<?php foreach ($productArray as $key) {echo $key['product_name']."^";};    
?>&prdqn=<?php foreach ($productArray as $key) {echo $key['product_qty']."^";};    
?>&prdpr=<?php foreach ($productArray as $key) {echo $key['product_price']."^";};
?>&prcatid=<?php foreach ($productArray as $key) {echo "your-product^";};
?>" width=1 height=1>

<!--End Google Affiliate Integration-->

This is the end result 这是最终结果

<!--Start Google Affiliate Integration-->

<img src="https://gan.doubleclick.net/gan_conversion?advid=MYID&event_type=transaction&oid=10000XXXX&amt=19.0000&fxsrc=USD&prdsku=DVT2756CH CHAR M^DVT2756CH CHAR M^&prdnm=DaVinci 1952 In Charcoal T-Shirt^DaVinci 1952 In Charcoal T-Shirt^&prdqn=1.0000^1.0000^&prdpr=19.0000^0.0000^&prcatid=4425^4427^" width=1 height=1>

<!--End Google Affiliate Integration--> 

So the question is there a way to edit the code above so it just echoes the main configurable product without the simple product. 因此,问题是有一种方法可以编辑上面的代码,以便仅回显主要可配置产品而无需简单产品。

Thanks! 谢谢!

One good place to look at this is the template for displaying the order items: app/design/frontend/base/default/template/sales/order/items.phtml 一个不错的地方是显示订单商品的模板: app/design/frontend/base/default/template/sales/order/items.phtml

and the code for the loop is: 循环的代码是:

<?php $_items = $_order->getItemsCollection(); ?>
<?php $_index = 0; ?>
    <?php $_count = $_items->count(); ?>
<?php foreach ($_items as $_item): ?>
<?php if ($_item->getParentItem()) continue; ?>

So this can be a good way to get what you need. 因此,这可能是获取所需内容的好方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM