Version Notes
Created 3rd March, 2017 Compatibility: 1.9.2.4 - Replaced SKUs with custom IDs
Download this release
Release Info
Developer | ROI Hunter |
Extension | roihunter_easy |
Version | 1.0.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.2 to 1.0.3
- app/code/community/Businessfactory/Roihuntereasy/Block/CategoryViewAnalytics.php +1 -1
- app/code/community/Businessfactory/Roihuntereasy/Model/AddedToCartObserver.php +13 -2
- app/code/community/Businessfactory/Roihuntereasy/Model/CheckoutObserver.php +41 -3
- app/code/community/Businessfactory/Roihuntereasy/Model/Cron.php +8 -3
- app/design/adminhtml/default/default/template/businessfactory_roihuntereasy/admin.phtml +23 -23
- app/design/frontend/base/default/template/businessfactory_roihuntereasy/product_view_analytics.phtml +2 -2
- package.xml +5 -5
app/code/community/Businessfactory/Roihuntereasy/Block/CategoryViewAnalytics.php
CHANGED
@@ -11,7 +11,7 @@ class Businessfactory_Roihuntereasy_Block_CategoryViewAnalytics extends Business
|
|
11 |
$count = 0;
|
12 |
$productIds = array();
|
13 |
foreach ($products as $product) {
|
14 |
-
array_push($productIds,
|
15 |
if (count($productIds) >= $limit) {
|
16 |
break;
|
17 |
}
|
11 |
$count = 0;
|
12 |
$productIds = array();
|
13 |
foreach ($products as $product) {
|
14 |
+
array_push($productIds, "mag_".$product->getId());
|
15 |
if (count($productIds) >= $limit) {
|
16 |
break;
|
17 |
}
|
app/code/community/Businessfactory/Roihuntereasy/Model/AddedToCartObserver.php
CHANGED
@@ -11,14 +11,25 @@ class Businessfactory_Roihuntereasy_Model_AddedToCartObserver extends Mage_Core_
|
|
11 |
{
|
12 |
try {
|
13 |
$product = $observer->getEvent()->getProduct();
|
|
|
|
|
14 |
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
16 |
$price = $product->getFinalPrice();
|
17 |
|
|
|
|
|
|
|
|
|
18 |
// set product as session data
|
19 |
$product_remarketing_data = array(
|
20 |
'pagetype' => 'cart',
|
21 |
-
'id' => $
|
22 |
'price' => $price
|
23 |
);
|
24 |
$product_remarketing_json = json_encode($product_remarketing_data);
|
11 |
{
|
12 |
try {
|
13 |
$product = $observer->getEvent()->getProduct();
|
14 |
+
$quoteItem = $observer->getEvent()->getQuoteItem();
|
15 |
+
$quoteItemProduct= $quoteItem->getProduct();
|
16 |
|
17 |
+
if ($product->getTypeId() == "configurable") {
|
18 |
+
$id = "mag_".$quoteItemProduct->getParentId()."_".$quoteItemProduct->getEntityId();
|
19 |
+
}
|
20 |
+
else {
|
21 |
+
$id = "mag_".$quoteItemProduct->getEntityId();
|
22 |
+
}
|
23 |
$price = $product->getFinalPrice();
|
24 |
|
25 |
+
|
26 |
+
// Mage::log($product->toJson(), null, 'debug.log');
|
27 |
+
// Mage::log($quoteItem->toJson(), null, 'debug.log');
|
28 |
+
|
29 |
// set product as session data
|
30 |
$product_remarketing_data = array(
|
31 |
'pagetype' => 'cart',
|
32 |
+
'id' => $id,
|
33 |
'price' => $price
|
34 |
);
|
35 |
$product_remarketing_json = json_encode($product_remarketing_data);
|
app/code/community/Businessfactory/Roihuntereasy/Model/CheckoutObserver.php
CHANGED
@@ -18,6 +18,8 @@ class Businessfactory_Roihuntereasy_Model_CheckoutObserver extends Mage_Core_Mod
|
|
18 |
|
19 |
$conversionValue = 0;
|
20 |
$productIds = array();
|
|
|
|
|
21 |
|
22 |
$collection = Mage::getResourceModel('sales/order_collection')
|
23 |
->addFieldToFilter('entity_id', array('in' => $orderIds));
|
@@ -25,12 +27,48 @@ class Businessfactory_Roihuntereasy_Model_CheckoutObserver extends Mage_Core_Mod
|
|
25 |
foreach ($collection as $order) {
|
26 |
$conversionValue += $order->getBaseGrandTotal();
|
27 |
|
28 |
-
|
29 |
-
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
}
|
32 |
}
|
33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
$checkout_remarketing_data = array(
|
35 |
'pagetype' => 'checkout',
|
36 |
'id' => $productIds,
|
18 |
|
19 |
$conversionValue = 0;
|
20 |
$productIds = array();
|
21 |
+
$configurableParentItems = array();
|
22 |
+
$configurableChildItems = array();
|
23 |
|
24 |
$collection = Mage::getResourceModel('sales/order_collection')
|
25 |
->addFieldToFilter('entity_id', array('in' => $orderIds));
|
27 |
foreach ($collection as $order) {
|
28 |
$conversionValue += $order->getBaseGrandTotal();
|
29 |
|
30 |
+
// returns all order items
|
31 |
+
// configurable items are separated to two items - one simple with parent_item_id and one configurable with item_id
|
32 |
+
$items = $order->getAllItems();
|
33 |
+
foreach ($items as $item) {
|
34 |
+
$parent_item_id = $item->getParentItemId();
|
35 |
+
$product_type = $item->getProductType();
|
36 |
+
|
37 |
+
if ($parent_item_id == null) {
|
38 |
+
// simple product - write directly to the result IDs array
|
39 |
+
if ($product_type == "simple") {
|
40 |
+
array_push($productIds, "mag_".$item->getProductId());
|
41 |
+
Mage::log("Writing simple product", null, 'debug.log');
|
42 |
+
}
|
43 |
+
// configurable parent product
|
44 |
+
else if ($product_type == "configurable") {
|
45 |
+
array_push($configurableParentItems, $item);
|
46 |
+
Mage::log("Storing configurable parent product", null, 'debug.log');
|
47 |
+
}
|
48 |
+
}
|
49 |
+
// configurable child product
|
50 |
+
else {
|
51 |
+
array_push($configurableChildItems, $item);
|
52 |
+
Mage::log("Storing configurable child product", null, 'debug.log');
|
53 |
+
}
|
54 |
}
|
55 |
}
|
56 |
|
57 |
+
// create map of parent IDS : parent objects
|
58 |
+
$parentItemIdToProductIdMap = array();
|
59 |
+
foreach ($configurableParentItems as $item) {
|
60 |
+
$parentItemIdToProductIdMap[$item['item_id']] = $item['product_id'];
|
61 |
+
}
|
62 |
+
|
63 |
+
Mage::log("Configurable parent products map: %s" % ($parentItemIdToProductIdMap), null, 'debug.log');
|
64 |
+
|
65 |
+
// iterate over children items a find parent item in the map
|
66 |
+
foreach ($configurableChildItems as $item) {
|
67 |
+
$id = "mag_".$parentItemIdToProductIdMap[$item["parent_item_id"]]."_".$item["product_id"];
|
68 |
+
array_push($productIds, $id);
|
69 |
+
}
|
70 |
+
|
71 |
+
// create Google Adwords data
|
72 |
$checkout_remarketing_data = array(
|
73 |
'pagetype' => 'checkout',
|
74 |
'id' => $productIds,
|
app/code/community/Businessfactory/Roihuntereasy/Model/Cron.php
CHANGED
@@ -205,6 +205,10 @@ class Businessfactory_Roihuntereasy_Model_Cron extends Mage_Core_Model_Abstract
|
|
205 |
{
|
206 |
$xmlWriter->startElement('item');
|
207 |
|
|
|
|
|
|
|
|
|
208 |
// process common attributes
|
209 |
$this->write_parent_product_attributes($_product, $xmlWriter);
|
210 |
// process advanced attributes
|
@@ -283,12 +287,10 @@ class Businessfactory_Roihuntereasy_Model_Cron extends Mage_Core_Model_Abstract
|
|
283 |
*/
|
284 |
function write_child_product_attributes($_product, $xmlWriter)
|
285 |
{
|
286 |
-
$xmlWriter->writeElement('g:id', $_product->getId());
|
287 |
$xmlWriter->writeElement('g:image_link', $this->get_image_url($_product));
|
288 |
|
289 |
// $this->_logger->debug('gtin: ' . $_product->getEan());
|
290 |
$xmlWriter->writeElement('g:mpn', $_product->getSku());
|
291 |
-
$xmlWriter->writeElement('g:display_ads_id', $_product->getSku());
|
292 |
if (strlen($_product->getEan()) > 7) {
|
293 |
$xmlWriter->writeElement('g:gtin', $_product->getEan());
|
294 |
}
|
@@ -357,7 +359,10 @@ class Businessfactory_Roihuntereasy_Model_Cron extends Mage_Core_Model_Abstract
|
|
357 |
foreach ($simple_collection as $_childproduct) {
|
358 |
$xmlWriter->startElement('item');
|
359 |
|
360 |
-
|
|
|
|
|
|
|
361 |
|
362 |
// process common attributes
|
363 |
$this->write_parent_product_attributes($_product, $xmlWriter);
|
205 |
{
|
206 |
$xmlWriter->startElement('item');
|
207 |
|
208 |
+
// ID belongs to the simple product's SKU
|
209 |
+
$xmlWriter->writeElement('g:id', "mag_".$_product->getId());
|
210 |
+
$xmlWriter->writeElement('g:display_ads_id', "mag_".$_product->getId());
|
211 |
+
|
212 |
// process common attributes
|
213 |
$this->write_parent_product_attributes($_product, $xmlWriter);
|
214 |
// process advanced attributes
|
287 |
*/
|
288 |
function write_child_product_attributes($_product, $xmlWriter)
|
289 |
{
|
|
|
290 |
$xmlWriter->writeElement('g:image_link', $this->get_image_url($_product));
|
291 |
|
292 |
// $this->_logger->debug('gtin: ' . $_product->getEan());
|
293 |
$xmlWriter->writeElement('g:mpn', $_product->getSku());
|
|
|
294 |
if (strlen($_product->getEan()) > 7) {
|
295 |
$xmlWriter->writeElement('g:gtin', $_product->getEan());
|
296 |
}
|
359 |
foreach ($simple_collection as $_childproduct) {
|
360 |
$xmlWriter->startElement('item');
|
361 |
|
362 |
+
// ID belongs to the child product's ID to make this product unique
|
363 |
+
$xmlWriter->writeElement('g:id', "mag_".$_product->getId()."_".$_childproduct->getId());
|
364 |
+
$xmlWriter->writeElement('g:item_group_id', "mag_".$_product->getId());
|
365 |
+
$xmlWriter->writeElement('g:display_ads_id', "mag_".$_product->getId()."_".$_childproduct->getId());
|
366 |
|
367 |
// process common attributes
|
368 |
$this->write_parent_product_attributes($_product, $xmlWriter);
|
app/design/adminhtml/default/default/template/businessfactory_roihuntereasy/admin.phtml
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
<!--"http://localhost:3000" "http://magento.roihunter.com/" -->
|
2 |
-
<!-- TODO testing url-->
|
3 |
<iframe src="//magento.roihunter.com/"
|
4 |
scrolling="yes"
|
5 |
frameBorder="0"
|
@@ -44,30 +43,31 @@
|
|
44 |
var loadingMessageEl = document.getElementById('loadingMessage');
|
45 |
|
46 |
iFrame.addEventListener('load', function () {
|
47 |
-
|
48 |
-
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
|
|
71 |
});
|
72 |
</script>
|
73 |
|
1 |
<!--"http://localhost:3000" "http://magento.roihunter.com/" -->
|
|
|
2 |
<iframe src="//magento.roihunter.com/"
|
3 |
scrolling="yes"
|
4 |
frameBorder="0"
|
43 |
var loadingMessageEl = document.getElementById('loadingMessage');
|
44 |
|
45 |
iFrame.addEventListener('load', function () {
|
46 |
+
setTimeout(function(){
|
47 |
+
console.log('hiding Loader');
|
48 |
|
49 |
+
// pass base url to React iframe fro future API calls to this site
|
50 |
+
iFrame.contentWindow.postMessage({
|
51 |
+
"type": "roihunter_magento_plugin",
|
52 |
+
"storeUrl": storeUrl,
|
53 |
+
"storeName": storeName,
|
54 |
+
"storeCurrency": storeCurrency,
|
55 |
+
"storeLanguage": storeLanguage,
|
56 |
+
"storeCountry": storeCountry,
|
57 |
+
"magentoMode": magentoMode,
|
58 |
|
59 |
+
// Database part
|
60 |
+
"customerId": customerId,
|
61 |
+
"accessToken": accessToken,
|
62 |
+
"clientToken": clientToken,
|
63 |
+
"managedMerchants": managedMerchants,
|
64 |
+
"adultOriented": adultOriented,
|
65 |
+
"status": status,
|
66 |
+
"errors": errors,
|
67 |
+
"creationState": creationState
|
68 |
+
}, '*'
|
69 |
+
);
|
70 |
+
}, 1000);
|
71 |
});
|
72 |
</script>
|
73 |
|
app/design/frontend/base/default/template/businessfactory_roihuntereasy/product_view_analytics.phtml
CHANGED
@@ -11,7 +11,7 @@ $_prodPrice = null;
|
|
11 |
if ($_product) {
|
12 |
$_prodName = $_product->getName();
|
13 |
$_prodSku = $_product->getSku();
|
14 |
-
$_prodId =
|
15 |
$_prodPrice = $_product->getFinalPrice();
|
16 |
// Regular price without discount
|
17 |
// $_prodPrice = $_product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue();
|
@@ -26,7 +26,7 @@ Remarketing tags may not be associated with personally identifiable information
|
|
26 |
/* <![CDATA[ */
|
27 |
var google_conversion_id = <?php echo $_conversionId ?>;
|
28 |
var google_custom_params = {
|
29 |
-
ecomm_prodid: '<?php echo $
|
30 |
ecomm_pagetype: 'product',
|
31 |
ecomm_totalvalue: <?php echo $_prodPrice ?>,
|
32 |
};;
|
11 |
if ($_product) {
|
12 |
$_prodName = $_product->getName();
|
13 |
$_prodSku = $_product->getSku();
|
14 |
+
$_prodId = "mag_".$_product->getId();
|
15 |
$_prodPrice = $_product->getFinalPrice();
|
16 |
// Regular price without discount
|
17 |
// $_prodPrice = $_product->getPriceInfo()->getPrice('regular_price')->getAmount()->getValue();
|
26 |
/* <![CDATA[ */
|
27 |
var google_conversion_id = <?php echo $_conversionId ?>;
|
28 |
var google_custom_params = {
|
29 |
+
ecomm_prodid: '<?php echo $_prodId ?>',
|
30 |
ecomm_pagetype: 'product',
|
31 |
ecomm_totalvalue: <?php echo $_prodPrice ?>,
|
32 |
};;
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>roihunter_easy</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license>AFL 3.0</license>
|
7 |
<channel>community</channel>
|
@@ -40,11 +40,11 @@ Extension update: 0.00 &#x20AC;&#xD;
|
|
40 |
No support fee&#xD;
|
41 |
No contract duration&#xD;
|
42 |
* Extension do not cover your Google Adwords Ad Spend. </description>
|
43 |
-
<notes>Created
|
44 |
<authors><author><name>ROI Hunter</name><user>MAG003490427</user><email>petr.skornok@b.cz</email></author></authors>
|
45 |
-
<date>2017-03-
|
46 |
-
<time>
|
47 |
-
<contents><target name="magecommunity"><dir name="Businessfactory"><dir name="Roihuntereasy"><dir name="Block"><file name="AddedToCartAnalytics.php" hash="eeb701f487b06ed82e0754aefb192fab"/><dir name="Adminhtml"><file name="Admin.php" hash="87c29e0e4de22b3b73189e1897ca781d"/><dir name="System"><dir name="Config"><file name="Cronbutton.php" hash="a07a6cfbd52a9a96fb4ec78cc8270924"/><file name="Resetbutton.php" hash="7721bb62feafe5d9d2951e70bfb0c30e"/></dir></dir></dir><file name="CategoryViewAnalytics.php" hash="
|
48 |
<compatible/>
|
49 |
<dependencies><required><php><min>5.6.0</min><max>7.0.0</max></php></required></dependencies>
|
50 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>roihunter_easy</name>
|
4 |
+
<version>1.0.3</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>AFL 3.0</license>
|
7 |
<channel>community</channel>
|
40 |
No support fee&#xD;
|
41 |
No contract duration&#xD;
|
42 |
* Extension do not cover your Google Adwords Ad Spend. </description>
|
43 |
+
<notes>Created 3rd March, 2017 Compatibility: 1.9.2.4 - Replaced SKUs with custom IDs</notes>
|
44 |
<authors><author><name>ROI Hunter</name><user>MAG003490427</user><email>petr.skornok@b.cz</email></author></authors>
|
45 |
+
<date>2017-03-08</date>
|
46 |
+
<time>09:33:35</time>
|
47 |
+
<contents><target name="magecommunity"><dir name="Businessfactory"><dir name="Roihuntereasy"><dir name="Block"><file name="AddedToCartAnalytics.php" hash="eeb701f487b06ed82e0754aefb192fab"/><dir name="Adminhtml"><file name="Admin.php" hash="87c29e0e4de22b3b73189e1897ca781d"/><dir name="System"><dir name="Config"><file name="Cronbutton.php" hash="a07a6cfbd52a9a96fb4ec78cc8270924"/><file name="Resetbutton.php" hash="7721bb62feafe5d9d2951e70bfb0c30e"/></dir></dir></dir><file name="CategoryViewAnalytics.php" hash="8a47d9b4b0ad88c2e3fc1aa38258c465"/><file name="CheckoutAnalytics.php" hash="831094424cf896e6644d66b0c70c3688"/><file name="Database.php" hash="4333ce4f66b762097cb50b4f04a7a4d2"/><file name="ProductViewAnalytics.php" hash="033e6702927d92ae5f2d388f00b46bd5"/></dir><dir name="Helper"><file name="Data.php" hash="05ee8de6f74805d4a2b4643b0b0fe33a"/></dir><dir name="Model"><file name="AddedToCartObserver.php" hash="4e6d394f8f0902904e357f441aca6289"/><file name="CheckoutObserver.php" hash="2468bfbdf1083205a0e3aba14d2b7510"/><file name="Cron.php" hash="d1e3bb04cbf1f9dd0cce907dbd724dc3"/><file name="Main.php" hash="06766b59391b52aaa701d8bf01e80d1a"/><file name="Options.php" hash="f6ecd5ab10cfcc5e0948b236bb873932"/><dir name="Resource"><dir name="Main"><file name="Collection.php" hash="9b66b73b312ac16e270c1435a789fdb9"/></dir><file name="Main.php" hash="1432c450ff554fb5057d1d6c4fd26c3c"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="RoihuntereasyController.php" hash="687380dafaffd792a281e2bfd653d027"/></dir><file name="CronController.php" hash="f160c324b60ce92b249731bb97aa1e75"/><file name="FeedController.php" hash="e185b7550c6ef091b5fbcf51f315dc5a"/><file name="IndexController.php" hash="33c2a22770591cbeb7fb394d3654d904"/><file name="ResetController.php" hash="1a6c578829957c0a2ec2a4085ed5a089"/><file name="RoihuntereasyController.php" hash="b2b37f613badb75be2198e6643ef8d85"/><file name="StoredetailsController.php" hash="c4eb4f5f60a80169a561f45ff8587f6e"/></dir><dir name="etc"><file name="adminhtml.xml" hash="bbab6af370448895030570a657469a15"/><file name="config.xml" hash="4b044240a4b1e4081250b429400681f9"/><file name="system.xml" hash="718ea25db00b6a500b8783f9c8e1ba5c"/></dir><dir name="sql"><dir name="businessfactory_roihuntereasy_setup"><file name="install-1.0.0.php" hash="f490ddfd229eb5680e68fb7ec55a5820"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="businessfactory_roihuntereasy.xml" hash="fa2e345d2461459e15c641731d1b114a"/></dir><dir name="template"><dir name="businessfactory_roihuntereasy"><file name="admin.phtml" hash="438db33d6a9ad17748a8a08898143ac9"/><dir name="system"><dir name="config"><file name="cronbutton.phtml" hash="758b97b5da81c92aaeb175e4b0142288"/><file name="resetbutton.phtml" hash="7aedce71c5d21bfce1a08c77e603143d"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="businessfactory_roihuntereasy.xml" hash="e1379f4d0a022d6740d0a6d96fd9fbed"/></dir><dir name="template"><dir name="businessfactory_roihuntereasy"><file name="added_to_cart_view_analytics.phtml" hash="8679d7940136d046ce46d2bc9aa2b522"/><file name="category_view_analytics.phtml" hash="420fe9c183c444e655250efa0b037da4"/><file name="checkout_analytics.phtml" hash="f06507f3867d78e0e6f1791fc210797d"/><file name="index.phtml" hash="a69cff3727b7bba2be7154b94b86ff08"/><file name="product_view_analytics.phtml" hash="a9ce50a31d64edcc70b2bbabd2ebf227"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Businessfactory_Roihuntereasy.xml" hash="d46e92b8a1b158bfdc47b9daa3274a3d"/></dir></target></contents>
|
48 |
<compatible/>
|
49 |
<dependencies><required><php><min>5.6.0</min><max>7.0.0</max></php></required></dependencies>
|
50 |
</package>
|