Version Notes
Changed functionality to move Monetate Tag script before other scripts
Download this release
Release Info
Developer | One Pica Codemaster |
Extension | Monetate_Track |
Version | 1.0.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.0.1
- app/code/community/Monetate/Track/Block/Abstract.php +45 -45
- app/code/community/Monetate/Track/Block/AddCartRows.php +87 -87
- app/code/community/Monetate/Track/Block/Init.php +121 -122
- app/code/community/Monetate/Track/Block/TrackData.php +184 -184
- app/code/community/Monetate/Track/Helper/Data.php +26 -26
- app/code/community/Monetate/Track/Model/Adminhtml/ExportProductFeed.php +96 -96
- app/code/community/Monetate/Track/Model/Observer.php +84 -50
- app/code/community/Monetate/Track/Model/PageCache/Container.php +53 -53
- app/code/community/Monetate/Track/Model/ProductFeed.php +537 -537
- app/code/community/Monetate/Track/controllers/Adminhtml/ProductfeedController.php +47 -47
- app/code/community/Monetate/Track/controllers/Adminhtml/Sftp/ConnectionController.php +41 -41
- app/code/community/Monetate/Track/etc/adminhtml.xml +42 -42
- app/code/community/Monetate/Track/etc/cache.xml +32 -32
- app/code/community/Monetate/Track/etc/config.xml +126 -117
- app/code/community/Monetate/Track/etc/system.xml +103 -103
- app/design/frontend/base/default/layout/monetate/track.xml +58 -58
- app/etc/modules/Monetate_Track.xml +29 -29
- package.xml +9 -12
app/code/community/Monetate/Track/Block/Abstract.php
CHANGED
@@ -1,45 +1,45 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Monetate
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to support@monetate.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Monetate
|
16 |
-
* @package Monetate_Track
|
17 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Abstract Block with general functionality
|
23 |
-
*/
|
24 |
-
abstract class Monetate_Track_Block_Abstract extends Mage_Core_Block_Template
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Returns HTML content to display
|
28 |
-
*
|
29 |
-
* @return string
|
30 |
-
*/
|
31 |
-
abstract protected function _getMonetateHtml();
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Render block HTML
|
35 |
-
*
|
36 |
-
* @return string
|
37 |
-
*/
|
38 |
-
protected function _toHtml()
|
39 |
-
{
|
40 |
-
if (Mage::getStoreConfigFlag('monetate/configuration/enable_tracking')) {
|
41 |
-
return $this->_getMonetateHtml();
|
42 |
-
}
|
43 |
-
return '';
|
44 |
-
}
|
45 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Monetate
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to support@monetate.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Monetate
|
16 |
+
* @package Monetate_Track
|
17 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Abstract Block with general functionality
|
23 |
+
*/
|
24 |
+
abstract class Monetate_Track_Block_Abstract extends Mage_Core_Block_Template
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Returns HTML content to display
|
28 |
+
*
|
29 |
+
* @return string
|
30 |
+
*/
|
31 |
+
abstract protected function _getMonetateHtml();
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Render block HTML
|
35 |
+
*
|
36 |
+
* @return string
|
37 |
+
*/
|
38 |
+
protected function _toHtml()
|
39 |
+
{
|
40 |
+
if (Mage::getStoreConfigFlag('monetate/configuration/enable_tracking')) {
|
41 |
+
return $this->_getMonetateHtml();
|
42 |
+
}
|
43 |
+
return '';
|
44 |
+
}
|
45 |
+
}
|
app/code/community/Monetate/Track/Block/AddCartRows.php
CHANGED
@@ -1,87 +1,87 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Monetate
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to support@monetate.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Monetate
|
16 |
-
* @package Monetate_Track
|
17 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Block with 'addCartRows' method implementation
|
23 |
-
*
|
24 |
-
* This block is independent of the other blocks because
|
25 |
-
* there are special caching considerations for it.
|
26 |
-
*/
|
27 |
-
class Monetate_Track_Block_AddCartRows extends Monetate_Track_Block_Abstract
|
28 |
-
{
|
29 |
-
/**
|
30 |
-
* Render block HTML
|
31 |
-
*
|
32 |
-
* @return string
|
33 |
-
*/
|
34 |
-
protected function _getMonetateHtml()
|
35 |
-
{
|
36 |
-
$cartItems = $this->_getCartItems();
|
37 |
-
if (count($cartItems)) {
|
38 |
-
$html = '
|
39 |
-
<!-- Begin Monetate ExpressTag - AddCartRows -->
|
40 |
-
<script type="text/javascript">
|
41 |
-
//<![CDATA[
|
42 |
-
window.monetateData.cartRows = ' . $this->helper('core')->jsonEncode($cartItems) . ';
|
43 |
-
//]]>
|
44 |
-
</script>
|
45 |
-
<!-- End Monetate ExpressTag -->
|
46 |
-
';
|
47 |
-
return $html;
|
48 |
-
}
|
49 |
-
return '';
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Get items currently in the customers cart
|
54 |
-
*
|
55 |
-
* @return array
|
56 |
-
*/
|
57 |
-
protected function _getCartItems()
|
58 |
-
{
|
59 |
-
$cartItems = array();
|
60 |
-
$quote = Mage::getModel('checkout/cart')->getQuote();
|
61 |
-
if ($quote->hasItems()) {
|
62 |
-
$currencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
|
63 |
-
foreach ($quote->getAllItems() as $item) {
|
64 |
-
if (($item->getParentItem() && $item->getParentItem()->getProduct()->getTypeId() != 'configurable')
|
65 |
-
|| $item->getProduct()->getTypeId() == 'configurable') {
|
66 |
-
continue;
|
67 |
-
} elseif ($item->getParentItem()
|
68 |
-
&& $item->getParentItem()->getProduct()->getTypeId() == 'configurable') {
|
69 |
-
$price = $item->getParentItem()->getPrice();
|
70 |
-
$qty = (int) $item->getParentItem()->getQty();
|
71 |
-
} else {
|
72 |
-
$price = $item->getPrice();
|
73 |
-
$qty = (int) $item->getQty();
|
74 |
-
}
|
75 |
-
$sku = str_replace(' ', '', $this->helper('core/string')->truncate($item->getSku(), 32, ''));
|
76 |
-
$cartItems[] = array(
|
77 |
-
'productId' => $item->getProductId(),
|
78 |
-
'quantity' => $qty,
|
79 |
-
'unitPrice' => number_format($price, '2', '.', ''),
|
80 |
-
'currency' => $currencyCode,
|
81 |
-
'sku' => $sku,
|
82 |
-
);
|
83 |
-
}
|
84 |
-
}
|
85 |
-
return $cartItems;
|
86 |
-
}
|
87 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Monetate
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to support@monetate.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Monetate
|
16 |
+
* @package Monetate_Track
|
17 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Block with 'addCartRows' method implementation
|
23 |
+
*
|
24 |
+
* This block is independent of the other blocks because
|
25 |
+
* there are special caching considerations for it.
|
26 |
+
*/
|
27 |
+
class Monetate_Track_Block_AddCartRows extends Monetate_Track_Block_Abstract
|
28 |
+
{
|
29 |
+
/**
|
30 |
+
* Render block HTML
|
31 |
+
*
|
32 |
+
* @return string
|
33 |
+
*/
|
34 |
+
protected function _getMonetateHtml()
|
35 |
+
{
|
36 |
+
$cartItems = $this->_getCartItems();
|
37 |
+
if (count($cartItems)) {
|
38 |
+
$html = '
|
39 |
+
<!-- Begin Monetate ExpressTag - AddCartRows -->
|
40 |
+
<script type="text/javascript">
|
41 |
+
//<![CDATA[
|
42 |
+
window.monetateData.cartRows = ' . $this->helper('core')->jsonEncode($cartItems) . ';
|
43 |
+
//]]>
|
44 |
+
</script>
|
45 |
+
<!-- End Monetate ExpressTag -->
|
46 |
+
';
|
47 |
+
return $html;
|
48 |
+
}
|
49 |
+
return '';
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Get items currently in the customers cart
|
54 |
+
*
|
55 |
+
* @return array
|
56 |
+
*/
|
57 |
+
protected function _getCartItems()
|
58 |
+
{
|
59 |
+
$cartItems = array();
|
60 |
+
$quote = Mage::getModel('checkout/cart')->getQuote();
|
61 |
+
if ($quote->hasItems()) {
|
62 |
+
$currencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
|
63 |
+
foreach ($quote->getAllItems() as $item) {
|
64 |
+
if (($item->getParentItem() && $item->getParentItem()->getProduct()->getTypeId() != 'configurable')
|
65 |
+
|| $item->getProduct()->getTypeId() == 'configurable') {
|
66 |
+
continue;
|
67 |
+
} elseif ($item->getParentItem()
|
68 |
+
&& $item->getParentItem()->getProduct()->getTypeId() == 'configurable') {
|
69 |
+
$price = $item->getParentItem()->getPrice();
|
70 |
+
$qty = (int) $item->getParentItem()->getQty();
|
71 |
+
} else {
|
72 |
+
$price = $item->getPrice();
|
73 |
+
$qty = (int) $item->getQty();
|
74 |
+
}
|
75 |
+
$sku = str_replace(' ', '', $this->helper('core/string')->truncate($item->getSku(), 32, ''));
|
76 |
+
$cartItems[] = array(
|
77 |
+
'productId' => $item->getProductId(),
|
78 |
+
'quantity' => $qty,
|
79 |
+
'unitPrice' => number_format($price, '2', '.', ''),
|
80 |
+
'currency' => $currencyCode,
|
81 |
+
'sku' => $sku,
|
82 |
+
);
|
83 |
+
}
|
84 |
+
}
|
85 |
+
return $cartItems;
|
86 |
+
}
|
87 |
+
}
|
app/code/community/Monetate/Track/Block/Init.php
CHANGED
@@ -1,122 +1,121 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Monetate
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to support@monetate.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Monetate
|
16 |
-
* @package Monetate_Track
|
17 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Block with Monetate tag initialization functionality
|
23 |
-
*/
|
24 |
-
class Monetate_Track_Block_Init extends Monetate_Track_Block_Abstract
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Render block HTML
|
28 |
-
*
|
29 |
-
* @return string
|
30 |
-
*/
|
31 |
-
protected function _getMonetateHtml()
|
32 |
-
{
|
33 |
-
$html =
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
window.
|
39 |
-
window.monetateData =
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
*
|
50 |
-
*
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
$pageIdentifier
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
$category
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
case '
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
case '
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
case '
|
106 |
-
case '
|
107 |
-
case '
|
108 |
-
|
109 |
-
|
110 |
-
case '
|
111 |
-
case '
|
112 |
-
case '
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Monetate
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to support@monetate.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Monetate
|
16 |
+
* @package Monetate_Track
|
17 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Block with Monetate tag initialization functionality
|
23 |
+
*/
|
24 |
+
class Monetate_Track_Block_Init extends Monetate_Track_Block_Abstract
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Render block HTML
|
28 |
+
*
|
29 |
+
* @return string
|
30 |
+
*/
|
31 |
+
protected function _getMonetateHtml()
|
32 |
+
{
|
33 |
+
$html = '
|
34 |
+
<!-- Begin Monetate ExpressTag - Init -->
|
35 |
+
<script type="text/javascript">
|
36 |
+
//<![CDATA[
|
37 |
+
window.monetateQ = window.monetateQ || [];
|
38 |
+
window.monetateData = window.monetateData || {};
|
39 |
+
window.monetateData.pageType = "'.$this->_getPageType().'";
|
40 |
+
//]]>
|
41 |
+
</script>
|
42 |
+
<!-- End Monetate ExpressTag -->
|
43 |
+
';
|
44 |
+
return $html;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Get page identifier
|
49 |
+
*
|
50 |
+
* @return string
|
51 |
+
*/
|
52 |
+
protected function _getPageType()
|
53 |
+
{
|
54 |
+
$pageIdentifier = $this->getAction()->getFullActionName();
|
55 |
+
switch ($pageIdentifier) {
|
56 |
+
/**
|
57 |
+
* Home Page / Catalog Pages
|
58 |
+
*/
|
59 |
+
case 'cms_index_index':
|
60 |
+
return 'main';
|
61 |
+
case 'catalog_category_view':
|
62 |
+
$category = Mage::registry('current_category');
|
63 |
+
if ($category && $category->getId() && $category->getDisplayMode() == 'PAGE') {
|
64 |
+
return 'category';
|
65 |
+
}
|
66 |
+
return 'index';
|
67 |
+
case 'catalog_product_view':
|
68 |
+
return 'product';
|
69 |
+
case 'catalogsearch_result_index':
|
70 |
+
case 'catalogsearch_advanced_result':
|
71 |
+
return 'search';
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Account Pages
|
75 |
+
*/
|
76 |
+
case 'customer_account_login':
|
77 |
+
return 'login';
|
78 |
+
case 'customer_account_create':
|
79 |
+
return 'signup';
|
80 |
+
case 'customer_account_index':
|
81 |
+
return 'account';
|
82 |
+
case 'sales_order_view':
|
83 |
+
return 'orderstatus';
|
84 |
+
case 'wishlist_index_index':
|
85 |
+
case 'wishlist_index_share':
|
86 |
+
return 'wishlist';
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Cart/Checkout
|
90 |
+
*/
|
91 |
+
case 'checkout_cart_index':
|
92 |
+
return 'cart';
|
93 |
+
case 'checkout_onepage_index':
|
94 |
+
if ($this->helper('customer')->isLoggedIn()) {
|
95 |
+
return 'billing';
|
96 |
+
}
|
97 |
+
return 'checkoutLogin';
|
98 |
+
case 'checkout_onepage_success':
|
99 |
+
return 'purchase';
|
100 |
+
case 'checkout_multishipping_login':
|
101 |
+
return 'checkoutLogin';
|
102 |
+
case 'checkout_multishipping_register':
|
103 |
+
return 'signup';
|
104 |
+
case 'checkout_multishipping_addresses':
|
105 |
+
case 'checkout_multishipping_address_newShipping':
|
106 |
+
case 'checkout_multishipping_address_editShipping':
|
107 |
+
case 'checkout_multishipping_shipping':
|
108 |
+
return 'shipping';
|
109 |
+
case 'checkout_multishipping_billing':
|
110 |
+
case 'checkout_multishipping_address_selectBilling':
|
111 |
+
case 'checkout_multishipping_address_newBilling':
|
112 |
+
case 'checkout_multishipping_address_editBilling':
|
113 |
+
return 'billing';
|
114 |
+
case 'checkout_multishipping_overview':
|
115 |
+
return 'checkout';
|
116 |
+
case 'checkout_multishipping_success':
|
117 |
+
return 'purchase';
|
118 |
+
}
|
119 |
+
return 'unknown';
|
120 |
+
}
|
121 |
+
}
|
|
app/code/community/Monetate/Track/Block/TrackData.php
CHANGED
@@ -1,184 +1,184 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Monetate
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to support@monetate.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Monetate
|
16 |
-
* @package Monetate_Track
|
17 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Block with 'trackData' method implementation
|
23 |
-
*/
|
24 |
-
class Monetate_Track_Block_TrackData extends Monetate_Track_Block_Abstract
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Push items to render
|
28 |
-
*/
|
29 |
-
protected $_pushItems = array();
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Render block HTML
|
33 |
-
*
|
34 |
-
* @return string
|
35 |
-
*/
|
36 |
-
protected function _getMonetateHtml()
|
37 |
-
{
|
38 |
-
//Start Javascript
|
39 |
-
$html = '
|
40 |
-
<!-- Begin Monetate ExpressTag - TrackData -->
|
41 |
-
<script type="text/javascript">
|
42 |
-
//<![CDATA[
|
43 |
-
window.monetateQ.push(["setPageType", window.monetateData.pageType]);
|
44 |
-
if(window.monetateData.cartRows) window.monetateQ.push(["addCartRows", window.monetateData.cartRows]);';
|
45 |
-
|
46 |
-
//Add Push Items
|
47 |
-
$this->addPushItem('trackData');
|
48 |
-
foreach ($this->_pushItems as $key => $data) {
|
49 |
-
if ($data === null) {
|
50 |
-
$html .= '
|
51 |
-
window.monetateQ.push(["' . $key . '"]);';
|
52 |
-
} else {
|
53 |
-
$html .= '
|
54 |
-
window.monetateQ.push(["' . $key . '", ' . $this->helper('core')->jsonEncode($data) . ']);';
|
55 |
-
}
|
56 |
-
}
|
57 |
-
|
58 |
-
//Add Onepage Checkout Observer
|
59 |
-
if ($this->getOnepageEnabled()) {
|
60 |
-
$html .= '
|
61 |
-
|
62 |
-
if (window.checkout != undefined && window.checkout.accordion != undefined
|
63 |
-
&& typeof window.checkout.accordion.openSection === "function") {
|
64 |
-
window.checkout.accordion.openSection = function(section){
|
65 |
-
Accordion.prototype.openSection.call(this, section);
|
66 |
-
var map = { "opc-login":"checkoutLogin", "opc-billing":"billing", "opc-shipping":"shipping",
|
67 |
-
"opc-shipping_method":"shipping", "opc-payment":"billing", opc-review":"checkout" };
|
68 |
-
window.monetateData.pageType = map[this.currentSection] || "unknown";
|
69 |
-
window.monetateQ.push(["setPageType", window.monetateData.pageType]);
|
70 |
-
if(window.monetateData.cartRows) window.monetateQ.push(["addCartRows", window.monetateData.cartRows]);
|
71 |
-
window.monetateQ.push(["trackData"]);
|
72 |
-
};
|
73 |
-
}';
|
74 |
-
}
|
75 |
-
|
76 |
-
//Finish Javascript
|
77 |
-
$html .= '
|
78 |
-
//]]>
|
79 |
-
</script>
|
80 |
-
<!-- End Monetate ExpressTag -->
|
81 |
-
';
|
82 |
-
return $html;
|
83 |
-
}
|
84 |
-
|
85 |
-
/**
|
86 |
-
* Edit item to push data
|
87 |
-
*
|
88 |
-
* @param string $key
|
89 |
-
* @param mixed $data
|
90 |
-
*/
|
91 |
-
public function addPushItem($key, $data = null)
|
92 |
-
{
|
93 |
-
$this->_pushItems[$key] = $data;
|
94 |
-
}
|
95 |
-
|
96 |
-
/**
|
97 |
-
* Implement 'addCategories' functionality
|
98 |
-
*/
|
99 |
-
public function addCategories()
|
100 |
-
{
|
101 |
-
$category = Mage::registry('current_category');
|
102 |
-
if ($category->getId()) {
|
103 |
-
$this->addPushItem('addCategories', array($category->getId()));
|
104 |
-
}
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Implement 'addProducts' functionality
|
109 |
-
*
|
110 |
-
* @param Mage_Catalog_Model_Resource_Product_Collection $collection
|
111 |
-
*/
|
112 |
-
public function addProducts($collection)
|
113 |
-
{
|
114 |
-
if ($collection instanceof Varien_Data_Collection) {
|
115 |
-
$productIds = $collection->getColumnValues('entity_id');
|
116 |
-
if (count($productIds)) {
|
117 |
-
$this->addPushItem('addProducts', $productIds);
|
118 |
-
}
|
119 |
-
}
|
120 |
-
}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Implement 'addProductDetails' functionality
|
124 |
-
*/
|
125 |
-
public function addProductDetails()
|
126 |
-
{
|
127 |
-
$product = Mage::registry('current_product');
|
128 |
-
if ($product->getId()) {
|
129 |
-
$productIds = array($product->getId());
|
130 |
-
if ($product->getTypeId() == 'grouped') {
|
131 |
-
$associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
|
132 |
-
if ($associatedProducts) {
|
133 |
-
$productIds = array();
|
134 |
-
foreach ($associatedProducts as $associatedProduct) {
|
135 |
-
$productIds[] = $associatedProduct->getId();
|
136 |
-
}
|
137 |
-
}
|
138 |
-
}
|
139 |
-
$this->addPushItem('addProductDetails', $productIds);
|
140 |
-
}
|
141 |
-
}
|
142 |
-
|
143 |
-
/**
|
144 |
-
* Implement 'addPurchaseRows' functionality
|
145 |
-
*/
|
146 |
-
public function addPurchaseRows($orderIds)
|
147 |
-
{
|
148 |
-
if (is_array($orderIds)) {
|
149 |
-
$purchasedRows = array();
|
150 |
-
foreach ($orderIds as $orderId) {
|
151 |
-
$order = Mage::getModel('sales/order')->load($orderId);
|
152 |
-
if ($order->getId()) {
|
153 |
-
$currencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
|
154 |
-
foreach ($order->getAllItems() as $item) {
|
155 |
-
$price = $qty = 0;
|
156 |
-
$parent = $item->getParentItem();
|
157 |
-
if (($parent !== null && $parent->getProductType() != 'configurable')
|
158 |
-
|| $item->getProductType() == 'configurable') {
|
159 |
-
continue;
|
160 |
-
} elseif ($parent && $parent->getProductType() == 'configurable') {
|
161 |
-
$price = $item->getParentItem()->getPrice();
|
162 |
-
$qty = (int) $item->getParentItem()->getQtyOrdered();
|
163 |
-
} else {
|
164 |
-
$price = $item->getPrice();
|
165 |
-
$qty = (int) $item->getQtyOrdered();
|
166 |
-
}
|
167 |
-
$sku = str_replace(' ', '', $this->helper('core/string')->truncate($item->getSku(), 32, ''));
|
168 |
-
$purchasedRows[] = array(
|
169 |
-
'purchaseId' => $order->getIncrementId(),
|
170 |
-
'productId' => $item->getProductId(),
|
171 |
-
'quantity' => (int) $qty,
|
172 |
-
'unitPrice' => number_format($price, '2', '.', ''),
|
173 |
-
'currency' => $currencyCode,
|
174 |
-
'sku' => $sku,
|
175 |
-
);
|
176 |
-
}
|
177 |
-
}
|
178 |
-
}
|
179 |
-
if (count($purchasedRows)) {
|
180 |
-
$this->addPushItem('addPurchaseRows', $purchasedRows);
|
181 |
-
}
|
182 |
-
}
|
183 |
-
}
|
184 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Monetate
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to support@monetate.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Monetate
|
16 |
+
* @package Monetate_Track
|
17 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Block with 'trackData' method implementation
|
23 |
+
*/
|
24 |
+
class Monetate_Track_Block_TrackData extends Monetate_Track_Block_Abstract
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Push items to render
|
28 |
+
*/
|
29 |
+
protected $_pushItems = array();
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Render block HTML
|
33 |
+
*
|
34 |
+
* @return string
|
35 |
+
*/
|
36 |
+
protected function _getMonetateHtml()
|
37 |
+
{
|
38 |
+
//Start Javascript
|
39 |
+
$html = '
|
40 |
+
<!-- Begin Monetate ExpressTag - TrackData -->
|
41 |
+
<script type="text/javascript">
|
42 |
+
//<![CDATA[
|
43 |
+
window.monetateQ.push(["setPageType", window.monetateData.pageType]);
|
44 |
+
if(window.monetateData.cartRows) window.monetateQ.push(["addCartRows", window.monetateData.cartRows]);';
|
45 |
+
|
46 |
+
//Add Push Items
|
47 |
+
$this->addPushItem('trackData');
|
48 |
+
foreach ($this->_pushItems as $key => $data) {
|
49 |
+
if ($data === null) {
|
50 |
+
$html .= '
|
51 |
+
window.monetateQ.push(["' . $key . '"]);';
|
52 |
+
} else {
|
53 |
+
$html .= '
|
54 |
+
window.monetateQ.push(["' . $key . '", ' . $this->helper('core')->jsonEncode($data) . ']);';
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
//Add Onepage Checkout Observer
|
59 |
+
if ($this->getOnepageEnabled()) {
|
60 |
+
$html .= '
|
61 |
+
|
62 |
+
if (window.checkout != undefined && window.checkout.accordion != undefined
|
63 |
+
&& typeof window.checkout.accordion.openSection === "function") {
|
64 |
+
window.checkout.accordion.openSection = function(section){
|
65 |
+
Accordion.prototype.openSection.call(this, section);
|
66 |
+
var map = { "opc-login":"checkoutLogin", "opc-billing":"billing", "opc-shipping":"shipping",
|
67 |
+
"opc-shipping_method":"shipping", "opc-payment":"billing", "opc-review":"checkout" };
|
68 |
+
window.monetateData.pageType = map[this.currentSection] || "unknown";
|
69 |
+
window.monetateQ.push(["setPageType", window.monetateData.pageType]);
|
70 |
+
if(window.monetateData.cartRows) window.monetateQ.push(["addCartRows", window.monetateData.cartRows]);
|
71 |
+
window.monetateQ.push(["trackData"]);
|
72 |
+
};
|
73 |
+
}';
|
74 |
+
}
|
75 |
+
|
76 |
+
//Finish Javascript
|
77 |
+
$html .= '
|
78 |
+
//]]>
|
79 |
+
</script>
|
80 |
+
<!-- End Monetate ExpressTag -->
|
81 |
+
';
|
82 |
+
return $html;
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Edit item to push data
|
87 |
+
*
|
88 |
+
* @param string $key
|
89 |
+
* @param mixed $data
|
90 |
+
*/
|
91 |
+
public function addPushItem($key, $data = null)
|
92 |
+
{
|
93 |
+
$this->_pushItems[$key] = $data;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Implement 'addCategories' functionality
|
98 |
+
*/
|
99 |
+
public function addCategories()
|
100 |
+
{
|
101 |
+
$category = Mage::registry('current_category');
|
102 |
+
if ($category->getId()) {
|
103 |
+
$this->addPushItem('addCategories', array($category->getId()));
|
104 |
+
}
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Implement 'addProducts' functionality
|
109 |
+
*
|
110 |
+
* @param Mage_Catalog_Model_Resource_Product_Collection $collection
|
111 |
+
*/
|
112 |
+
public function addProducts($collection)
|
113 |
+
{
|
114 |
+
if ($collection instanceof Varien_Data_Collection) {
|
115 |
+
$productIds = $collection->getColumnValues('entity_id');
|
116 |
+
if (count($productIds)) {
|
117 |
+
$this->addPushItem('addProducts', $productIds);
|
118 |
+
}
|
119 |
+
}
|
120 |
+
}
|
121 |
+
|
122 |
+
/**
|
123 |
+
* Implement 'addProductDetails' functionality
|
124 |
+
*/
|
125 |
+
public function addProductDetails()
|
126 |
+
{
|
127 |
+
$product = Mage::registry('current_product');
|
128 |
+
if ($product->getId()) {
|
129 |
+
$productIds = array($product->getId());
|
130 |
+
if ($product->getTypeId() == 'grouped') {
|
131 |
+
$associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
|
132 |
+
if ($associatedProducts) {
|
133 |
+
$productIds = array();
|
134 |
+
foreach ($associatedProducts as $associatedProduct) {
|
135 |
+
$productIds[] = $associatedProduct->getId();
|
136 |
+
}
|
137 |
+
}
|
138 |
+
}
|
139 |
+
$this->addPushItem('addProductDetails', $productIds);
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Implement 'addPurchaseRows' functionality
|
145 |
+
*/
|
146 |
+
public function addPurchaseRows($orderIds)
|
147 |
+
{
|
148 |
+
if (is_array($orderIds)) {
|
149 |
+
$purchasedRows = array();
|
150 |
+
foreach ($orderIds as $orderId) {
|
151 |
+
$order = Mage::getModel('sales/order')->load($orderId);
|
152 |
+
if ($order->getId()) {
|
153 |
+
$currencyCode = Mage::app()->getStore()->getCurrentCurrencyCode();
|
154 |
+
foreach ($order->getAllItems() as $item) {
|
155 |
+
$price = $qty = 0;
|
156 |
+
$parent = $item->getParentItem();
|
157 |
+
if (($parent !== null && $parent->getProductType() != 'configurable')
|
158 |
+
|| $item->getProductType() == 'configurable') {
|
159 |
+
continue;
|
160 |
+
} elseif ($parent && $parent->getProductType() == 'configurable') {
|
161 |
+
$price = $item->getParentItem()->getPrice();
|
162 |
+
$qty = (int) $item->getParentItem()->getQtyOrdered();
|
163 |
+
} else {
|
164 |
+
$price = $item->getPrice();
|
165 |
+
$qty = (int) $item->getQtyOrdered();
|
166 |
+
}
|
167 |
+
$sku = str_replace(' ', '', $this->helper('core/string')->truncate($item->getSku(), 32, ''));
|
168 |
+
$purchasedRows[] = array(
|
169 |
+
'purchaseId' => $order->getIncrementId(),
|
170 |
+
'productId' => $item->getProductId(),
|
171 |
+
'quantity' => (int) $qty,
|
172 |
+
'unitPrice' => number_format($price, '2', '.', ''),
|
173 |
+
'currency' => $currencyCode,
|
174 |
+
'sku' => $sku,
|
175 |
+
);
|
176 |
+
}
|
177 |
+
}
|
178 |
+
}
|
179 |
+
if (count($purchasedRows)) {
|
180 |
+
$this->addPushItem('addPurchaseRows', $purchasedRows);
|
181 |
+
}
|
182 |
+
}
|
183 |
+
}
|
184 |
+
}
|
app/code/community/Monetate/Track/Helper/Data.php
CHANGED
@@ -1,26 +1,26 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Monetate
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to support@monetate.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Monetate
|
16 |
-
* @package Monetate_Track
|
17 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Monetate_Track module's default helper
|
23 |
-
*/
|
24 |
-
class Monetate_Track_Helper_Data extends Mage_Core_Helper_Abstract
|
25 |
-
{
|
26 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Monetate
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to support@monetate.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Monetate
|
16 |
+
* @package Monetate_Track
|
17 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Monetate_Track module's default helper
|
23 |
+
*/
|
24 |
+
class Monetate_Track_Helper_Data extends Mage_Core_Helper_Abstract
|
25 |
+
{
|
26 |
+
}
|
app/code/community/Monetate/Track/Model/Adminhtml/ExportProductFeed.php
CHANGED
@@ -1,96 +1,96 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Monetate
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to support@monetate.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Monetate
|
16 |
-
* @package Monetate_Track
|
17 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Export product feed settings model
|
23 |
-
*/
|
24 |
-
class Monetate_Track_Model_Adminhtml_ExportProductFeed extends Mage_Core_Model_Abstract
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Outputs comment under the element in configuration
|
28 |
-
*
|
29 |
-
* @param Mage_Core_Model_Config_Element $element
|
30 |
-
* @param string $currentValue
|
31 |
-
*
|
32 |
-
* @return string
|
33 |
-
*/
|
34 |
-
public function getCommentText(Mage_Core_Model_Config_Element $element, $currentValue)
|
35 |
-
{
|
36 |
-
$helper = Mage::helper('monetate_track');
|
37 |
-
$result = '<a id="monetate_sftp_test_connection" href="#" onclick="sftp_connection_test();">' . $helper->__('Test SFTP Connection') . '</a><br />';
|
38 |
-
$result .= '<a id="monetate_export_run" href="#" onclick="product_feed_export()">' . $helper->__('Run Product Feed Export') . '</a><br />';
|
39 |
-
$result .= $helper->__('Product Feed Data Exports Statuses file is located in {{base_dir}}/var/monetate.log<br />');
|
40 |
-
$result .= $helper->__('Product Feed Data Export Detailed files are located in {{base_dir}}/var/monetate/<br />');
|
41 |
-
$result .= '<script type="text/javascript">';
|
42 |
-
$result .= "
|
43 |
-
function sftp_connection_test()
|
44 |
-
{
|
45 |
-
parameters = {
|
46 |
-
host: '" . Mage::getStoreConfig('monetate/export/monetate_sftp_host') . "',
|
47 |
-
username: $('monetate_export_sftp_user').getValue(),
|
48 |
-
password: $('monetate_export_sftp_password').getValue(),
|
49 |
-
port: '" . Mage::getStoreConfig('monetate/export/monetate_sftp_port') . "',
|
50 |
-
timeout: '" . Mage::getStoreConfig('monetate/export/monetate_sftp_timeout') . "'
|
51 |
-
};
|
52 |
-
send_ajax_request('" . Mage::helper('adminhtml')->getUrl('monetate_track/adminhtml_sftp_connection/test') . "', parameters, 'monetate_sftp_test_connection', 'monetate_sftp_test_connection_result');
|
53 |
-
}
|
54 |
-
|
55 |
-
function product_feed_export()
|
56 |
-
{
|
57 |
-
parameters = {};
|
58 |
-
send_ajax_request('" . Mage::helper('adminhtml')->getUrl('monetate_track/adminhtml_productfeed/export') . "', parameters, 'monetate_export_run', 'monetate_export_run_result');
|
59 |
-
}
|
60 |
-
|
61 |
-
function send_ajax_request(url, parameters, buttonId, resultId)
|
62 |
-
{
|
63 |
-
if ($(resultId) == undefined) {
|
64 |
-
$(buttonId).insert({after: '<span id=\'' + resultId + '\' class=\'bold\'> Processing</span>'});
|
65 |
-
} else {
|
66 |
-
$(resultId).update(' " . $helper->__('Processing') . "');
|
67 |
-
$(resultId).style.color = 'black';
|
68 |
-
}
|
69 |
-
new Ajax.Request(url, {
|
70 |
-
method: 'post',
|
71 |
-
parameters: parameters,
|
72 |
-
timeout: 3000,
|
73 |
-
onSuccess: function(response) {
|
74 |
-
if (response.responseText == 'Success') {
|
75 |
-
$(resultId).update(' " . $helper->__('Success') . "');
|
76 |
-
$(resultId).style.color = 'green';
|
77 |
-
} else {
|
78 |
-
$(resultId).update(' ' + '" . $helper->__('Fail') . "');
|
79 |
-
$(resultId).style.color = 'red';
|
80 |
-
responseText = response.responseText
|
81 |
-
.replace(/(<([^>]+)>)/ig, '')
|
82 |
-
.replace(/^\\s*$[\\n\\r]{1,}/gm, '')
|
83 |
-
.split('\\n')[0];
|
84 |
-
console.log(responseText);
|
85 |
-
}
|
86 |
-
},
|
87 |
-
onFailure: function(response) {
|
88 |
-
$(resultId).update(' " . $helper->__('Fail') . "');
|
89 |
-
$(resultId).style.color = 'red';
|
90 |
-
},
|
91 |
-
});
|
92 |
-
}";
|
93 |
-
$result .= '</script>';
|
94 |
-
return $result;
|
95 |
-
}
|
96 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Monetate
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to support@monetate.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Monetate
|
16 |
+
* @package Monetate_Track
|
17 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Export product feed settings model
|
23 |
+
*/
|
24 |
+
class Monetate_Track_Model_Adminhtml_ExportProductFeed extends Mage_Core_Model_Abstract
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Outputs comment under the element in configuration
|
28 |
+
*
|
29 |
+
* @param Mage_Core_Model_Config_Element $element
|
30 |
+
* @param string $currentValue
|
31 |
+
*
|
32 |
+
* @return string
|
33 |
+
*/
|
34 |
+
public function getCommentText(Mage_Core_Model_Config_Element $element, $currentValue)
|
35 |
+
{
|
36 |
+
$helper = Mage::helper('monetate_track');
|
37 |
+
$result = '<a id="monetate_sftp_test_connection" href="#" onclick="sftp_connection_test();">' . $helper->__('Test SFTP Connection') . '</a><br />';
|
38 |
+
$result .= '<a id="monetate_export_run" href="#" onclick="product_feed_export()">' . $helper->__('Run Product Feed Export') . '</a><br />';
|
39 |
+
$result .= $helper->__('Product Feed Data Exports Statuses file is located in {{base_dir}}/var/monetate.log<br />');
|
40 |
+
$result .= $helper->__('Product Feed Data Export Detailed files are located in {{base_dir}}/var/monetate/<br />');
|
41 |
+
$result .= '<script type="text/javascript">';
|
42 |
+
$result .= "
|
43 |
+
function sftp_connection_test()
|
44 |
+
{
|
45 |
+
parameters = {
|
46 |
+
host: '" . Mage::getStoreConfig('monetate/export/monetate_sftp_host') . "',
|
47 |
+
username: $('monetate_export_sftp_user').getValue(),
|
48 |
+
password: $('monetate_export_sftp_password').getValue(),
|
49 |
+
port: '" . Mage::getStoreConfig('monetate/export/monetate_sftp_port') . "',
|
50 |
+
timeout: '" . Mage::getStoreConfig('monetate/export/monetate_sftp_timeout') . "'
|
51 |
+
};
|
52 |
+
send_ajax_request('" . Mage::helper('adminhtml')->getUrl('monetate_track/adminhtml_sftp_connection/test') . "', parameters, 'monetate_sftp_test_connection', 'monetate_sftp_test_connection_result');
|
53 |
+
}
|
54 |
+
|
55 |
+
function product_feed_export()
|
56 |
+
{
|
57 |
+
parameters = {};
|
58 |
+
send_ajax_request('" . Mage::helper('adminhtml')->getUrl('monetate_track/adminhtml_productfeed/export') . "', parameters, 'monetate_export_run', 'monetate_export_run_result');
|
59 |
+
}
|
60 |
+
|
61 |
+
function send_ajax_request(url, parameters, buttonId, resultId)
|
62 |
+
{
|
63 |
+
if ($(resultId) == undefined) {
|
64 |
+
$(buttonId).insert({after: '<span id=\'' + resultId + '\' class=\'bold\'> Processing</span>'});
|
65 |
+
} else {
|
66 |
+
$(resultId).update(' " . $helper->__('Processing') . "');
|
67 |
+
$(resultId).style.color = 'black';
|
68 |
+
}
|
69 |
+
new Ajax.Request(url, {
|
70 |
+
method: 'post',
|
71 |
+
parameters: parameters,
|
72 |
+
timeout: 3000,
|
73 |
+
onSuccess: function(response) {
|
74 |
+
if (response.responseText == 'Success') {
|
75 |
+
$(resultId).update(' " . $helper->__('Success') . "');
|
76 |
+
$(resultId).style.color = 'green';
|
77 |
+
} else {
|
78 |
+
$(resultId).update(' ' + '" . $helper->__('Fail') . "');
|
79 |
+
$(resultId).style.color = 'red';
|
80 |
+
responseText = response.responseText
|
81 |
+
.replace(/(<([^>]+)>)/ig, '')
|
82 |
+
.replace(/^\\s*$[\\n\\r]{1,}/gm, '')
|
83 |
+
.split('\\n')[0];
|
84 |
+
console.log(responseText);
|
85 |
+
}
|
86 |
+
},
|
87 |
+
onFailure: function(response) {
|
88 |
+
$(resultId).update(' " . $helper->__('Fail') . "');
|
89 |
+
$(resultId).style.color = 'red';
|
90 |
+
},
|
91 |
+
});
|
92 |
+
}";
|
93 |
+
$result .= '</script>';
|
94 |
+
return $result;
|
95 |
+
}
|
96 |
+
}
|
app/code/community/Monetate/Track/Model/Observer.php
CHANGED
@@ -1,50 +1,84 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Monetate
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to support@monetate.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Monetate
|
16 |
-
* @package Monetate_Track
|
17 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Monetate_Track module's observer
|
23 |
-
*/
|
24 |
-
class Monetate_Track_Model_Observer
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Add
|
28 |
-
*
|
29 |
-
* @param Varien_Event_Observer $observer
|
30 |
-
*/
|
31 |
-
public function
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Monetate
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to support@monetate.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Monetate
|
16 |
+
* @package Monetate_Track
|
17 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Monetate_Track module's observer
|
23 |
+
*/
|
24 |
+
class Monetate_Track_Model_Observer
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Add Monetate Tag script to head
|
28 |
+
*
|
29 |
+
* @param Varien_Event_Observer $observer
|
30 |
+
*/
|
31 |
+
public function observeBlockShowing(Varien_Event_Observer $observer)
|
32 |
+
{
|
33 |
+
$block = $observer->getBlock();
|
34 |
+
if ($block instanceof Mage_Page_Block_Html_Head) {
|
35 |
+
$transport = $observer->getTransport();
|
36 |
+
$html = $this->_htmlJsInsert($transport->getHtml(), Mage::getStoreConfig('monetate/configuration/tag'));
|
37 |
+
$transport->setHtml($html);
|
38 |
+
}
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Add 'addProductsBlock' block's HTML to blocks' HTML with type 'catalog/product_list'
|
43 |
+
*
|
44 |
+
* @param Varien_Event_Observer $observer
|
45 |
+
*/
|
46 |
+
public function observeProductListCollection(Varien_Event_Observer $observer) {
|
47 |
+
$block = Mage::app()->getLayout()->getBlock('monetate.track.track.data');
|
48 |
+
if ($block instanceof Monetate_Track_Block_TrackData) {
|
49 |
+
$block->addProducts($observer->getCollection());
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Add Purchase Rows to page
|
55 |
+
*
|
56 |
+
* @param Varien_Event_Observer $observer
|
57 |
+
*/
|
58 |
+
public function observeOrderSuccess(Varien_Event_Observer $observer)
|
59 |
+
{
|
60 |
+
$block = Mage::app()->getLayout()->getBlock('monetate.track.track.data');
|
61 |
+
if ($block instanceof Monetate_Track_Block_TrackData) {
|
62 |
+
$block->addPurchaseRows($observer->getOrderIds());
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Insert script before other scripts in HTML code
|
68 |
+
*
|
69 |
+
* @param string $html
|
70 |
+
* @param string $tagHtml
|
71 |
+
*/
|
72 |
+
protected function _htmlJsInsert($html, $tagHtml)
|
73 |
+
{
|
74 |
+
if (mb_strpos($html, '<script', null, 'utf-8') < mb_strpos($html, '<!--[if', null, 'utf-8')) {
|
75 |
+
$scriptStartPos = mb_strpos($html, '<script', null, 'utf-8');
|
76 |
+
} else {
|
77 |
+
$scriptStartPos = mb_strpos($html, '<!--[if', null, 'utf-8');
|
78 |
+
}
|
79 |
+
$htmlBefore = mb_substr($html, 0, $scriptStartPos);
|
80 |
+
$htmlAfter = mb_substr($html, $scriptStartPos, mb_strlen($html, 'utf-8') - $scriptStartPos);
|
81 |
+
|
82 |
+
return $htmlBefore . $tagHtml . $htmlAfter;
|
83 |
+
}
|
84 |
+
}
|
app/code/community/Monetate/Track/Model/PageCache/Container.php
CHANGED
@@ -1,53 +1,53 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Monetate
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to support@monetate.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Monetate
|
16 |
-
* @package Monetate_Track
|
17 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Container model for blocks that should not be cached
|
23 |
-
*/
|
24 |
-
class Monetate_Track_Model_PageCache_Container extends Enterprise_PageCache_Model_Container_Advanced_Quote
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Cache tag prefix
|
28 |
-
*/
|
29 |
-
const CACHE_TAG_PREFIX = 'monetate_track_';
|
30 |
-
|
31 |
-
/**
|
32 |
-
* Get identifier from cookies
|
33 |
-
*
|
34 |
-
* @return string
|
35 |
-
*/
|
36 |
-
protected function _getIdentifier()
|
37 |
-
{
|
38 |
-
return $this->_getCookieValue(Enterprise_PageCache_Model_Cookie::COOKIE_CART, '')
|
39 |
-
. $this->_getCookieValue(Enterprise_PageCache_Model_Cookie::COOKIE_CUSTOMER, '');
|
40 |
-
}
|
41 |
-
|
42 |
-
/**
|
43 |
-
* Render block content
|
44 |
-
*
|
45 |
-
* @return string
|
46 |
-
*/
|
47 |
-
protected function _renderBlock()
|
48 |
-
{
|
49 |
-
$blockClass = $this->_placeholder->getAttribute('block');
|
50 |
-
$block = new $blockClass;
|
51 |
-
return $block->toHtml();
|
52 |
-
}
|
53 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Monetate
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to support@monetate.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Monetate
|
16 |
+
* @package Monetate_Track
|
17 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Container model for blocks that should not be cached
|
23 |
+
*/
|
24 |
+
class Monetate_Track_Model_PageCache_Container extends Enterprise_PageCache_Model_Container_Advanced_Quote
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Cache tag prefix
|
28 |
+
*/
|
29 |
+
const CACHE_TAG_PREFIX = 'monetate_track_';
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Get identifier from cookies
|
33 |
+
*
|
34 |
+
* @return string
|
35 |
+
*/
|
36 |
+
protected function _getIdentifier()
|
37 |
+
{
|
38 |
+
return $this->_getCookieValue(Enterprise_PageCache_Model_Cookie::COOKIE_CART, '')
|
39 |
+
. $this->_getCookieValue(Enterprise_PageCache_Model_Cookie::COOKIE_CUSTOMER, '');
|
40 |
+
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Render block content
|
44 |
+
*
|
45 |
+
* @return string
|
46 |
+
*/
|
47 |
+
protected function _renderBlock()
|
48 |
+
{
|
49 |
+
$blockClass = $this->_placeholder->getAttribute('block');
|
50 |
+
$block = new $blockClass;
|
51 |
+
return $block->toHtml();
|
52 |
+
}
|
53 |
+
}
|
app/code/community/Monetate/Track/Model/ProductFeed.php
CHANGED
@@ -1,537 +1,537 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Monetate
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to support@monetate.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Monetate
|
16 |
-
* @package Monetate_Track
|
17 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Export products functionality
|
23 |
-
*/
|
24 |
-
class Monetate_Track_Model_ProductFeed extends Mage_Core_Model_Abstract
|
25 |
-
{
|
26 |
-
/** Feed specification version */
|
27 |
-
const PRODUCT_FEED_SPECIFICATION_VERSION = '5.0';
|
28 |
-
|
29 |
-
/** Feed export files storage directory name */
|
30 |
-
const PRODUCT_FEED_DIR = 'monetate';
|
31 |
-
|
32 |
-
/** @var array Keys are product attributes, that are placed in product data array, and XML nodes' names as values */
|
33 |
-
protected $_dataAttrs = array(
|
34 |
-
'product_id' => 'entity_id',
|
35 |
-
'product_name' => 'name',
|
36 |
-
'product_description' => 'description',
|
37 |
-
);
|
38 |
-
|
39 |
-
/** @var array Attributes to load for the product */
|
40 |
-
protected $_productAttrs = array(
|
41 |
-
'type_id', 'name', 'description', 'image', 'small_image',
|
42 |
-
'price', 'special_price', 'special_from_date', 'special_to_date'
|
43 |
-
);
|
44 |
-
|
45 |
-
/** @var array Cache of Product Type Instances */
|
46 |
-
protected $_productTypeInstances = array();
|
47 |
-
|
48 |
-
/** @var Varien_Io_File */
|
49 |
-
protected $_filesystem;
|
50 |
-
|
51 |
-
/**
|
52 |
-
* Set variables and open connection with local filesystem
|
53 |
-
*
|
54 |
-
* @see Varien_Object::_construct()
|
55 |
-
*/
|
56 |
-
protected function _construct()
|
57 |
-
{
|
58 |
-
$this->setFilename('product-feed-export-' . date('y-m-d-H-i', time()) . '.xml');
|
59 |
-
$this->setProductModel(Mage::getSingleton('catalog/product'));
|
60 |
-
$this->setXmlDir(Mage::getBaseDir('var') . DS . self::PRODUCT_FEED_DIR . DS);
|
61 |
-
$this->setExportResult(true);
|
62 |
-
$this->_openFilesystemConnection();
|
63 |
-
return parent::_construct();
|
64 |
-
}
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Export function
|
68 |
-
*
|
69 |
-
* @param bool $isLaunchedManually
|
70 |
-
* @return string|bool
|
71 |
-
*/
|
72 |
-
public function export($isLaunchedManually = false)
|
73 |
-
{
|
74 |
-
$message = 'Export process failed';
|
75 |
-
$result = false;
|
76 |
-
$exportEnabled = (bool) Mage::getStoreConfig('monetate/export/enable_cron');
|
77 |
-
if ($exportEnabled || $isLaunchedManually) {
|
78 |
-
Mage::log('Export process started', null, 'monetate.log', true);
|
79 |
-
|
80 |
-
$doc = new DOMDocument('1.0', 'UTF-8');
|
81 |
-
// Write XML header to the file
|
82 |
-
$this->_saveXmlLocally($doc, false, false);
|
83 |
-
// Write 'catalog' opening node and version node
|
84 |
-
$this->_saveXmlLocally(false, $this->_getXmlStartAsText(), false);
|
85 |
-
|
86 |
-
// Process the product collection
|
87 |
-
$products = $this->getProductModel()->getCollection()->addAttributeToSelect($this->_productAttrs, 'left');
|
88 |
-
$select = $products->getSelect();
|
89 |
-
unset($products);
|
90 |
-
Mage::getSingleton('core/resource_iterator')
|
91 |
-
->walk($select, array(array($this, 'productCallback')));
|
92 |
-
|
93 |
-
// Write 'catalog' closing node
|
94 |
-
$result = (bool) $this->_saveXmlLocally(false, $this->_getXmlEndAsText(), false);
|
95 |
-
|
96 |
-
if ($result) {
|
97 |
-
$message = 'Export process completed. Data saved in ' . $this->getFilename();
|
98 |
-
if (!$this->_uploadXml()) {
|
99 |
-
$message .= ' (File not uploaded via SFTP)';
|
100 |
-
}
|
101 |
-
}
|
102 |
-
}
|
103 |
-
Mage::log($message, null, 'monetate.log', true);
|
104 |
-
if (!$result) {
|
105 |
-
$result = $message;
|
106 |
-
}
|
107 |
-
return $result;
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Get XML document's beginning as a text
|
112 |
-
*
|
113 |
-
* @return string
|
114 |
-
*/
|
115 |
-
protected function _getXmlStartAsText()
|
116 |
-
{
|
117 |
-
return '<catalog><version>' . self::PRODUCT_FEED_SPECIFICATION_VERSION . '</version>';
|
118 |
-
}
|
119 |
-
|
120 |
-
/**
|
121 |
-
* Get XML document's end as a text
|
122 |
-
*
|
123 |
-
* @return string
|
124 |
-
*/
|
125 |
-
protected function _getXmlEndAsText()
|
126 |
-
{
|
127 |
-
return '</catalog>';
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Callback for walk() function. Run for each product.
|
132 |
-
*
|
133 |
-
* @param array $args
|
134 |
-
*/
|
135 |
-
public function productCallback($args)
|
136 |
-
{
|
137 |
-
// Init Product (without loading)
|
138 |
-
$product = $this->getProductModel()
|
139 |
-
->reset()
|
140 |
-
->setData($args['row']);
|
141 |
-
$this->setProductTypeInstance($product);
|
142 |
-
|
143 |
-
// Skip Virtual Products
|
144 |
-
if ($product->getTypeId() === 'virtual') {
|
145 |
-
return;
|
146 |
-
}
|
147 |
-
|
148 |
-
// Load Product Options
|
149 |
-
if ($product->getHasOptions()) {
|
150 |
-
foreach ($product->getProductOptionsCollection() as $option) {
|
151 |
-
$option->setProduct($product);
|
152 |
-
$product->addOption($option);
|
153 |
-
}
|
154 |
-
}
|
155 |
-
|
156 |
-
// Add Product to XML
|
157 |
-
$doc = new DOMDocument('1.0', 'UTF-8');
|
158 |
-
$this->_createProductAttrsNodes($doc, $product);
|
159 |
-
$result = (bool) $this->_saveXmlLocally($doc, false, $this->getFilename());
|
160 |
-
if (!$result) {
|
161 |
-
$this->setExportResult(false);
|
162 |
-
}
|
163 |
-
return;
|
164 |
-
}
|
165 |
-
|
166 |
-
/**
|
167 |
-
* ReDefine Product Type Instance to Product
|
168 |
-
*
|
169 |
-
* @param Mage_Catalog_Model_Product $product
|
170 |
-
*/
|
171 |
-
public function setProductTypeInstance(Mage_Catalog_Model_Product $product)
|
172 |
-
{
|
173 |
-
$type = $product->getTypeId();
|
174 |
-
if (!isset($this->_productTypeInstances[$type])) {
|
175 |
-
$this->_productTypeInstances[$type] = Mage::getSingleton('catalog/product_type')
|
176 |
-
->factory($product, true);
|
177 |
-
}
|
178 |
-
$product->setTypeInstance($this->_productTypeInstances[$type], true);
|
179 |
-
}
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Create product attributes' nodes
|
183 |
-
*
|
184 |
-
* @param DOMDocument $doc
|
185 |
-
* @param Mage_Catalog_Model_Product $product
|
186 |
-
*/
|
187 |
-
protected function _createProductAttrsNodes(DOMDocument $doc, Mage_Catalog_Model_Product $product)
|
188 |
-
{
|
189 |
-
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getId());
|
190 |
-
$productNode = $doc->createElement('product');
|
191 |
-
$doc->appendChild($productNode);
|
192 |
-
|
193 |
-
// product_id, product_name, product_description
|
194 |
-
foreach ($this->_dataAttrs as $key => $value) {
|
195 |
-
$node = $doc->createElement($key, htmlspecialchars(strip_tags($product->getData($value))));
|
196 |
-
$productNode->appendChild($node);
|
197 |
-
}
|
198 |
-
|
199 |
-
// price, alt_price
|
200 |
-
$this->_createPriceNodes($product, 'price', $doc, $productNode);
|
201 |
-
|
202 |
-
// url
|
203 |
-
$this->_createUrlNode($product, $doc, $productNode);
|
204 |
-
|
205 |
-
// product_image_url
|
206 |
-
$this->_createImageUrlNodes($product, 'product_image_url', $doc, $productNode);
|
207 |
-
|
208 |
-
// categories
|
209 |
-
$this->_createCategoriesNodes($product, $doc, $productNode);
|
210 |
-
|
211 |
-
// brand_name
|
212 |
-
$this->_createBrandNode($product, $doc, $productNode);
|
213 |
-
|
214 |
-
// endcap_image_url
|
215 |
-
$this->_createImageUrlNodes($product, 'endcap_image_url', $doc, $productNode);
|
216 |
-
|
217 |
-
// search_image_url
|
218 |
-
$this->_createImageUrlNodes($product, 'search_image_url', $doc, $productNode);
|
219 |
-
|
220 |
-
// skus
|
221 |
-
$this->_createSkuNodes($product, $doc, $productNode);
|
222 |
-
|
223 |
-
// availability
|
224 |
-
$this->_createStockNodes($stock, 'availability', 'is_in_stock', $doc, $productNode);
|
225 |
-
|
226 |
-
// ats
|
227 |
-
$this->_createStockNodes($stock, 'ats', 'min_qty', $doc, $productNode);
|
228 |
-
|
229 |
-
// allocation
|
230 |
-
$this->_createStockNodes($stock, 'allocation', 'qty', $doc, $productNode);
|
231 |
-
|
232 |
-
// variations
|
233 |
-
$this->_createVariationsNodes($product, $doc, $productNode);
|
234 |
-
|
235 |
-
// rating
|
236 |
-
$this->_createRatingNode($product, $doc, $productNode);
|
237 |
-
}
|
238 |
-
|
239 |
-
/**
|
240 |
-
* Create category nodes
|
241 |
-
*
|
242 |
-
* @param Mage_Catalog_Model_Product $product
|
243 |
-
* @param DOMDocument $doc
|
244 |
-
* @param DOMElement $productNode
|
245 |
-
*/
|
246 |
-
protected function _createCategoriesNodes(Mage_Catalog_Model_Product $product, DOMDocument $doc,
|
247 |
-
DOMElement $productNode)
|
248 |
-
{
|
249 |
-
$categoriesNode = $doc->createElement('categories');
|
250 |
-
$productNode->appendChild($categoriesNode);
|
251 |
-
$categories = $product->getCategoryCollection()->addAttributeToSelect('name');
|
252 |
-
foreach ($categories as $category) {
|
253 |
-
$categoryNode = $doc->createElement('category');
|
254 |
-
$categoriesNode->appendChild($categoryNode);
|
255 |
-
$categoryNameNode = $doc->createElement('category_name', htmlspecialchars($category->getName()));
|
256 |
-
$categoryIdNode = $doc->createElement('category_id', $category->getId());
|
257 |
-
$categoryNode->appendChild($categoryIdNode);
|
258 |
-
$categoryNode->appendChild($categoryNameNode);
|
259 |
-
}
|
260 |
-
}
|
261 |
-
|
262 |
-
/**
|
263 |
-
* Create variations nodes
|
264 |
-
*
|
265 |
-
* @param Mage_Catalog_Model_Product $product
|
266 |
-
* @param DOMDocument $doc
|
267 |
-
* @param DOMElement $productNode
|
268 |
-
*/
|
269 |
-
protected function _createVariationsNodes(Mage_Catalog_Model_Product $product, DOMDocument $doc,
|
270 |
-
DOMElement $productNode)
|
271 |
-
{
|
272 |
-
$variationsNode = $doc->createElement('variations');
|
273 |
-
$productNode->appendChild($variationsNode);
|
274 |
-
if ($product->getTypeId() === 'configurable') {
|
275 |
-
$configurableAttributes = $product->getTypeInstance(true)
|
276 |
-
->getConfigurableAttributesAsArray($product);
|
277 |
-
foreach ($configurableAttributes as $attr) {
|
278 |
-
$label = strtolower(preg_replace('|[^a-z]*|i', '', $attr['label']));
|
279 |
-
$attributeNode = $doc->createElement($label);
|
280 |
-
$variationsNode->appendChild($attributeNode);
|
281 |
-
foreach ($attr['values'] as $option) {
|
282 |
-
$label = strtolower(preg_replace('|[^a-z]*|i', '', $option['label']));
|
283 |
-
$optionNode = $doc->createElement('option', $label);
|
284 |
-
$attributeNode->appendChild($optionNode);
|
285 |
-
}
|
286 |
-
}
|
287 |
-
}
|
288 |
-
if ($product->getOptions()) {
|
289 |
-
foreach ($product->getOptions() as $option) {
|
290 |
-
$title = strtolower(preg_replace('|[^a-z]*|i', '', $option->getTitle()));
|
291 |
-
$attributeNode = $doc->createElement($title);
|
292 |
-
$variationsNode->appendChild($attributeNode);
|
293 |
-
$values = $option->getValues();
|
294 |
-
foreach ($values as $v) {
|
295 |
-
$optionNode = $doc->createElement('option', $v->getSku());
|
296 |
-
$attributeNode->appendChild($optionNode);
|
297 |
-
}
|
298 |
-
}
|
299 |
-
}
|
300 |
-
}
|
301 |
-
|
302 |
-
/**
|
303 |
-
* Create price nodes
|
304 |
-
*
|
305 |
-
* @param Mage_Catalog_Model_Product $product
|
306 |
-
* @param string $type
|
307 |
-
* @param DOMDocument $doc
|
308 |
-
* @param DOMElement $productNode
|
309 |
-
*/
|
310 |
-
protected function _createPriceNodes(Mage_Catalog_Model_Product $product, $type, DOMDocument $doc,
|
311 |
-
DOMElement $productNode)
|
312 |
-
{
|
313 |
-
list($altPrice, $price) = $this->_getProductPrice($product, $type);
|
314 |
-
$node = $doc->createElement('price', number_format($price, 2, '.', ''));
|
315 |
-
$productNode->appendChild($node);
|
316 |
-
$node = $doc->createElement('alt_price', number_format($altPrice, 2, '.', ''));
|
317 |
-
$productNode->appendChild($node);
|
318 |
-
}
|
319 |
-
|
320 |
-
/**
|
321 |
-
* Return product price
|
322 |
-
*
|
323 |
-
* @param Mage_Catalog_Model_Product $product
|
324 |
-
*
|
325 |
-
* @return array
|
326 |
-
*/
|
327 |
-
protected function _getProductPrice(Mage_Catalog_Model_Product $product)
|
328 |
-
{
|
329 |
-
if ($product->getTypeId() === 'bundle') {
|
330 |
-
$priceModel = $product->getPriceModel();
|
331 |
-
$stores = Mage::app()->getStores();
|
332 |
-
$price = 0;
|
333 |
-
foreach ($stores as $store) {
|
334 |
-
$product->setStoreId($store->getId());
|
335 |
-
if (method_exists($priceModel, 'getTotalPrices')) {
|
336 |
-
list($minimalPrice, $maximalPrice) = $priceModel->getTotalPrices($product, null, null, false);
|
337 |
-
} else {
|
338 |
-
list($minimalPrice, $maximalPrice) = $priceModel->getPricesDependingOnTax($product);
|
339 |
-
}
|
340 |
-
if ($price == 0 || $price > (float) $minimalPrice) {
|
341 |
-
$price = $minimalPrice;
|
342 |
-
}
|
343 |
-
}
|
344 |
-
return array($price, $product->getFinalPrice());
|
345 |
-
} elseif ($product->getTypeId() === 'grouped') {
|
346 |
-
$associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
|
347 |
-
$price = array();
|
348 |
-
foreach ($associatedProducts as $item) {
|
349 |
-
$price[] = $item->getFinalPrice();
|
350 |
-
}
|
351 |
-
sort($price);
|
352 |
-
return array($price[0], $product->getFinalPrice());
|
353 |
-
} elseif ($product->getTypeId() === 'giftcard' && $product->getGiftcardAmounts()) {
|
354 |
-
$prices = Mage::getBlockSingleton('enterprise_giftcard/catalog_product_view_type_giftcard')
|
355 |
-
->getAmounts($product);
|
356 |
-
if ($prices) {
|
357 |
-
return $prices[0];
|
358 |
-
}
|
359 |
-
return array(0, $product->getFinalPrice());
|
360 |
-
} else {
|
361 |
-
return array($product->getPrice(), $product->getFinalPrice());
|
362 |
-
}
|
363 |
-
}
|
364 |
-
|
365 |
-
/**
|
366 |
-
* Create ats, availability, allocation nodes
|
367 |
-
*
|
368 |
-
* @param Mage_CatalogInventory_Model_Stock_Item $stock
|
369 |
-
* @param string $nodeName
|
370 |
-
* @param string $attrName
|
371 |
-
* @param DOMDocument $doc
|
372 |
-
* @param DOMElement $productNode
|
373 |
-
*/
|
374 |
-
protected function _createStockNodes(Mage_CatalogInventory_Model_Stock_Item $stock, $nodeName, $attrName,
|
375 |
-
DOMDocument $doc, DOMElement $productNode)
|
376 |
-
{
|
377 |
-
if ($attrName == 'is_in_stock') {
|
378 |
-
$value = $stock->getData('is_in_stock') ? 'In Stock' : 'Out of Stock';
|
379 |
-
} else {
|
380 |
-
$value = (int) $stock->getData($attrName);
|
381 |
-
}
|
382 |
-
$node = $doc->createElement($nodeName, $value);
|
383 |
-
$productNode->appendChild($node);
|
384 |
-
}
|
385 |
-
|
386 |
-
/**
|
387 |
-
* Create image urls nodes
|
388 |
-
*
|
389 |
-
* @param Mage_Catalog_Model_Product $product
|
390 |
-
* @param string $type
|
391 |
-
* @param DOMDocument $doc
|
392 |
-
* @param DOMElement $productNode
|
393 |
-
*/
|
394 |
-
protected function _createImageUrlNodes(Mage_Catalog_Model_Product $product, $type, DOMDocument $doc,
|
395 |
-
DOMElement $productNode)
|
396 |
-
{
|
397 |
-
$url = '';
|
398 |
-
try {
|
399 |
-
if ($type == 'endcap_image_url') {
|
400 |
-
$url = Mage::getDesign()
|
401 |
-
->getSkinUrl('images/catalog/product/placeholder/small_image.jpg', array('_area' => 'frontend'));
|
402 |
-
} elseif ($type == 'product_image_url' && $product->getData('image')
|
403 |
-
&& $product->getData('image') != 'no_selection') {
|
404 |
-
$url = Mage::helper('catalog/image')->init($product, 'image');
|
405 |
-
} elseif ($type == 'search_image_url' && $product->getData('small_image')
|
406 |
-
&& $product->getData('small_image') != 'no_selection') {
|
407 |
-
$url = Mage::helper('catalog/image')->init($product, 'small_image');
|
408 |
-
}
|
409 |
-
$url = str_replace(Mage::getStoreConfig('web/unsecure/base_url'), Mage::getStoreConfig('web/secure/base_url'), $url);
|
410 |
-
$imageUrlNode = $doc->createElement($type, $url);
|
411 |
-
$productNode->appendChild($imageUrlNode);
|
412 |
-
} catch (Exception $e) {
|
413 |
-
Mage::log($e->getMessage(), null, 'monetate.log', true);
|
414 |
-
}
|
415 |
-
}
|
416 |
-
|
417 |
-
/**
|
418 |
-
* Create product url node
|
419 |
-
*
|
420 |
-
* @param Mage_Catalog_Model_Product $product
|
421 |
-
* @param DOMDocument $doc
|
422 |
-
* @param DOMElement $productNode
|
423 |
-
*/
|
424 |
-
protected function _createUrlNode(Mage_Catalog_Model_Product $product, DOMDocument $doc, DOMElement $productNode)
|
425 |
-
{
|
426 |
-
$url = $product->getProductUrl();
|
427 |
-
$urlNode = $doc->createElement('url', $url);
|
428 |
-
$productNode->appendChild($urlNode);
|
429 |
-
}
|
430 |
-
|
431 |
-
/**
|
432 |
-
* Create rating node
|
433 |
-
*
|
434 |
-
* @param Mage_Catalog_Model_Product $product
|
435 |
-
* @param DOMDocument $doc
|
436 |
-
* @param DOMElement $productNode
|
437 |
-
*/
|
438 |
-
protected function _createRatingNode(Mage_Catalog_Model_Product $product, DOMDocument $doc, DOMElement $productNode)
|
439 |
-
{
|
440 |
-
$summaryData = Mage::getModel('review/review_summary')->load($product->getId());
|
441 |
-
$ratingNode = $doc->createElement('rating', (int) $summaryData->getRatingSummary());
|
442 |
-
$productNode->appendChild($ratingNode);
|
443 |
-
}
|
444 |
-
|
445 |
-
/**
|
446 |
-
* Create skus nodes
|
447 |
-
*
|
448 |
-
* @param Mage_Catalog_Model_Product $product
|
449 |
-
* @param DOMDocument $doc
|
450 |
-
* @param DOMElement $productNode
|
451 |
-
*/
|
452 |
-
protected function _createSkuNodes(Mage_Catalog_Model_Product $product, DOMDocument $doc, DOMElement $productNode)
|
453 |
-
{
|
454 |
-
$skusNode = $doc->createElement('skus');
|
455 |
-
$skuNode = $doc->createElement('sku', $product->getSku());
|
456 |
-
$skusNode->appendChild($skuNode);
|
457 |
-
$productNode->appendChild($skusNode);
|
458 |
-
}
|
459 |
-
|
460 |
-
/**
|
461 |
-
* Create brand node
|
462 |
-
*
|
463 |
-
* @param Mage_Catalog_Model_Product $product
|
464 |
-
* @param DOMDocument $doc
|
465 |
-
* @param DOMElement $productNode
|
466 |
-
*/
|
467 |
-
protected function _createBrandNode(Mage_Catalog_Model_Product $product, DOMDocument $doc, DOMElement $productNode)
|
468 |
-
{
|
469 |
-
$brandNode = $doc->createElement('brand_name', htmlspecialchars($product->getAttributeText('manufacturer')));
|
470 |
-
$productNode->appendChild($brandNode);
|
471 |
-
}
|
472 |
-
|
473 |
-
/**
|
474 |
-
* Saves document on server
|
475 |
-
*
|
476 |
-
* @param DOMDocument|false $doc
|
477 |
-
* @param string|false $content
|
478 |
-
* @param bool $excludeHeader
|
479 |
-
*
|
480 |
-
* @return bool|string
|
481 |
-
*/
|
482 |
-
protected function _saveXmlLocally($doc, $content, $excludeHeader = true)
|
483 |
-
{
|
484 |
-
$result = false;
|
485 |
-
$this->_filesystem->checkAndCreateFolder($this->getXmlDir());
|
486 |
-
if ($excludeHeader && !$content) {
|
487 |
-
$content = $doc->saveXml($doc->documentElement);
|
488 |
-
} elseif (!$content) {
|
489 |
-
$content = $doc->saveXml();
|
490 |
-
}
|
491 |
-
if ($content) {
|
492 |
-
$result = @file_put_contents($this->getXmlDir() . $this->getFilename(), $content, FILE_APPEND);
|
493 |
-
}
|
494 |
-
return $result;
|
495 |
-
}
|
496 |
-
|
497 |
-
/**
|
498 |
-
* Upload document to Monetate server via SFTP
|
499 |
-
*
|
500 |
-
* @return string|bool
|
501 |
-
*/
|
502 |
-
protected function _uploadXml()
|
503 |
-
{
|
504 |
-
// Close connection with local filesystem
|
505 |
-
$this->_filesystem->cd(getcwd());
|
506 |
-
|
507 |
-
$accessData = array(
|
508 |
-
'host' => Mage::getStoreConfig('monetate/export/monetate_sftp_host'),
|
509 |
-
'username' => Mage::getStoreConfig('monetate/export/sftp_user'),
|
510 |
-
'password' => Mage::getStoreConfig('monetate/export/sftp_password'),
|
511 |
-
'port' => Mage::getStoreConfig('monetate/export/monetate_sftp_port'),
|
512 |
-
'timeout' => Mage::getStoreConfig('monetate/export/monetate_sftp_timeout'),
|
513 |
-
);
|
514 |
-
if (empty($accessData['host']) || empty($accessData['username']) || empty($accessData['password'])) {
|
515 |
-
return false;
|
516 |
-
}
|
517 |
-
include('phpseclib/Net/SFTP.php');
|
518 |
-
$netSftpConnection = new Net_SFTP($accessData['host'], $accessData['port'], $accessData['timeout']);
|
519 |
-
if (!$netSftpConnection->login($accessData['username'], $accessData['password'])) {
|
520 |
-
Mage::log('Login on SFTP server failed', null, 'monetate.log', true);
|
521 |
-
} else if ($netSftpConnection->put('/upload/' . $this->getFilename(), $this->getXmlDir() . $this->getFilename(),
|
522 |
-
NET_SFTP_LOCAL_FILE)) {
|
523 |
-
return $this->getXmlDir() . $this->getFilename();
|
524 |
-
}
|
525 |
-
return false;
|
526 |
-
}
|
527 |
-
|
528 |
-
/**
|
529 |
-
* Open connection with local filesystem
|
530 |
-
*/
|
531 |
-
protected function _openFilesystemConnection()
|
532 |
-
{
|
533 |
-
$this->_filesystem = new Varien_Io_File;
|
534 |
-
$this->_filesystem->open();
|
535 |
-
$this->_filesystem->cd($this->_filesystem->pwd());
|
536 |
-
}
|
537 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Monetate
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to support@monetate.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Monetate
|
16 |
+
* @package Monetate_Track
|
17 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Export products functionality
|
23 |
+
*/
|
24 |
+
class Monetate_Track_Model_ProductFeed extends Mage_Core_Model_Abstract
|
25 |
+
{
|
26 |
+
/** Feed specification version */
|
27 |
+
const PRODUCT_FEED_SPECIFICATION_VERSION = '5.0';
|
28 |
+
|
29 |
+
/** Feed export files storage directory name */
|
30 |
+
const PRODUCT_FEED_DIR = 'monetate';
|
31 |
+
|
32 |
+
/** @var array Keys are product attributes, that are placed in product data array, and XML nodes' names as values */
|
33 |
+
protected $_dataAttrs = array(
|
34 |
+
'product_id' => 'entity_id',
|
35 |
+
'product_name' => 'name',
|
36 |
+
'product_description' => 'description',
|
37 |
+
);
|
38 |
+
|
39 |
+
/** @var array Attributes to load for the product */
|
40 |
+
protected $_productAttrs = array(
|
41 |
+
'type_id', 'name', 'description', 'image', 'small_image',
|
42 |
+
'price', 'special_price', 'special_from_date', 'special_to_date'
|
43 |
+
);
|
44 |
+
|
45 |
+
/** @var array Cache of Product Type Instances */
|
46 |
+
protected $_productTypeInstances = array();
|
47 |
+
|
48 |
+
/** @var Varien_Io_File */
|
49 |
+
protected $_filesystem;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Set variables and open connection with local filesystem
|
53 |
+
*
|
54 |
+
* @see Varien_Object::_construct()
|
55 |
+
*/
|
56 |
+
protected function _construct()
|
57 |
+
{
|
58 |
+
$this->setFilename('product-feed-export-' . date('y-m-d-H-i', time()) . '.xml');
|
59 |
+
$this->setProductModel(Mage::getSingleton('catalog/product'));
|
60 |
+
$this->setXmlDir(Mage::getBaseDir('var') . DS . self::PRODUCT_FEED_DIR . DS);
|
61 |
+
$this->setExportResult(true);
|
62 |
+
$this->_openFilesystemConnection();
|
63 |
+
return parent::_construct();
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Export function
|
68 |
+
*
|
69 |
+
* @param bool $isLaunchedManually
|
70 |
+
* @return string|bool
|
71 |
+
*/
|
72 |
+
public function export($isLaunchedManually = false)
|
73 |
+
{
|
74 |
+
$message = 'Export process failed';
|
75 |
+
$result = false;
|
76 |
+
$exportEnabled = (bool) Mage::getStoreConfig('monetate/export/enable_cron');
|
77 |
+
if ($exportEnabled || $isLaunchedManually) {
|
78 |
+
Mage::log('Export process started', null, 'monetate.log', true);
|
79 |
+
|
80 |
+
$doc = new DOMDocument('1.0', 'UTF-8');
|
81 |
+
// Write XML header to the file
|
82 |
+
$this->_saveXmlLocally($doc, false, false);
|
83 |
+
// Write 'catalog' opening node and version node
|
84 |
+
$this->_saveXmlLocally(false, $this->_getXmlStartAsText(), false);
|
85 |
+
|
86 |
+
// Process the product collection
|
87 |
+
$products = $this->getProductModel()->getCollection()->addAttributeToSelect($this->_productAttrs, 'left');
|
88 |
+
$select = $products->getSelect();
|
89 |
+
unset($products);
|
90 |
+
Mage::getSingleton('core/resource_iterator')
|
91 |
+
->walk($select, array(array($this, 'productCallback')));
|
92 |
+
|
93 |
+
// Write 'catalog' closing node
|
94 |
+
$result = (bool) $this->_saveXmlLocally(false, $this->_getXmlEndAsText(), false);
|
95 |
+
|
96 |
+
if ($result) {
|
97 |
+
$message = 'Export process completed. Data saved in ' . $this->getFilename();
|
98 |
+
if (!$this->_uploadXml()) {
|
99 |
+
$message .= ' (File not uploaded via SFTP)';
|
100 |
+
}
|
101 |
+
}
|
102 |
+
}
|
103 |
+
Mage::log($message, null, 'monetate.log', true);
|
104 |
+
if (!$result) {
|
105 |
+
$result = $message;
|
106 |
+
}
|
107 |
+
return $result;
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Get XML document's beginning as a text
|
112 |
+
*
|
113 |
+
* @return string
|
114 |
+
*/
|
115 |
+
protected function _getXmlStartAsText()
|
116 |
+
{
|
117 |
+
return '<catalog><version>' . self::PRODUCT_FEED_SPECIFICATION_VERSION . '</version>';
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* Get XML document's end as a text
|
122 |
+
*
|
123 |
+
* @return string
|
124 |
+
*/
|
125 |
+
protected function _getXmlEndAsText()
|
126 |
+
{
|
127 |
+
return '</catalog>';
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Callback for walk() function. Run for each product.
|
132 |
+
*
|
133 |
+
* @param array $args
|
134 |
+
*/
|
135 |
+
public function productCallback($args)
|
136 |
+
{
|
137 |
+
// Init Product (without loading)
|
138 |
+
$product = $this->getProductModel()
|
139 |
+
->reset()
|
140 |
+
->setData($args['row']);
|
141 |
+
$this->setProductTypeInstance($product);
|
142 |
+
|
143 |
+
// Skip Virtual Products
|
144 |
+
if ($product->getTypeId() === 'virtual') {
|
145 |
+
return;
|
146 |
+
}
|
147 |
+
|
148 |
+
// Load Product Options
|
149 |
+
if ($product->getHasOptions()) {
|
150 |
+
foreach ($product->getProductOptionsCollection() as $option) {
|
151 |
+
$option->setProduct($product);
|
152 |
+
$product->addOption($option);
|
153 |
+
}
|
154 |
+
}
|
155 |
+
|
156 |
+
// Add Product to XML
|
157 |
+
$doc = new DOMDocument('1.0', 'UTF-8');
|
158 |
+
$this->_createProductAttrsNodes($doc, $product);
|
159 |
+
$result = (bool) $this->_saveXmlLocally($doc, false, $this->getFilename());
|
160 |
+
if (!$result) {
|
161 |
+
$this->setExportResult(false);
|
162 |
+
}
|
163 |
+
return;
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* ReDefine Product Type Instance to Product
|
168 |
+
*
|
169 |
+
* @param Mage_Catalog_Model_Product $product
|
170 |
+
*/
|
171 |
+
public function setProductTypeInstance(Mage_Catalog_Model_Product $product)
|
172 |
+
{
|
173 |
+
$type = $product->getTypeId();
|
174 |
+
if (!isset($this->_productTypeInstances[$type])) {
|
175 |
+
$this->_productTypeInstances[$type] = Mage::getSingleton('catalog/product_type')
|
176 |
+
->factory($product, true);
|
177 |
+
}
|
178 |
+
$product->setTypeInstance($this->_productTypeInstances[$type], true);
|
179 |
+
}
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Create product attributes' nodes
|
183 |
+
*
|
184 |
+
* @param DOMDocument $doc
|
185 |
+
* @param Mage_Catalog_Model_Product $product
|
186 |
+
*/
|
187 |
+
protected function _createProductAttrsNodes(DOMDocument $doc, Mage_Catalog_Model_Product $product)
|
188 |
+
{
|
189 |
+
$stock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($product->getId());
|
190 |
+
$productNode = $doc->createElement('product');
|
191 |
+
$doc->appendChild($productNode);
|
192 |
+
|
193 |
+
// product_id, product_name, product_description
|
194 |
+
foreach ($this->_dataAttrs as $key => $value) {
|
195 |
+
$node = $doc->createElement($key, htmlspecialchars(strip_tags($product->getData($value))));
|
196 |
+
$productNode->appendChild($node);
|
197 |
+
}
|
198 |
+
|
199 |
+
// price, alt_price
|
200 |
+
$this->_createPriceNodes($product, 'price', $doc, $productNode);
|
201 |
+
|
202 |
+
// url
|
203 |
+
$this->_createUrlNode($product, $doc, $productNode);
|
204 |
+
|
205 |
+
// product_image_url
|
206 |
+
$this->_createImageUrlNodes($product, 'product_image_url', $doc, $productNode);
|
207 |
+
|
208 |
+
// categories
|
209 |
+
$this->_createCategoriesNodes($product, $doc, $productNode);
|
210 |
+
|
211 |
+
// brand_name
|
212 |
+
$this->_createBrandNode($product, $doc, $productNode);
|
213 |
+
|
214 |
+
// endcap_image_url
|
215 |
+
$this->_createImageUrlNodes($product, 'endcap_image_url', $doc, $productNode);
|
216 |
+
|
217 |
+
// search_image_url
|
218 |
+
$this->_createImageUrlNodes($product, 'search_image_url', $doc, $productNode);
|
219 |
+
|
220 |
+
// skus
|
221 |
+
$this->_createSkuNodes($product, $doc, $productNode);
|
222 |
+
|
223 |
+
// availability
|
224 |
+
$this->_createStockNodes($stock, 'availability', 'is_in_stock', $doc, $productNode);
|
225 |
+
|
226 |
+
// ats
|
227 |
+
$this->_createStockNodes($stock, 'ats', 'min_qty', $doc, $productNode);
|
228 |
+
|
229 |
+
// allocation
|
230 |
+
$this->_createStockNodes($stock, 'allocation', 'qty', $doc, $productNode);
|
231 |
+
|
232 |
+
// variations
|
233 |
+
$this->_createVariationsNodes($product, $doc, $productNode);
|
234 |
+
|
235 |
+
// rating
|
236 |
+
$this->_createRatingNode($product, $doc, $productNode);
|
237 |
+
}
|
238 |
+
|
239 |
+
/**
|
240 |
+
* Create category nodes
|
241 |
+
*
|
242 |
+
* @param Mage_Catalog_Model_Product $product
|
243 |
+
* @param DOMDocument $doc
|
244 |
+
* @param DOMElement $productNode
|
245 |
+
*/
|
246 |
+
protected function _createCategoriesNodes(Mage_Catalog_Model_Product $product, DOMDocument $doc,
|
247 |
+
DOMElement $productNode)
|
248 |
+
{
|
249 |
+
$categoriesNode = $doc->createElement('categories');
|
250 |
+
$productNode->appendChild($categoriesNode);
|
251 |
+
$categories = $product->getCategoryCollection()->addAttributeToSelect('name');
|
252 |
+
foreach ($categories as $category) {
|
253 |
+
$categoryNode = $doc->createElement('category');
|
254 |
+
$categoriesNode->appendChild($categoryNode);
|
255 |
+
$categoryNameNode = $doc->createElement('category_name', htmlspecialchars($category->getName()));
|
256 |
+
$categoryIdNode = $doc->createElement('category_id', $category->getId());
|
257 |
+
$categoryNode->appendChild($categoryIdNode);
|
258 |
+
$categoryNode->appendChild($categoryNameNode);
|
259 |
+
}
|
260 |
+
}
|
261 |
+
|
262 |
+
/**
|
263 |
+
* Create variations nodes
|
264 |
+
*
|
265 |
+
* @param Mage_Catalog_Model_Product $product
|
266 |
+
* @param DOMDocument $doc
|
267 |
+
* @param DOMElement $productNode
|
268 |
+
*/
|
269 |
+
protected function _createVariationsNodes(Mage_Catalog_Model_Product $product, DOMDocument $doc,
|
270 |
+
DOMElement $productNode)
|
271 |
+
{
|
272 |
+
$variationsNode = $doc->createElement('variations');
|
273 |
+
$productNode->appendChild($variationsNode);
|
274 |
+
if ($product->getTypeId() === 'configurable') {
|
275 |
+
$configurableAttributes = $product->getTypeInstance(true)
|
276 |
+
->getConfigurableAttributesAsArray($product);
|
277 |
+
foreach ($configurableAttributes as $attr) {
|
278 |
+
$label = strtolower(preg_replace('|[^a-z]*|i', '', $attr['label']));
|
279 |
+
$attributeNode = $doc->createElement($label);
|
280 |
+
$variationsNode->appendChild($attributeNode);
|
281 |
+
foreach ($attr['values'] as $option) {
|
282 |
+
$label = strtolower(preg_replace('|[^a-z]*|i', '', $option['label']));
|
283 |
+
$optionNode = $doc->createElement('option', $label);
|
284 |
+
$attributeNode->appendChild($optionNode);
|
285 |
+
}
|
286 |
+
}
|
287 |
+
}
|
288 |
+
if ($product->getOptions()) {
|
289 |
+
foreach ($product->getOptions() as $option) {
|
290 |
+
$title = strtolower(preg_replace('|[^a-z]*|i', '', $option->getTitle()));
|
291 |
+
$attributeNode = $doc->createElement($title);
|
292 |
+
$variationsNode->appendChild($attributeNode);
|
293 |
+
$values = $option->getValues();
|
294 |
+
foreach ($values as $v) {
|
295 |
+
$optionNode = $doc->createElement('option', $v->getSku());
|
296 |
+
$attributeNode->appendChild($optionNode);
|
297 |
+
}
|
298 |
+
}
|
299 |
+
}
|
300 |
+
}
|
301 |
+
|
302 |
+
/**
|
303 |
+
* Create price nodes
|
304 |
+
*
|
305 |
+
* @param Mage_Catalog_Model_Product $product
|
306 |
+
* @param string $type
|
307 |
+
* @param DOMDocument $doc
|
308 |
+
* @param DOMElement $productNode
|
309 |
+
*/
|
310 |
+
protected function _createPriceNodes(Mage_Catalog_Model_Product $product, $type, DOMDocument $doc,
|
311 |
+
DOMElement $productNode)
|
312 |
+
{
|
313 |
+
list($altPrice, $price) = $this->_getProductPrice($product, $type);
|
314 |
+
$node = $doc->createElement('price', number_format($price, 2, '.', ''));
|
315 |
+
$productNode->appendChild($node);
|
316 |
+
$node = $doc->createElement('alt_price', number_format($altPrice, 2, '.', ''));
|
317 |
+
$productNode->appendChild($node);
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Return product price
|
322 |
+
*
|
323 |
+
* @param Mage_Catalog_Model_Product $product
|
324 |
+
*
|
325 |
+
* @return array
|
326 |
+
*/
|
327 |
+
protected function _getProductPrice(Mage_Catalog_Model_Product $product)
|
328 |
+
{
|
329 |
+
if ($product->getTypeId() === 'bundle') {
|
330 |
+
$priceModel = $product->getPriceModel();
|
331 |
+
$stores = Mage::app()->getStores();
|
332 |
+
$price = 0;
|
333 |
+
foreach ($stores as $store) {
|
334 |
+
$product->setStoreId($store->getId());
|
335 |
+
if (method_exists($priceModel, 'getTotalPrices')) {
|
336 |
+
list($minimalPrice, $maximalPrice) = $priceModel->getTotalPrices($product, null, null, false);
|
337 |
+
} else {
|
338 |
+
list($minimalPrice, $maximalPrice) = $priceModel->getPricesDependingOnTax($product);
|
339 |
+
}
|
340 |
+
if ($price == 0 || $price > (float) $minimalPrice) {
|
341 |
+
$price = $minimalPrice;
|
342 |
+
}
|
343 |
+
}
|
344 |
+
return array($price, $product->getFinalPrice());
|
345 |
+
} elseif ($product->getTypeId() === 'grouped') {
|
346 |
+
$associatedProducts = $product->getTypeInstance(true)->getAssociatedProducts($product);
|
347 |
+
$price = array();
|
348 |
+
foreach ($associatedProducts as $item) {
|
349 |
+
$price[] = $item->getFinalPrice();
|
350 |
+
}
|
351 |
+
sort($price);
|
352 |
+
return array($price[0], $product->getFinalPrice());
|
353 |
+
} elseif ($product->getTypeId() === 'giftcard' && $product->getGiftcardAmounts()) {
|
354 |
+
$prices = Mage::getBlockSingleton('enterprise_giftcard/catalog_product_view_type_giftcard')
|
355 |
+
->getAmounts($product);
|
356 |
+
if ($prices) {
|
357 |
+
return $prices[0];
|
358 |
+
}
|
359 |
+
return array(0, $product->getFinalPrice());
|
360 |
+
} else {
|
361 |
+
return array($product->getPrice(), $product->getFinalPrice());
|
362 |
+
}
|
363 |
+
}
|
364 |
+
|
365 |
+
/**
|
366 |
+
* Create ats, availability, allocation nodes
|
367 |
+
*
|
368 |
+
* @param Mage_CatalogInventory_Model_Stock_Item $stock
|
369 |
+
* @param string $nodeName
|
370 |
+
* @param string $attrName
|
371 |
+
* @param DOMDocument $doc
|
372 |
+
* @param DOMElement $productNode
|
373 |
+
*/
|
374 |
+
protected function _createStockNodes(Mage_CatalogInventory_Model_Stock_Item $stock, $nodeName, $attrName,
|
375 |
+
DOMDocument $doc, DOMElement $productNode)
|
376 |
+
{
|
377 |
+
if ($attrName == 'is_in_stock') {
|
378 |
+
$value = $stock->getData('is_in_stock') ? 'In Stock' : 'Out of Stock';
|
379 |
+
} else {
|
380 |
+
$value = (int) $stock->getData($attrName);
|
381 |
+
}
|
382 |
+
$node = $doc->createElement($nodeName, $value);
|
383 |
+
$productNode->appendChild($node);
|
384 |
+
}
|
385 |
+
|
386 |
+
/**
|
387 |
+
* Create image urls nodes
|
388 |
+
*
|
389 |
+
* @param Mage_Catalog_Model_Product $product
|
390 |
+
* @param string $type
|
391 |
+
* @param DOMDocument $doc
|
392 |
+
* @param DOMElement $productNode
|
393 |
+
*/
|
394 |
+
protected function _createImageUrlNodes(Mage_Catalog_Model_Product $product, $type, DOMDocument $doc,
|
395 |
+
DOMElement $productNode)
|
396 |
+
{
|
397 |
+
$url = '';
|
398 |
+
try {
|
399 |
+
if ($type == 'endcap_image_url') {
|
400 |
+
$url = Mage::getDesign()
|
401 |
+
->getSkinUrl('images/catalog/product/placeholder/small_image.jpg', array('_area' => 'frontend'));
|
402 |
+
} elseif ($type == 'product_image_url' && $product->getData('image')
|
403 |
+
&& $product->getData('image') != 'no_selection') {
|
404 |
+
$url = Mage::helper('catalog/image')->init($product, 'image');
|
405 |
+
} elseif ($type == 'search_image_url' && $product->getData('small_image')
|
406 |
+
&& $product->getData('small_image') != 'no_selection') {
|
407 |
+
$url = Mage::helper('catalog/image')->init($product, 'small_image');
|
408 |
+
}
|
409 |
+
$url = str_replace(Mage::getStoreConfig('web/unsecure/base_url'), Mage::getStoreConfig('web/secure/base_url'), $url);
|
410 |
+
$imageUrlNode = $doc->createElement($type, $url);
|
411 |
+
$productNode->appendChild($imageUrlNode);
|
412 |
+
} catch (Exception $e) {
|
413 |
+
Mage::log($e->getMessage(), null, 'monetate.log', true);
|
414 |
+
}
|
415 |
+
}
|
416 |
+
|
417 |
+
/**
|
418 |
+
* Create product url node
|
419 |
+
*
|
420 |
+
* @param Mage_Catalog_Model_Product $product
|
421 |
+
* @param DOMDocument $doc
|
422 |
+
* @param DOMElement $productNode
|
423 |
+
*/
|
424 |
+
protected function _createUrlNode(Mage_Catalog_Model_Product $product, DOMDocument $doc, DOMElement $productNode)
|
425 |
+
{
|
426 |
+
$url = $product->getProductUrl();
|
427 |
+
$urlNode = $doc->createElement('url', $url);
|
428 |
+
$productNode->appendChild($urlNode);
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Create rating node
|
433 |
+
*
|
434 |
+
* @param Mage_Catalog_Model_Product $product
|
435 |
+
* @param DOMDocument $doc
|
436 |
+
* @param DOMElement $productNode
|
437 |
+
*/
|
438 |
+
protected function _createRatingNode(Mage_Catalog_Model_Product $product, DOMDocument $doc, DOMElement $productNode)
|
439 |
+
{
|
440 |
+
$summaryData = Mage::getModel('review/review_summary')->load($product->getId());
|
441 |
+
$ratingNode = $doc->createElement('rating', (int) $summaryData->getRatingSummary());
|
442 |
+
$productNode->appendChild($ratingNode);
|
443 |
+
}
|
444 |
+
|
445 |
+
/**
|
446 |
+
* Create skus nodes
|
447 |
+
*
|
448 |
+
* @param Mage_Catalog_Model_Product $product
|
449 |
+
* @param DOMDocument $doc
|
450 |
+
* @param DOMElement $productNode
|
451 |
+
*/
|
452 |
+
protected function _createSkuNodes(Mage_Catalog_Model_Product $product, DOMDocument $doc, DOMElement $productNode)
|
453 |
+
{
|
454 |
+
$skusNode = $doc->createElement('skus');
|
455 |
+
$skuNode = $doc->createElement('sku', $product->getSku());
|
456 |
+
$skusNode->appendChild($skuNode);
|
457 |
+
$productNode->appendChild($skusNode);
|
458 |
+
}
|
459 |
+
|
460 |
+
/**
|
461 |
+
* Create brand node
|
462 |
+
*
|
463 |
+
* @param Mage_Catalog_Model_Product $product
|
464 |
+
* @param DOMDocument $doc
|
465 |
+
* @param DOMElement $productNode
|
466 |
+
*/
|
467 |
+
protected function _createBrandNode(Mage_Catalog_Model_Product $product, DOMDocument $doc, DOMElement $productNode)
|
468 |
+
{
|
469 |
+
$brandNode = $doc->createElement('brand_name', htmlspecialchars($product->getAttributeText('manufacturer')));
|
470 |
+
$productNode->appendChild($brandNode);
|
471 |
+
}
|
472 |
+
|
473 |
+
/**
|
474 |
+
* Saves document on server
|
475 |
+
*
|
476 |
+
* @param DOMDocument|false $doc
|
477 |
+
* @param string|false $content
|
478 |
+
* @param bool $excludeHeader
|
479 |
+
*
|
480 |
+
* @return bool|string
|
481 |
+
*/
|
482 |
+
protected function _saveXmlLocally($doc, $content, $excludeHeader = true)
|
483 |
+
{
|
484 |
+
$result = false;
|
485 |
+
$this->_filesystem->checkAndCreateFolder($this->getXmlDir());
|
486 |
+
if ($excludeHeader && !$content) {
|
487 |
+
$content = $doc->saveXml($doc->documentElement);
|
488 |
+
} elseif (!$content) {
|
489 |
+
$content = $doc->saveXml();
|
490 |
+
}
|
491 |
+
if ($content) {
|
492 |
+
$result = @file_put_contents($this->getXmlDir() . $this->getFilename(), $content, FILE_APPEND);
|
493 |
+
}
|
494 |
+
return $result;
|
495 |
+
}
|
496 |
+
|
497 |
+
/**
|
498 |
+
* Upload document to Monetate server via SFTP
|
499 |
+
*
|
500 |
+
* @return string|bool
|
501 |
+
*/
|
502 |
+
protected function _uploadXml()
|
503 |
+
{
|
504 |
+
// Close connection with local filesystem
|
505 |
+
$this->_filesystem->cd(getcwd());
|
506 |
+
|
507 |
+
$accessData = array(
|
508 |
+
'host' => Mage::getStoreConfig('monetate/export/monetate_sftp_host'),
|
509 |
+
'username' => Mage::getStoreConfig('monetate/export/sftp_user'),
|
510 |
+
'password' => Mage::getStoreConfig('monetate/export/sftp_password'),
|
511 |
+
'port' => Mage::getStoreConfig('monetate/export/monetate_sftp_port'),
|
512 |
+
'timeout' => Mage::getStoreConfig('monetate/export/monetate_sftp_timeout'),
|
513 |
+
);
|
514 |
+
if (empty($accessData['host']) || empty($accessData['username']) || empty($accessData['password'])) {
|
515 |
+
return false;
|
516 |
+
}
|
517 |
+
include('phpseclib/Net/SFTP.php');
|
518 |
+
$netSftpConnection = new Net_SFTP($accessData['host'], $accessData['port'], $accessData['timeout']);
|
519 |
+
if (!$netSftpConnection->login($accessData['username'], $accessData['password'])) {
|
520 |
+
Mage::log('Login on SFTP server failed', null, 'monetate.log', true);
|
521 |
+
} else if ($netSftpConnection->put('/upload/' . $this->getFilename(), $this->getXmlDir() . $this->getFilename(),
|
522 |
+
NET_SFTP_LOCAL_FILE)) {
|
523 |
+
return $this->getXmlDir() . $this->getFilename();
|
524 |
+
}
|
525 |
+
return false;
|
526 |
+
}
|
527 |
+
|
528 |
+
/**
|
529 |
+
* Open connection with local filesystem
|
530 |
+
*/
|
531 |
+
protected function _openFilesystemConnection()
|
532 |
+
{
|
533 |
+
$this->_filesystem = new Varien_Io_File;
|
534 |
+
$this->_filesystem->open();
|
535 |
+
$this->_filesystem->cd($this->_filesystem->pwd());
|
536 |
+
}
|
537 |
+
}
|
app/code/community/Monetate/Track/controllers/Adminhtml/ProductfeedController.php
CHANGED
@@ -1,47 +1,47 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Monetate
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to support@monetate.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Monetate
|
16 |
-
* @package Monetate_Track
|
17 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Product feed data econtroller
|
23 |
-
*/
|
24 |
-
class Monetate_Track_Adminhtml_ProductfeedController extends Mage_Adminhtml_Controller_Action
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Export action
|
28 |
-
*/
|
29 |
-
public function exportAction()
|
30 |
-
{
|
31 |
-
if ($this->getRequest()->isAjax()) {
|
32 |
-
try {
|
33 |
-
$result = Mage::getSingleton('monetate_track/productFeed')->export(true);
|
34 |
-
if ($result === true) {
|
35 |
-
echo 'Success';
|
36 |
-
} else {
|
37 |
-
echo $result;
|
38 |
-
}
|
39 |
-
} catch (Exception $e) {
|
40 |
-
Mage::log($e->getMessage(), null, 'monetate.log', true);
|
41 |
-
echo $this->__($e->getMessage());
|
42 |
-
}
|
43 |
-
} else {
|
44 |
-
return $this->_redirect('*/*');
|
45 |
-
}
|
46 |
-
}
|
47 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Monetate
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to support@monetate.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Monetate
|
16 |
+
* @package Monetate_Track
|
17 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Product feed data econtroller
|
23 |
+
*/
|
24 |
+
class Monetate_Track_Adminhtml_ProductfeedController extends Mage_Adminhtml_Controller_Action
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Export action
|
28 |
+
*/
|
29 |
+
public function exportAction()
|
30 |
+
{
|
31 |
+
if ($this->getRequest()->isAjax()) {
|
32 |
+
try {
|
33 |
+
$result = Mage::getSingleton('monetate_track/productFeed')->export(true);
|
34 |
+
if ($result === true) {
|
35 |
+
echo 'Success';
|
36 |
+
} else {
|
37 |
+
echo $result;
|
38 |
+
}
|
39 |
+
} catch (Exception $e) {
|
40 |
+
Mage::log($e->getMessage(), null, 'monetate.log', true);
|
41 |
+
echo $this->__($e->getMessage());
|
42 |
+
}
|
43 |
+
} else {
|
44 |
+
return $this->_redirect('*/*');
|
45 |
+
}
|
46 |
+
}
|
47 |
+
}
|
app/code/community/Monetate/Track/controllers/Adminhtml/Sftp/ConnectionController.php
CHANGED
@@ -1,41 +1,41 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Monetate
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to support@monetate.com so we can send you a copy immediately.
|
14 |
-
*
|
15 |
-
* @category Monetate
|
16 |
-
* @package Monetate_Track
|
17 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
-
*/
|
20 |
-
|
21 |
-
/**
|
22 |
-
* SFTP connection controller
|
23 |
-
*/
|
24 |
-
class Monetate_Track_Adminhtml_Sftp_ConnectionController extends Mage_Adminhtml_Controller_Action
|
25 |
-
{
|
26 |
-
/**
|
27 |
-
* Test SFTP connection
|
28 |
-
*
|
29 |
-
* @return string
|
30 |
-
*/
|
31 |
-
public function testAction()
|
32 |
-
{
|
33 |
-
$connection = new Varien_Io_Sftp();
|
34 |
-
try {
|
35 |
-
$connection->open($this->getRequest()->getPost());
|
36 |
-
echo $this->__('Success');
|
37 |
-
} catch (Exception $e) {
|
38 |
-
echo $this->__('Fail');
|
39 |
-
}
|
40 |
-
}
|
41 |
-
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Monetate
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
+
* that is bundled with this package in the file LICENSE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://opensource.org/licenses/osl-3.0.php
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to support@monetate.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* @category Monetate
|
16 |
+
* @package Monetate_Track
|
17 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
18 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
19 |
+
*/
|
20 |
+
|
21 |
+
/**
|
22 |
+
* SFTP connection controller
|
23 |
+
*/
|
24 |
+
class Monetate_Track_Adminhtml_Sftp_ConnectionController extends Mage_Adminhtml_Controller_Action
|
25 |
+
{
|
26 |
+
/**
|
27 |
+
* Test SFTP connection
|
28 |
+
*
|
29 |
+
* @return string
|
30 |
+
*/
|
31 |
+
public function testAction()
|
32 |
+
{
|
33 |
+
$connection = new Varien_Io_Sftp();
|
34 |
+
try {
|
35 |
+
$connection->open($this->getRequest()->getPost());
|
36 |
+
echo $this->__('Success');
|
37 |
+
} catch (Exception $e) {
|
38 |
+
echo $this->__('Fail');
|
39 |
+
}
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Monetate/Track/etc/adminhtml.xml
CHANGED
@@ -1,42 +1,42 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* Monetate
|
5 |
-
*
|
6 |
-
* NOTICE OF LICENSE
|
7 |
-
*
|
8 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
-
* that is bundled with this package in the file LICENSE.txt.
|
10 |
-
* It is also available through the world-wide-web at this URL:
|
11 |
-
* http://opensource.org/licenses/osl-3.0.php
|
12 |
-
* If you did not receive a copy of the license and are unable to
|
13 |
-
* obtain it through the world-wide-web, please send an email
|
14 |
-
* to support@monetate.com so we can send you a copy immediately.
|
15 |
-
*
|
16 |
-
* @category Monetate
|
17 |
-
* @package Monetate_Track
|
18 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
19 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
-
*/
|
21 |
-
-->
|
22 |
-
<config>
|
23 |
-
<acl>
|
24 |
-
<resources>
|
25 |
-
<admin>
|
26 |
-
<children>
|
27 |
-
<system>
|
28 |
-
<children>
|
29 |
-
<config>
|
30 |
-
<children>
|
31 |
-
<monetate>
|
32 |
-
<title>Monetate Configuration</title>
|
33 |
-
</monetate>
|
34 |
-
</children>
|
35 |
-
</config>
|
36 |
-
</children>
|
37 |
-
</system>
|
38 |
-
</children>
|
39 |
-
</admin>
|
40 |
-
</resources>
|
41 |
-
</acl>
|
42 |
-
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Monetate
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to support@monetate.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category Monetate
|
17 |
+
* @package Monetate_Track
|
18 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
-->
|
22 |
+
<config>
|
23 |
+
<acl>
|
24 |
+
<resources>
|
25 |
+
<admin>
|
26 |
+
<children>
|
27 |
+
<system>
|
28 |
+
<children>
|
29 |
+
<config>
|
30 |
+
<children>
|
31 |
+
<monetate>
|
32 |
+
<title>Monetate Configuration</title>
|
33 |
+
</monetate>
|
34 |
+
</children>
|
35 |
+
</config>
|
36 |
+
</children>
|
37 |
+
</system>
|
38 |
+
</children>
|
39 |
+
</admin>
|
40 |
+
</resources>
|
41 |
+
</acl>
|
42 |
+
</config>
|
app/code/community/Monetate/Track/etc/cache.xml
CHANGED
@@ -1,32 +1,32 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* Monetate
|
5 |
-
*
|
6 |
-
* NOTICE OF LICENSE
|
7 |
-
*
|
8 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
-
* that is bundled with this package in the file LICENSE.txt.
|
10 |
-
* It is also available through the world-wide-web at this URL:
|
11 |
-
* http://opensource.org/licenses/osl-3.0.php
|
12 |
-
* If you did not receive a copy of the license and are unable to
|
13 |
-
* obtain it through the world-wide-web, please send an email
|
14 |
-
* to support@monetate.com so we can send you a copy immediately.
|
15 |
-
*
|
16 |
-
* @category Monetate
|
17 |
-
* @package Monetate_Track
|
18 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
19 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
-
*/
|
21 |
-
-->
|
22 |
-
<config>
|
23 |
-
<placeholders>
|
24 |
-
<monetate_track_add_cart_rows>
|
25 |
-
<block>monetate_track/addCartRows</block>
|
26 |
-
<name>monetate.track.add.cart.rows</name>
|
27 |
-
<placeholder>MONETATE_TRACK_PLACEHOLDER</placeholder>
|
28 |
-
<container>Monetate_Track_Model_PageCache_Container</container>
|
29 |
-
<cache_lifetime>86400</cache_lifetime>
|
30 |
-
</monetate_track_add_cart_rows>
|
31 |
-
</placeholders>
|
32 |
-
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Monetate
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to support@monetate.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category Monetate
|
17 |
+
* @package Monetate_Track
|
18 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
-->
|
22 |
+
<config>
|
23 |
+
<placeholders>
|
24 |
+
<monetate_track_add_cart_rows>
|
25 |
+
<block>monetate_track/addCartRows</block>
|
26 |
+
<name>monetate.track.add.cart.rows</name>
|
27 |
+
<placeholder>MONETATE_TRACK_PLACEHOLDER</placeholder>
|
28 |
+
<container>Monetate_Track_Model_PageCache_Container</container>
|
29 |
+
<cache_lifetime>86400</cache_lifetime>
|
30 |
+
</monetate_track_add_cart_rows>
|
31 |
+
</placeholders>
|
32 |
+
</config>
|
app/code/community/Monetate/Track/etc/config.xml
CHANGED
@@ -1,117 +1,126 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* Monetate
|
5 |
-
*
|
6 |
-
* NOTICE OF LICENSE
|
7 |
-
*
|
8 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
-
* that is bundled with this package in the file LICENSE.txt.
|
10 |
-
* It is also available through the world-wide-web at this URL:
|
11 |
-
* http://opensource.org/licenses/osl-3.0.php
|
12 |
-
* If you did not receive a copy of the license and are unable to
|
13 |
-
* obtain it through the world-wide-web, please send an email
|
14 |
-
* to support@monetate.com so we can send you a copy immediately.
|
15 |
-
*
|
16 |
-
* @category Monetate
|
17 |
-
* @package Monetate_Track
|
18 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
19 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
-
*/
|
21 |
-
-->
|
22 |
-
<config>
|
23 |
-
<modules>
|
24 |
-
<Monetate_Track>
|
25 |
-
<version>1.0.
|
26 |
-
</Monetate_Track>
|
27 |
-
</modules>
|
28 |
-
<global>
|
29 |
-
<blocks>
|
30 |
-
<monetate_track>
|
31 |
-
<class>Monetate_Track_Block</class>
|
32 |
-
</monetate_track>
|
33 |
-
</blocks>
|
34 |
-
<helpers>
|
35 |
-
<monetate_track>
|
36 |
-
<class>Monetate_Track_Helper</class>
|
37 |
-
</monetate_track>
|
38 |
-
</helpers>
|
39 |
-
<models>
|
40 |
-
<monetate_track>
|
41 |
-
<class>Monetate_Track_Model</class>
|
42 |
-
</monetate_track>
|
43 |
-
</models>
|
44 |
-
</global>
|
45 |
-
<admin>
|
46 |
-
<routers>
|
47 |
-
<monetate_track>
|
48 |
-
<use>admin</use>
|
49 |
-
<args>
|
50 |
-
<frontName>monetate_track</frontName>
|
51 |
-
<module>Monetate_Track</module>
|
52 |
-
</args>
|
53 |
-
</monetate_track>
|
54 |
-
</routers>
|
55 |
-
</admin>
|
56 |
-
<frontend>
|
57 |
-
<events>
|
58 |
-
|
59 |
-
<observers>
|
60 |
-
<
|
61 |
-
<type>singleton</type>
|
62 |
-
<class>monetate_track/observer</class>
|
63 |
-
<method>
|
64 |
-
</
|
65 |
-
</observers>
|
66 |
-
</
|
67 |
-
<
|
68 |
-
<observers>
|
69 |
-
<
|
70 |
-
<
|
71 |
-
<
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
<
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
<
|
94 |
-
<
|
95 |
-
<
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
<
|
109 |
-
|
110 |
-
</
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Monetate
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to support@monetate.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category Monetate
|
17 |
+
* @package Monetate_Track
|
18 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
-->
|
22 |
+
<config>
|
23 |
+
<modules>
|
24 |
+
<Monetate_Track>
|
25 |
+
<version>1.0.1</version>
|
26 |
+
</Monetate_Track>
|
27 |
+
</modules>
|
28 |
+
<global>
|
29 |
+
<blocks>
|
30 |
+
<monetate_track>
|
31 |
+
<class>Monetate_Track_Block</class>
|
32 |
+
</monetate_track>
|
33 |
+
</blocks>
|
34 |
+
<helpers>
|
35 |
+
<monetate_track>
|
36 |
+
<class>Monetate_Track_Helper</class>
|
37 |
+
</monetate_track>
|
38 |
+
</helpers>
|
39 |
+
<models>
|
40 |
+
<monetate_track>
|
41 |
+
<class>Monetate_Track_Model</class>
|
42 |
+
</monetate_track>
|
43 |
+
</models>
|
44 |
+
</global>
|
45 |
+
<admin>
|
46 |
+
<routers>
|
47 |
+
<monetate_track>
|
48 |
+
<use>admin</use>
|
49 |
+
<args>
|
50 |
+
<frontName>monetate_track</frontName>
|
51 |
+
<module>Monetate_Track</module>
|
52 |
+
</args>
|
53 |
+
</monetate_track>
|
54 |
+
</routers>
|
55 |
+
</admin>
|
56 |
+
<frontend>
|
57 |
+
<events>
|
58 |
+
<core_block_abstract_to_html_after>
|
59 |
+
<observers>
|
60 |
+
<monetate_track_observer>
|
61 |
+
<type>singleton</type>
|
62 |
+
<class>monetate_track/observer</class>
|
63 |
+
<method>observeBlockShowing</method>
|
64 |
+
</monetate_track_observer>
|
65 |
+
</observers>
|
66 |
+
</core_block_abstract_to_html_after>
|
67 |
+
<catalog_block_product_list_collection>
|
68 |
+
<observers>
|
69 |
+
<monetate_track_product_list>
|
70 |
+
<type>singleton</type>
|
71 |
+
<class>monetate_track/observer</class>
|
72 |
+
<method>observeProductListCollection</method>
|
73 |
+
</monetate_track_product_list>
|
74 |
+
</observers>
|
75 |
+
</catalog_block_product_list_collection>
|
76 |
+
<checkout_onepage_controller_success_action>
|
77 |
+
<observers>
|
78 |
+
<monetate_track_order_success>
|
79 |
+
<class>monetate_track/observer</class>
|
80 |
+
<method>observeOrderSuccess</method>
|
81 |
+
</monetate_track_order_success>
|
82 |
+
</observers>
|
83 |
+
</checkout_onepage_controller_success_action>
|
84 |
+
<checkout_multishipping_controller_success_action>
|
85 |
+
<observers>
|
86 |
+
<monetate_track_order_success>
|
87 |
+
<class>monetate_track/observer</class>
|
88 |
+
<method>observeOrderSuccess</method>
|
89 |
+
</monetate_track_order_success>
|
90 |
+
</observers>
|
91 |
+
</checkout_multishipping_controller_success_action>
|
92 |
+
</events>
|
93 |
+
<layout>
|
94 |
+
<updates>
|
95 |
+
<monetate_track>
|
96 |
+
<file>monetate/track.xml</file>
|
97 |
+
</monetate_track>
|
98 |
+
</updates>
|
99 |
+
</layout>
|
100 |
+
</frontend>
|
101 |
+
<default>
|
102 |
+
<monetate>
|
103 |
+
<configuration>
|
104 |
+
<monetate_enable_tracking>0</monetate_enable_tracking>
|
105 |
+
</configuration>
|
106 |
+
<export>
|
107 |
+
<monetate_product_feed_enable_cron>0</monetate_product_feed_enable_cron>
|
108 |
+
<monetate_sftp_host>sftp.monetate.net</monetate_sftp_host>
|
109 |
+
<monetate_sftp_port>22</monetate_sftp_port>
|
110 |
+
<monetate_sftp_timeout>10</monetate_sftp_timeout>
|
111 |
+
</export>
|
112 |
+
</monetate>
|
113 |
+
</default>
|
114 |
+
<crontab>
|
115 |
+
<jobs>
|
116 |
+
<monetate_product_feed_export>
|
117 |
+
<schedule>
|
118 |
+
<cron_expr>0 1 * * *</cron_expr>
|
119 |
+
</schedule>
|
120 |
+
<run>
|
121 |
+
<model>monetate_track/productFeed::export</model>
|
122 |
+
</run>
|
123 |
+
</monetate_product_feed_export>
|
124 |
+
</jobs>
|
125 |
+
</crontab>
|
126 |
+
</config>
|
app/code/community/Monetate/Track/etc/system.xml
CHANGED
@@ -1,103 +1,103 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* Monetate
|
5 |
-
*
|
6 |
-
* NOTICE OF LICENSE
|
7 |
-
*
|
8 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
-
* that is bundled with this package in the file LICENSE.txt.
|
10 |
-
* It is also available through the world-wide-web at this URL:
|
11 |
-
* http://opensource.org/licenses/osl-3.0.php
|
12 |
-
* If you did not receive a copy of the license and are unable to
|
13 |
-
* obtain it through the world-wide-web, please send an email
|
14 |
-
* to support@monetate.com so we can send you a copy immediately.
|
15 |
-
*
|
16 |
-
* @category Monetate
|
17 |
-
* @package Monetate_Track
|
18 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
19 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
-
*/
|
21 |
-
-->
|
22 |
-
<config>
|
23 |
-
<sections>
|
24 |
-
<monetate translate="label" module="monetate_track">
|
25 |
-
<label>Monetate</label>
|
26 |
-
<tab>general</tab>
|
27 |
-
<sort_order>1002</sort_order>
|
28 |
-
<show_in_default>1</show_in_default>
|
29 |
-
<show_in_website>1</show_in_website>
|
30 |
-
<show_in_store>1</show_in_store>
|
31 |
-
<groups>
|
32 |
-
<configuration translate="label">
|
33 |
-
<label>Configuration</label>
|
34 |
-
<frontend_type>text</frontend_type>
|
35 |
-
<sort_order>1</sort_order>
|
36 |
-
<show_in_default>1</show_in_default>
|
37 |
-
<show_in_website>1</show_in_website>
|
38 |
-
<show_in_store>1</show_in_store>
|
39 |
-
<fields>
|
40 |
-
<tag translate="label">
|
41 |
-
<label>Monetate Tag</label>
|
42 |
-
<frontend_type>textarea</frontend_type>
|
43 |
-
<depends><enable_tracking>1</enable_tracking></depends>
|
44 |
-
<sort_order>2</sort_order>
|
45 |
-
<show_in_default>1</show_in_default>
|
46 |
-
<show_in_website>1</show_in_website>
|
47 |
-
<show_in_store>1</show_in_store>
|
48 |
-
</tag>
|
49 |
-
<enable_tracking translate="label">
|
50 |
-
<label>Tracking Enabled</label>
|
51 |
-
<frontend_type>select</frontend_type>
|
52 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
53 |
-
<sort_order>1</sort_order>
|
54 |
-
<show_in_default>1</show_in_default>
|
55 |
-
<show_in_website>1</show_in_website>
|
56 |
-
<show_in_store>1</show_in_store>
|
57 |
-
</enable_tracking>
|
58 |
-
</fields>
|
59 |
-
</configuration>
|
60 |
-
<export translate="label">
|
61 |
-
<label>Export Product Feed</label>
|
62 |
-
<frontend_type>text</frontend_type>
|
63 |
-
<sort_order>2</sort_order>
|
64 |
-
<show_in_default>1</show_in_default>
|
65 |
-
<show_in_website>1</show_in_website>
|
66 |
-
<show_in_store>1</show_in_store>
|
67 |
-
<fields>
|
68 |
-
<sftp_user translate="label">
|
69 |
-
<label>Monetate SFTP Username</label>
|
70 |
-
<frontend_type>text</frontend_type>
|
71 |
-
<sort_order>1</sort_order>
|
72 |
-
<show_in_default>1</show_in_default>
|
73 |
-
<show_in_website>1</show_in_website>
|
74 |
-
<show_in_store>1</show_in_store>
|
75 |
-
</sftp_user>
|
76 |
-
<sftp_password translate="label">
|
77 |
-
<label>Monetate SFTP Password</label>
|
78 |
-
<frontend_type>password</frontend_type>
|
79 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
80 |
-
<validate>validate-password</validate>
|
81 |
-
<sort_order>2</sort_order>
|
82 |
-
<show_in_default>1</show_in_default>
|
83 |
-
<show_in_website>1</show_in_website>
|
84 |
-
<show_in_store>1</show_in_store>
|
85 |
-
</sftp_password>
|
86 |
-
<enable_cron translate="label">
|
87 |
-
<label>Product Feed Export On Schedule Enable</label>
|
88 |
-
<frontend_type>select</frontend_type>
|
89 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
90 |
-
<comment>
|
91 |
-
<model>monetate_track/adminhtml_exportProductFeed</model>
|
92 |
-
</comment>
|
93 |
-
<sort_order>3</sort_order>
|
94 |
-
<show_in_default>1</show_in_default>
|
95 |
-
<show_in_website>1</show_in_website>
|
96 |
-
<show_in_store>1</show_in_store>
|
97 |
-
</enable_cron>
|
98 |
-
</fields>
|
99 |
-
</export>
|
100 |
-
</groups>
|
101 |
-
</monetate>
|
102 |
-
</sections>
|
103 |
-
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Monetate
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to support@monetate.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category Monetate
|
17 |
+
* @package Monetate_Track
|
18 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
-->
|
22 |
+
<config>
|
23 |
+
<sections>
|
24 |
+
<monetate translate="label" module="monetate_track">
|
25 |
+
<label>Monetate</label>
|
26 |
+
<tab>general</tab>
|
27 |
+
<sort_order>1002</sort_order>
|
28 |
+
<show_in_default>1</show_in_default>
|
29 |
+
<show_in_website>1</show_in_website>
|
30 |
+
<show_in_store>1</show_in_store>
|
31 |
+
<groups>
|
32 |
+
<configuration translate="label">
|
33 |
+
<label>Configuration</label>
|
34 |
+
<frontend_type>text</frontend_type>
|
35 |
+
<sort_order>1</sort_order>
|
36 |
+
<show_in_default>1</show_in_default>
|
37 |
+
<show_in_website>1</show_in_website>
|
38 |
+
<show_in_store>1</show_in_store>
|
39 |
+
<fields>
|
40 |
+
<tag translate="label">
|
41 |
+
<label>Monetate Tag</label>
|
42 |
+
<frontend_type>textarea</frontend_type>
|
43 |
+
<depends><enable_tracking>1</enable_tracking></depends>
|
44 |
+
<sort_order>2</sort_order>
|
45 |
+
<show_in_default>1</show_in_default>
|
46 |
+
<show_in_website>1</show_in_website>
|
47 |
+
<show_in_store>1</show_in_store>
|
48 |
+
</tag>
|
49 |
+
<enable_tracking translate="label">
|
50 |
+
<label>Tracking Enabled</label>
|
51 |
+
<frontend_type>select</frontend_type>
|
52 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
53 |
+
<sort_order>1</sort_order>
|
54 |
+
<show_in_default>1</show_in_default>
|
55 |
+
<show_in_website>1</show_in_website>
|
56 |
+
<show_in_store>1</show_in_store>
|
57 |
+
</enable_tracking>
|
58 |
+
</fields>
|
59 |
+
</configuration>
|
60 |
+
<export translate="label">
|
61 |
+
<label>Export Product Feed</label>
|
62 |
+
<frontend_type>text</frontend_type>
|
63 |
+
<sort_order>2</sort_order>
|
64 |
+
<show_in_default>1</show_in_default>
|
65 |
+
<show_in_website>1</show_in_website>
|
66 |
+
<show_in_store>1</show_in_store>
|
67 |
+
<fields>
|
68 |
+
<sftp_user translate="label">
|
69 |
+
<label>Monetate SFTP Username</label>
|
70 |
+
<frontend_type>text</frontend_type>
|
71 |
+
<sort_order>1</sort_order>
|
72 |
+
<show_in_default>1</show_in_default>
|
73 |
+
<show_in_website>1</show_in_website>
|
74 |
+
<show_in_store>1</show_in_store>
|
75 |
+
</sftp_user>
|
76 |
+
<sftp_password translate="label">
|
77 |
+
<label>Monetate SFTP Password</label>
|
78 |
+
<frontend_type>password</frontend_type>
|
79 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
80 |
+
<validate>validate-password</validate>
|
81 |
+
<sort_order>2</sort_order>
|
82 |
+
<show_in_default>1</show_in_default>
|
83 |
+
<show_in_website>1</show_in_website>
|
84 |
+
<show_in_store>1</show_in_store>
|
85 |
+
</sftp_password>
|
86 |
+
<enable_cron translate="label">
|
87 |
+
<label>Product Feed Export On Schedule Enable</label>
|
88 |
+
<frontend_type>select</frontend_type>
|
89 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
90 |
+
<comment>
|
91 |
+
<model>monetate_track/adminhtml_exportProductFeed</model>
|
92 |
+
</comment>
|
93 |
+
<sort_order>3</sort_order>
|
94 |
+
<show_in_default>1</show_in_default>
|
95 |
+
<show_in_website>1</show_in_website>
|
96 |
+
<show_in_store>1</show_in_store>
|
97 |
+
</enable_cron>
|
98 |
+
</fields>
|
99 |
+
</export>
|
100 |
+
</groups>
|
101 |
+
</monetate>
|
102 |
+
</sections>
|
103 |
+
</config>
|
app/design/frontend/base/default/layout/monetate/track.xml
CHANGED
@@ -1,58 +1,58 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* Monetate
|
5 |
-
*
|
6 |
-
* NOTICE OF LICENSE
|
7 |
-
*
|
8 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
-
* that is bundled with this package in the file LICENSE.txt.
|
10 |
-
* It is also available through the world-wide-web at this URL:
|
11 |
-
* http://opensource.org/licenses/osl-3.0.php
|
12 |
-
* If you did not receive a copy of the license and are unable to
|
13 |
-
* obtain it through the world-wide-web, please send an email
|
14 |
-
* to support@monetate.com so we can send you a copy immediately.
|
15 |
-
*
|
16 |
-
* @category Monetate
|
17 |
-
* @package Monetate_Track
|
18 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
19 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
-
*/
|
21 |
-
-->
|
22 |
-
|
23 |
-
<!--
|
24 |
-
/**
|
25 |
-
* @category design
|
26 |
-
* @package base_default
|
27 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
28 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
29 |
-
*/
|
30 |
-
-->
|
31 |
-
<layout version="0.1.0">
|
32 |
-
<default>
|
33 |
-
<reference name="head">
|
34 |
-
<block type="monetate_track/init" name="monetate.track.init" before="-" />
|
35 |
-
</reference>
|
36 |
-
<reference name="before_body_end">
|
37 |
-
<block type="monetate_track/trackData" name="monetate.track.track.data" after="-" />
|
38 |
-
<block type="monetate_track/addCartRows" name="monetate.track.add.cart.rows"
|
39 |
-
before="monetate.track.track.data">
|
40 |
-
</block>
|
41 |
-
</reference>
|
42 |
-
</default>
|
43 |
-
<catalog_category_view>
|
44 |
-
<reference name="monetate.track.track.data">
|
45 |
-
<action method="addCategories" />
|
46 |
-
</reference>
|
47 |
-
</catalog_category_view>
|
48 |
-
<catalog_product_view>
|
49 |
-
<reference name="monetate.track.track.data">
|
50 |
-
<action method="addProductDetails" />
|
51 |
-
</reference>
|
52 |
-
</catalog_product_view>
|
53 |
-
<checkout_onepage_index>
|
54 |
-
<reference name="monetate.track.track.data">
|
55 |
-
<action method="setOnepageEnabled"><value>1</value></action>
|
56 |
-
</reference>
|
57 |
-
</checkout_onepage_index>
|
58 |
-
</layout>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Monetate
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to support@monetate.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category Monetate
|
17 |
+
* @package Monetate_Track
|
18 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
-->
|
22 |
+
|
23 |
+
<!--
|
24 |
+
/**
|
25 |
+
* @category design
|
26 |
+
* @package base_default
|
27 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
28 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
29 |
+
*/
|
30 |
+
-->
|
31 |
+
<layout version="0.1.0">
|
32 |
+
<default>
|
33 |
+
<reference name="head">
|
34 |
+
<block type="monetate_track/init" name="monetate.track.init" before="-" />
|
35 |
+
</reference>
|
36 |
+
<reference name="before_body_end">
|
37 |
+
<block type="monetate_track/trackData" name="monetate.track.track.data" after="-" />
|
38 |
+
<block type="monetate_track/addCartRows" name="monetate.track.add.cart.rows"
|
39 |
+
before="monetate.track.track.data">
|
40 |
+
</block>
|
41 |
+
</reference>
|
42 |
+
</default>
|
43 |
+
<catalog_category_view>
|
44 |
+
<reference name="monetate.track.track.data">
|
45 |
+
<action method="addCategories" />
|
46 |
+
</reference>
|
47 |
+
</catalog_category_view>
|
48 |
+
<catalog_product_view>
|
49 |
+
<reference name="monetate.track.track.data">
|
50 |
+
<action method="addProductDetails" />
|
51 |
+
</reference>
|
52 |
+
</catalog_product_view>
|
53 |
+
<checkout_onepage_index>
|
54 |
+
<reference name="monetate.track.track.data">
|
55 |
+
<action method="setOnepageEnabled"><value>1</value></action>
|
56 |
+
</reference>
|
57 |
+
</checkout_onepage_index>
|
58 |
+
</layout>
|
app/etc/modules/Monetate_Track.xml
CHANGED
@@ -1,29 +1,29 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* Monetate
|
5 |
-
*
|
6 |
-
* NOTICE OF LICENSE
|
7 |
-
*
|
8 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
-
* that is bundled with this package in the file LICENSE.txt.
|
10 |
-
* It is also available through the world-wide-web at this URL:
|
11 |
-
* http://opensource.org/licenses/osl-3.0.php
|
12 |
-
* If you did not receive a copy of the license and are unable to
|
13 |
-
* obtain it through the world-wide-web, please send an email
|
14 |
-
* to support@monetate.com so we can send you a copy immediately.
|
15 |
-
*
|
16 |
-
* @category Monetate
|
17 |
-
* @package Monetate_Track
|
18 |
-
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
19 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
-
*/
|
21 |
-
-->
|
22 |
-
<config>
|
23 |
-
<modules>
|
24 |
-
<Monetate_Track>
|
25 |
-
<active>true</active>
|
26 |
-
<codePool>community</codePool>
|
27 |
-
</Monetate_Track>
|
28 |
-
</modules>
|
29 |
-
</config>
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Monetate
|
5 |
+
*
|
6 |
+
* NOTICE OF LICENSE
|
7 |
+
*
|
8 |
+
* This source file is subject to the Open Software License (OSL 3.0)
|
9 |
+
* that is bundled with this package in the file LICENSE.txt.
|
10 |
+
* It is also available through the world-wide-web at this URL:
|
11 |
+
* http://opensource.org/licenses/osl-3.0.php
|
12 |
+
* If you did not receive a copy of the license and are unable to
|
13 |
+
* obtain it through the world-wide-web, please send an email
|
14 |
+
* to support@monetate.com so we can send you a copy immediately.
|
15 |
+
*
|
16 |
+
* @category Monetate
|
17 |
+
* @package Monetate_Track
|
18 |
+
* @copyright Copyright (c) 2014 Monetate, Inc. All rights reserved. (http://www.monetate.com)
|
19 |
+
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
20 |
+
*/
|
21 |
+
-->
|
22 |
+
<config>
|
23 |
+
<modules>
|
24 |
+
<Monetate_Track>
|
25 |
+
<active>true</active>
|
26 |
+
<codePool>community</codePool>
|
27 |
+
</Monetate_Track>
|
28 |
+
</modules>
|
29 |
+
</config>
|
package.xml
CHANGED
@@ -1,21 +1,18 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Monetate_Track</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description>
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
<
|
15 |
-
<
|
16 |
-
<date>2014-10-01</date>
|
17 |
-
<time>17:53:41</time>
|
18 |
-
<contents><target name="mageetc"><dir name="modules"><file name="Monetate_Track.xml" hash="6c81ac4e5e790df6a85c37a58032613d"/></dir></target><target name="magecommunity"><dir name="Monetate"><dir name="Track"><dir name="Block"><file name="Abstract.php" hash="87cfeb808d16ad10c598b8a80f7d026f"/><file name="AddCartRows.php" hash="768e20eb43a96c99228c256a1f43b8b1"/><file name="Init.php" hash="35b04cc2cf215409c5349f9a6e93da5d"/><file name="TrackData.php" hash="c6c71c7a286bfd87806c09130a8324c5"/></dir><dir name="Helper"><file name="Data.php" hash="6ef4229ef8a8ed453b073bb549ed74bf"/></dir><dir name="Model"><dir name="Adminhtml"><file name="ExportProductFeed.php" hash="b8e0a7bcec8b21a84657381147569b34"/></dir><file name="Observer.php" hash="4efbc69c863079d4503cd6adbd03db7e"/><dir name="PageCache"><file name="Container.php" hash="02022ffe338d675824edf699dd438380"/></dir><file name="ProductFeed.php" hash="54a32d71facd0f9d5e5dd3348c692787"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ProductfeedController.php" hash="0b91362fe5c4b545250906e79330a513"/><dir name="Sftp"><file name="ConnectionController.php" hash="f27ae84b166bebb453e7db46edffa649"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="bd7ab1fd0e73fb67e3d6db1a76c184af"/><file name="cache.xml" hash="4379b3e3846540c9fcbd561f05bd25fd"/><file name="config.xml" hash="8147f0fed3122783808ae605e37a0570"/><file name="system.xml" hash="86765ce44cd1624ca0d93f9e3f665d9a"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="monetate"><file name="track.xml" hash="b8344dfbdf718e4aa6ce0cd29508b7bd"/></dir></dir></dir></dir></dir></target></contents>
|
19 |
<compatible/>
|
20 |
-
<dependencies><required><php><min>5.
|
21 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Monetate_Track</name>
|
4 |
+
<version>1.0.1</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Track data and export product feed to Monetate.</summary>
|
10 |
+
<description>Module for Monetate allows to use an event handler which adds a tracking script for each page. This handler will add methods with parameters, based on current location, actions, to a global object. An XML data feed will be created to send product data to Monetate.</description>
|
11 |
+
<notes>Changed functionality to move Monetate Tag script before other scripts</notes>
|
12 |
+
<authors><author><name>One Pica Inc</name><user>onepica</user><email>hello@onepica.com</email></author></authors>
|
13 |
+
<date>2015-03-23</date>
|
14 |
+
<time>13:06:46</time>
|
15 |
+
<contents><target name="mageetc"><dir name="modules"><file name="Monetate_Track.xml" hash="77fdaa45fa4dffc3a647e5c6333f7928"/></dir></target><target name="magecommunity"><dir name="Monetate"><dir name="Track"><dir name="Block"><file name="Abstract.php" hash="911a0fa14cb1e1f3a6fdc56c0c5c9c06"/><file name="AddCartRows.php" hash="6a08041e8bebca833700933edd2bde2e"/><file name="Init.php" hash="4c8472c095122d5d81ae525512d9f626"/><file name="TrackData.php" hash="ce3daf34f9bb7f6cffd91302bbc6bfbf"/></dir><dir name="Helper"><file name="Data.php" hash="4334045b99767810e06f15a9340dc6e3"/></dir><dir name="Model"><dir name="Adminhtml"><file name="ExportProductFeed.php" hash="14499d5b5fe519964ddd0ee089749b8c"/></dir><file name="Observer.php" hash="73bc971260e79c27bcaa95587c7dab66"/><dir name="PageCache"><file name="Container.php" hash="5a3d9eb378ee32e330fd27a04eeda6cd"/></dir><file name="ProductFeed.php" hash="e4c5d809995610aaf0671d7714b5bdb1"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="ProductfeedController.php" hash="90c6260b6876642bdd3751b29135877d"/><dir name="Sftp"><file name="ConnectionController.php" hash="ff832620ecb82e5ae521330db13e99c5"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="1cfb36d0e5926bea3142b6dde6d17548"/><file name="cache.xml" hash="cfb5e864f98d8a3df24c650b2c954ae0"/><file name="config.xml" hash="6140d986d19e523c907a35f29bb7bde7"/><file name="system.xml" hash="9a664d77bc9026d4bae8b167bcfe24e9"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="monetate"><file name="track.xml" hash="b64f6ef6ce1ddd9b1ada86292ebbfd0a"/></dir></dir></dir></dir></dir></target></contents>
|
|
|
|
|
|
|
16 |
<compatible/>
|
17 |
+
<dependencies><required><php><min>5.3.0</min><max>5.5.6</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.5</min><max>1.8</max></package><package><name>Mage_Core_Modules</name><channel>enterprise</channel><min>1.12</min><max>1.14</max></package></required></dependencies>
|
18 |
</package>
|