Me_Gravity - Version 1.0.0.0

Version Notes

Version number: 1.0.0.0
Stability: Stable
Compatibility: CE 1.6.x, 1.7.x, 1.8.x, 1.9.x

Download this release

Release Info

Developer Gravity Recommendations
Extension Me_Gravity
Version 1.0.0.0
Comparing to
See all releases


Version 1.0.0.0

Files changed (77) hide show
  1. app/code/community/Me/Gravity/Block/Abstract.php +37 -0
  2. app/code/community/Me/Gravity/Block/Adminhtml/System/Config/Form/Catalog.php +103 -0
  3. app/code/community/Me/Gravity/Block/Adminhtml/System/Config/Form/Customer.php +71 -0
  4. app/code/community/Me/Gravity/Block/Adminhtml/System/Config/Form/Test.php +93 -0
  5. app/code/community/Me/Gravity/Block/Catalog/Category/Boxes/Category.php +141 -0
  6. app/code/community/Me/Gravity/Block/Catalog/Category/Boxes/Personal.php +51 -0
  7. app/code/community/Me/Gravity/Block/Catalog/Category/Boxes/Top.php +51 -0
  8. app/code/community/Me/Gravity/Block/Catalog/Product/View/Boxes/Accessories.php +49 -0
  9. app/code/community/Me/Gravity/Block/Catalog/Product/View/Boxes/Personal.php +49 -0
  10. app/code/community/Me/Gravity/Block/Catalog/Product/View/Boxes/Product.php +56 -0
  11. app/code/community/Me/Gravity/Block/Catalog/Product/View/Boxes/Similar.php +49 -0
  12. app/code/community/Me/Gravity/Block/Catalog/Product/View/Js/Gravity.php +63 -0
  13. app/code/community/Me/Gravity/Block/Catalogsearch/Advanced/Js/Gravity.php +57 -0
  14. app/code/community/Me/Gravity/Block/Catalogsearch/Boxes/Result.php +181 -0
  15. app/code/community/Me/Gravity/Block/Catalogsearch/Js/Gravity.php +57 -0
  16. app/code/community/Me/Gravity/Block/Checkout/Cart/Boxes/Cart.php +105 -0
  17. app/code/community/Me/Gravity/Block/General/Boxes/Best.php +49 -0
  18. app/code/community/Me/Gravity/Block/General/Boxes/History.php +49 -0
  19. app/code/community/Me/Gravity/Block/General/Boxes/Others.php +49 -0
  20. app/code/community/Me/Gravity/Block/General/Boxes/Popular.php +49 -0
  21. app/code/community/Me/Gravity/Block/Page/Js/Gravity.php +37 -0
  22. app/code/community/Me/Gravity/Block/Recommendation.php +260 -0
  23. app/code/community/Me/Gravity/Block/Widget/Boxes/Widget.php +106 -0
  24. app/code/community/Me/Gravity/Helper/Boxes.php +103 -0
  25. app/code/community/Me/Gravity/Helper/Data.php +398 -0
  26. app/code/community/Me/Gravity/Model/Client/GravityClient.php +951 -0
  27. app/code/community/Me/Gravity/Model/Customers.php +124 -0
  28. app/code/community/Me/Gravity/Model/Export/Abstract.php +148 -0
  29. app/code/community/Me/Gravity/Model/Export/Catalog/Product.php +231 -0
  30. app/code/community/Me/Gravity/Model/Export/Customer/Customer.php +152 -0
  31. app/code/community/Me/Gravity/Model/Method/Abstract.php +77 -0
  32. app/code/community/Me/Gravity/Model/Method/Request.php +553 -0
  33. app/code/community/Me/Gravity/Model/Observer.php +660 -0
  34. app/code/community/Me/Gravity/Model/Products.php +289 -0
  35. app/code/community/Me/Gravity/Model/System/Config/Backend/Catalog/Cron.php +73 -0
  36. app/code/community/Me/Gravity/Model/System/Config/Source/Catalog/Attributes.php +45 -0
  37. app/code/community/Me/Gravity/Model/System/Config/Source/Customer/Attributes.php +44 -0
  38. app/code/community/Me/Gravity/Model/System/Config/Source/Layout/Layout.php +59 -0
  39. app/code/community/Me/Gravity/Model/System/Config/Source/Layout/Pages.php +48 -0
  40. app/code/community/Me/Gravity/controllers/Adminhtml/GravityController.php +163 -0
  41. app/code/community/Me/Gravity/etc/adminhtml.xml +32 -0
  42. app/code/community/Me/Gravity/etc/config.xml +245 -0
  43. app/code/community/Me/Gravity/etc/system.xml +1076 -0
  44. app/code/community/Me/Gravity/etc/widget.xml +85 -0
  45. app/design/adminhtml/default/default/template/me/gravity/system/config/form/test.phtml +38 -0
  46. app/design/frontend/base/default/layout/me/gravity.xml +43 -0
  47. app/design/frontend/base/default/template/me/gravity/catalog/category/boxes/default.phtml +97 -0
  48. app/design/frontend/base/default/template/me/gravity/catalog/category/boxes/sidebar.phtml +96 -0
  49. app/design/frontend/base/default/template/me/gravity/catalog/product/view/boxes/default.phtml +95 -0
  50. app/design/frontend/base/default/template/me/gravity/catalog/product/view/boxes/sidebar.phtml +94 -0
  51. app/design/frontend/base/default/template/me/gravity/catalog/product/view/js/gravity.phtml +40 -0
  52. app/design/frontend/base/default/template/me/gravity/catalogsearch/advanced/js/gravity.phtml +51 -0
  53. app/design/frontend/base/default/template/me/gravity/catalogsearch/boxes/default.phtml +97 -0
  54. app/design/frontend/base/default/template/me/gravity/catalogsearch/boxes/sidebar.phtml +96 -0
  55. app/design/frontend/base/default/template/me/gravity/catalogsearch/js/gravity.phtml +36 -0
  56. app/design/frontend/base/default/template/me/gravity/checkout/cart/boxes/default.phtml +97 -0
  57. app/design/frontend/base/default/template/me/gravity/checkout/cart/boxes/sidebar.phtml +96 -0
  58. app/design/frontend/base/default/template/me/gravity/general/boxes/default.phtml +92 -0
  59. app/design/frontend/base/default/template/me/gravity/general/boxes/sidebar.phtml +91 -0
  60. app/design/frontend/base/default/template/me/gravity/page/js/body-end.phtml +31 -0
  61. app/design/frontend/base/default/template/me/gravity/page/js/gravity.phtml +35 -0
  62. app/design/frontend/base/default/template/me/gravity/widget/boxes/widget.phtml +92 -0
  63. app/design/frontend/rwd/default/template/me/gravity/catalog/category/boxes/default.phtml +97 -0
  64. app/design/frontend/rwd/default/template/me/gravity/catalog/category/boxes/sidebar.phtml +96 -0
  65. app/design/frontend/rwd/default/template/me/gravity/catalog/product/view/boxes/default.phtml +95 -0
  66. app/design/frontend/rwd/default/template/me/gravity/catalog/product/view/boxes/sidebar.phtml +94 -0
  67. app/design/frontend/rwd/default/template/me/gravity/catalogsearch/boxes/default.phtml +97 -0
  68. app/design/frontend/rwd/default/template/me/gravity/catalogsearch/boxes/sidebar.phtml +96 -0
  69. app/design/frontend/rwd/default/template/me/gravity/checkout/cart/boxes/default.phtml +97 -0
  70. app/design/frontend/rwd/default/template/me/gravity/checkout/cart/boxes/sidebar.phtml +96 -0
  71. app/design/frontend/rwd/default/template/me/gravity/general/boxes/default.phtml +92 -0
  72. app/design/frontend/rwd/default/template/me/gravity/general/boxes/sidebar.phtml +91 -0
  73. app/design/frontend/rwd/default/template/me/gravity/widget/boxes/widget.phtml +94 -0
  74. app/etc/modules/Me_Gravity.xml +27 -0
  75. app/locale/en_US/Me_Gravity.csv +160 -0
  76. package.xml +20 -0
  77. skin/frontend/base/default/css/me/gravity/gravity.css +11 -0
app/code/community/Me/Gravity/Block/Abstract.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Abstract
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Abstract
15
+ */
16
+ class Me_Gravity_Block_Abstract extends Mage_Core_Block_Template
17
+ {
18
+ /**
19
+ * Get extension is enabled
20
+ *
21
+ * @return bool
22
+ */
23
+ public function isEnabled()
24
+ {
25
+ return $this->getGravityHelper()->isFullyEnabled();
26
+ }
27
+
28
+ /**
29
+ * Get Gravity extension helper
30
+ *
31
+ * @return Me_Gravity_Helper_Data
32
+ */
33
+ public function getGravityHelper()
34
+ {
35
+ return Mage::helper('me_gravity');
36
+ }
37
+ }
app/code/community/Me/Gravity/Block/Adminhtml/System/Config/Form/Catalog.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Adminhtml_System_Config_Form_Catalog
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Adminhtml_System_Config_Form_Catalog
15
+ */
16
+ class Me_Gravity_Block_Adminhtml_System_Config_Form_Catalog extends Mage_Adminhtml_Block_System_Config_Form_Field
17
+ {
18
+ /**
19
+ * Path to store config catalog export file save path
20
+ *
21
+ * @var string
22
+ */
23
+ const XML_CATALOG_EXPORT_PATH = 'gravity/export/catalog_path';
24
+
25
+ /**
26
+ * Return element html
27
+ *
28
+ * @param Varien_Data_Form_Element_Abstract $element element
29
+ * @return string
30
+ */
31
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
32
+ {
33
+ return $this->getButtonHtml();
34
+ }
35
+
36
+ /**
37
+ * Return url for button
38
+ *
39
+ * @return string
40
+ */
41
+ public function getExportUrl()
42
+ {
43
+ return Mage::helper('adminhtml')->getUrl(
44
+ 'adminhtml/gravity/exportcatalog',
45
+ array('store' => Mage::app()->getRequest()->getParam('store'))
46
+ );
47
+ }
48
+
49
+ /**
50
+ * Generate button html
51
+ *
52
+ * @return string
53
+ */
54
+ public function getButtonHtml()
55
+ {
56
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
57
+ ->setData(
58
+ array(
59
+ 'id' => 'gravity_catalog_button',
60
+ 'label' => $this->_getGravityHelper()->__('Export Products'),
61
+ 'onclick' => "setLocation('" . $this->getExportUrl() . "')",
62
+ 'disabled' => $this->_getIsButtonEnabled()
63
+ )
64
+ );
65
+
66
+ return $button->toHtml();
67
+ }
68
+
69
+ /**
70
+ * Check if button enabled
71
+ *
72
+ * @return bool
73
+ */
74
+ private function _getIsButtonEnabled()
75
+ {
76
+ if ($this->_getGravityHelper()->isFullyEnabled() && $this->_getCatalogFilePath()) {
77
+ return false;
78
+ } else {
79
+ return true;
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Get extension helper
85
+ *
86
+ * @return Me_Gravity_Helper_Data
87
+ */
88
+ private function _getGravityHelper()
89
+ {
90
+ return Mage::helper('me_gravity');
91
+ }
92
+
93
+ /**
94
+ * Get catalog export file path
95
+ *
96
+ * @param integer|string|Mage_Core_Model_Store $store store
97
+ * @return boolean
98
+ */
99
+ private function _getCatalogFilePath($store = null)
100
+ {
101
+ return Mage::getStoreConfig(self::XML_CATALOG_EXPORT_PATH, $store);
102
+ }
103
+ }
app/code/community/Me/Gravity/Block/Adminhtml/System/Config/Form/Customer.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Adminhtml_System_Config_Form_Customer
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Adminhtml_System_Config_Form_Customer
15
+ */
16
+ class Me_Gravity_Block_Adminhtml_System_Config_Form_Customer extends Mage_Adminhtml_Block_System_Config_Form_Field
17
+ {
18
+ /**
19
+ * Return element html
20
+ *
21
+ * @param Varien_Data_Form_Element_Abstract $element element
22
+ * @return string
23
+ */
24
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
25
+ {
26
+ return $this->getButtonHtml();
27
+ }
28
+
29
+ /**
30
+ * Return url for button
31
+ *
32
+ * @return string
33
+ */
34
+ public function getExportUrl()
35
+ {
36
+ return Mage::helper('adminhtml')->getUrl(
37
+ 'adminhtml/gravity/exportcustomer',
38
+ array('store' => Mage::app()->getRequest()->getParam('store'))
39
+ );
40
+ }
41
+
42
+ /**
43
+ * Generate button html
44
+ *
45
+ * @return string
46
+ */
47
+ public function getButtonHtml()
48
+ {
49
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
50
+ ->setData(
51
+ array(
52
+ 'id' => 'gravity_customer_button',
53
+ 'label' => $this->_getGravityHelper()->__('Export Customers'),
54
+ 'onclick' => "setLocation('" . $this->getExportUrl() . "')",
55
+ 'disabled' => !$this->_getGravityHelper()->isFullyEnabled()
56
+ )
57
+ );
58
+
59
+ return $button->toHtml();
60
+ }
61
+
62
+ /**
63
+ * Get extension helper
64
+ *
65
+ * @return Me_Gravity_Helper_Data
66
+ */
67
+ private function _getGravityHelper()
68
+ {
69
+ return Mage::helper('me_gravity');
70
+ }
71
+ }
app/code/community/Me/Gravity/Block/Adminhtml/System/Config/Form/Test.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Adminhtml_System_Config_Form_Test
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Adminhtml_System_Config_Form_Test
15
+ */
16
+ class Me_Gravity_Block_Adminhtml_System_Config_Form_Test extends Mage_Adminhtml_Block_System_Config_Form_Field
17
+ {
18
+ /**
19
+ * Construct
20
+ *
21
+ * @return void
22
+ */
23
+ protected function _construct()
24
+ {
25
+ parent::_construct();
26
+ $this->setTemplate('me/gravity/system/config/form/test.phtml');
27
+ }
28
+
29
+ /**
30
+ * Return element html
31
+ *
32
+ * @param Varien_Data_Form_Element_Abstract $element element
33
+ * @return string
34
+ */
35
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
36
+ {
37
+ return $this->_toHtml();
38
+ }
39
+
40
+ /**
41
+ * Return ajax url for button
42
+ *
43
+ * @return string
44
+ */
45
+ public function getAjaxTestUrl()
46
+ {
47
+ return Mage::helper('adminhtml')->getUrl('adminhtml/gravity/test');
48
+ }
49
+
50
+ /**
51
+ * Generate button html
52
+ *
53
+ * @return string
54
+ */
55
+ public function getButtonHtml()
56
+ {
57
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
58
+ ->setData(
59
+ array(
60
+ 'id' => 'gravity_test_button',
61
+ 'label' => $this->_getGravityHelper()->__('Test Connection'),
62
+ 'onclick' => 'javascript:check(); return false;',
63
+ 'disabled' => $this->_getIsButtonEnabled()
64
+ )
65
+ );
66
+
67
+ return $button->toHtml();
68
+ }
69
+
70
+ /**
71
+ * Check if button enabled
72
+ *
73
+ * @return bool
74
+ */
75
+ private function _getIsButtonEnabled()
76
+ {
77
+ if ($this->_getGravityHelper()->isFullyEnabled()) {
78
+ return false;
79
+ } else {
80
+ return true;
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Get Gravity extension helper
86
+ *
87
+ * @return Me_Gravity_Helper_Data
88
+ */
89
+ public function _getGravityHelper()
90
+ {
91
+ return Mage::helper('me_gravity');
92
+ }
93
+ }
app/code/community/Me/Gravity/Block/Catalog/Category/Boxes/Category.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Catalog_Category_Boxes_Category
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Catalog_Category_Boxes_Category
15
+ */
16
+ class Me_Gravity_Block_Catalog_Category_Boxes_Category extends Me_Gravity_Block_Recommendation
17
+ {
18
+ /**
19
+ * @var array|null
20
+ */
21
+ protected $_filters = null;
22
+
23
+ /**
24
+ * Get recommended items
25
+ *
26
+ * @return $this|bool
27
+ */
28
+ public function getProductCollection()
29
+ {
30
+ if ($this->getRecommendationType()) {
31
+
32
+ $items = Mage::getModel('me_gravity/method_request')->sendRequest(
33
+ Me_Gravity_Model_Method_Request::EVENT_TYPE_GET,
34
+ array(
35
+ 'type' => $this->_recommendationType,
36
+ 'limit' => $this->_recommendationLimit,
37
+ 'filters' => $this->_filters ? $this->_filters : null
38
+ )
39
+ );
40
+
41
+ if (!empty($items)) {
42
+
43
+ $this->_recommendationId = key($items);
44
+ $itemCollection = $this->_getProductCollection();
45
+ $itemCollection->addAttributeToFilter('entity_id', array('in' => $items));
46
+ $itemCollection->load();
47
+
48
+ } else {
49
+
50
+ $itemCollection = null;
51
+
52
+ }
53
+
54
+ return $itemCollection;
55
+
56
+ } else {
57
+
58
+ return null;
59
+
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Get all filters
65
+ *
66
+ * @return array
67
+ */
68
+ public function getFilters()
69
+ {
70
+ return $this->_filters;
71
+ }
72
+
73
+ /**
74
+ * Set current category filters
75
+ *
76
+ * @return array
77
+ * @throws Exception
78
+ */
79
+ protected function _setFilters()
80
+ {
81
+ try {
82
+
83
+ if (is_null($this->_filters)) {
84
+ $this->_filters['categoryId'] = $this->_getCurrentCategory()->getId();
85
+ $this->_filters = array_merge($this->_filters, $this->getRequest()->getParams());
86
+ if (isset($this->_filters['id'])) {
87
+ unset($this->_filters['id']);
88
+ }
89
+ }
90
+ return $this->_filters;
91
+
92
+ } catch (Mage_Core_Exception $e) {
93
+ $this->getGravityHelper()->getLogger($e->getMessage());
94
+ } catch (Exception $e) {
95
+ $this->getGravityHelper()->getLogger(
96
+ $e->getMessage(),
97
+ $this->getGravityHelper()->__('An error occurred while setting category filters.')
98
+ );
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Retrieve current category model object
104
+ *
105
+ * @return Mage_Catalog_Model_Category
106
+ */
107
+ protected function _getCurrentCategory()
108
+ {
109
+ if (!$this->hasData('current_category')) {
110
+ $this->setData('current_category', Mage::registry('current_category'));
111
+ }
112
+ return $this->getData('current_category');
113
+ }
114
+
115
+ /**
116
+ * Retrieve active filters
117
+ *
118
+ * @return array
119
+ */
120
+ public function getActiveFilters()
121
+ {
122
+ $filters = $this->getLayer()->getState()->getFilters();
123
+ if (!is_array($filters)) {
124
+ $filters = array();
125
+ }
126
+ return $filters;
127
+ }
128
+
129
+ /**
130
+ * Retrieve Layer object
131
+ *
132
+ * @return Mage_Catalog_Model_Layer
133
+ */
134
+ public function getLayer()
135
+ {
136
+ if (!$this->hasData('layer')) {
137
+ $this->setLayer(Mage::getSingleton('catalog/layer'));
138
+ }
139
+ return $this->_getData('layer');
140
+ }
141
+ }
app/code/community/Me/Gravity/Block/Catalog/Category/Boxes/Personal.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Catalog_Category_Boxes_Personal
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Catalog_Category_Boxes_Personal
15
+ */
16
+ class Me_Gravity_Block_Catalog_Category_Boxes_Personal extends Me_Gravity_Block_Catalog_Category_Boxes_Category
17
+ {
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $_boxClass = 'personal';
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ protected $_pageType = 'category';
27
+
28
+ /**
29
+ * Construct
30
+ *
31
+ * @return void
32
+ */
33
+ protected function _construct()
34
+ {
35
+ $boxHelper = $this->_getGravityBoxHelper();
36
+
37
+ $this->setRecommendationType(Me_Gravity_Model_Method_Request::CATEGORY_PAGE_PERSONAL);
38
+
39
+ $boxTitle = $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
40
+ ? $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
41
+ : $this->getGravityHelper()->__('Personal Product(s)');
42
+ $this->setRecommendationTitle($boxTitle);
43
+
44
+ $this->setRecommendationLimit($boxHelper->getBoxLimit($this->_boxClass, $this->_pageType));
45
+ $this->setBoxColumnCount($boxHelper->getBoxColumns($this->_boxClass, $this->_pageType));
46
+
47
+ $this->_setFilters();
48
+
49
+ parent::_construct();
50
+ }
51
+ }
app/code/community/Me/Gravity/Block/Catalog/Category/Boxes/Top.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Catalog_Category_Boxes_Top
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Catalog_Category_Boxes_Top
15
+ */
16
+ class Me_Gravity_Block_Catalog_Category_Boxes_Top extends Me_Gravity_Block_Catalog_Category_Boxes_Category
17
+ {
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $_boxClass = 'top';
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ protected $_pageType = 'category';
27
+
28
+ /**
29
+ * Construct
30
+ *
31
+ * @return void
32
+ */
33
+ protected function _construct()
34
+ {
35
+ $boxHelper = $this->_getGravityBoxHelper();
36
+
37
+ $this->setRecommendationType(Me_Gravity_Model_Method_Request::CATEGORY_PAGE_TOP);
38
+
39
+ $boxTitle = $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
40
+ ? $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
41
+ : $this->getGravityHelper()->__('Top Product(s)');
42
+ $this->setRecommendationTitle($boxTitle);
43
+
44
+ $this->setRecommendationLimit($boxHelper->getBoxLimit($this->_boxClass, $this->_pageType));
45
+ $this->setBoxColumnCount($boxHelper->getBoxColumns($this->_boxClass, $this->_pageType));
46
+
47
+ $this->_setFilters();
48
+
49
+ parent::_construct();
50
+ }
51
+ }
app/code/community/Me/Gravity/Block/Catalog/Product/View/Boxes/Accessories.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Catalog_Product_View_Boxes_Accessories
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Catalog_Product_View_Boxes_Accessories
15
+ */
16
+ class Me_Gravity_Block_Catalog_Product_View_Boxes_Accessories extends Me_Gravity_Block_Catalog_Product_View_Boxes_Product
17
+ {
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $_boxClass = 'accessories';
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ protected $_pageType = 'product';
27
+
28
+ /**
29
+ * Construct
30
+ *
31
+ * @return void
32
+ */
33
+ protected function _construct()
34
+ {
35
+ $boxHelper = $this->_getGravityBoxHelper();
36
+
37
+ $this->setRecommendationType(Me_Gravity_Model_Method_Request::PRODUCT_PAGE_ACCESSORIES);
38
+
39
+ $boxTitle = $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
40
+ ? $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
41
+ : $this->getGravityHelper()->__('Accessories');
42
+ $this->setRecommendationTitle($boxTitle);
43
+
44
+ $this->setRecommendationLimit($boxHelper->getBoxLimit($this->_boxClass, $this->_pageType));
45
+ $this->setBoxColumnCount($boxHelper->getBoxColumns($this->_boxClass, $this->_pageType));
46
+
47
+ parent::_construct();
48
+ }
49
+ }
app/code/community/Me/Gravity/Block/Catalog/Product/View/Boxes/Personal.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Catalog_Product_View_Boxes_Personal
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Catalog_Product_View_Boxes_Personal
15
+ */
16
+ class Me_Gravity_Block_Catalog_Product_View_Boxes_Personal extends Me_Gravity_Block_Catalog_Product_View_Boxes_Product
17
+ {
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $_boxClass = 'personal';
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ protected $_pageType = 'product';
27
+
28
+ /**
29
+ * Construct
30
+ *
31
+ * @return void
32
+ */
33
+ protected function _construct()
34
+ {
35
+ $boxHelper = $this->_getGravityBoxHelper();
36
+
37
+ $this->setRecommendationType(Me_Gravity_Model_Method_Request::PRODUCT_PAGE_PERSONAL);
38
+
39
+ $boxTitle = $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
40
+ ? $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
41
+ : $this->getGravityHelper()->__('Personal Product(s)');
42
+ $this->setRecommendationTitle($boxTitle);
43
+
44
+ $this->setRecommendationLimit($boxHelper->getBoxLimit($this->_boxClass, $this->_pageType));
45
+ $this->setBoxColumnCount($boxHelper->getBoxColumns($this->_boxClass, $this->_pageType));
46
+
47
+ parent::_construct();
48
+ }
49
+ }
app/code/community/Me/Gravity/Block/Catalog/Product/View/Boxes/Product.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Catalog_Product_View_Boxes_Product
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Catalog_Product_View_Boxes_Product
15
+ */
16
+ class Me_Gravity_Block_Catalog_Product_View_Boxes_Product extends Me_Gravity_Block_Recommendation
17
+ {
18
+ /**
19
+ * Get recommended items
20
+ *
21
+ * @return $this|bool
22
+ */
23
+ public function getProductCollection()
24
+ {
25
+ if ($this->getRecommendationType()) {
26
+
27
+ $items = Mage::getModel('me_gravity/method_request')->sendRequest(
28
+ Me_Gravity_Model_Method_Request::EVENT_TYPE_GET,
29
+ array(
30
+ 'type' => $this->_recommendationType,
31
+ 'limit' => $this->_recommendationLimit,
32
+ 'itemId' => $this->getProduct() ? $this->getProduct()->getId() : null
33
+ )
34
+ );
35
+
36
+ if (!empty($items)) {
37
+ $this->_recommendationId = key($items);
38
+ $itemCollection = $this->_getProductCollection();
39
+ $itemCollection->addAttributeToFilter('entity_id', array('in' => $items));
40
+ $itemCollection->load();
41
+
42
+ } else {
43
+
44
+ $itemCollection = null;
45
+
46
+ }
47
+
48
+ return $itemCollection;
49
+
50
+ } else {
51
+
52
+ return null;
53
+
54
+ }
55
+ }
56
+ }
app/code/community/Me/Gravity/Block/Catalog/Product/View/Boxes/Similar.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Catalog_Product_View_Boxes_Similar
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Catalog_Product_View_Boxes_Similar
15
+ */
16
+ class Me_Gravity_Block_Catalog_Product_View_Boxes_Similar extends Me_Gravity_Block_Catalog_Product_View_Boxes_Product
17
+ {
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $_boxClass = 'similar';
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ protected $_pageType = 'product';
27
+
28
+ /**
29
+ * Construct
30
+ *
31
+ * @return void
32
+ */
33
+ protected function _construct()
34
+ {
35
+ $boxHelper = $this->_getGravityBoxHelper();
36
+
37
+ $this->setRecommendationType(Me_Gravity_Model_Method_Request::PRODUCT_PAGE_SIMILAR);
38
+
39
+ $boxTitle = $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
40
+ ? $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
41
+ : $this->getGravityHelper()->__('Similar Product(s)');
42
+ $this->setRecommendationTitle($boxTitle);
43
+
44
+ $this->setRecommendationLimit($boxHelper->getBoxLimit($this->_boxClass, $this->_pageType));
45
+ $this->setBoxColumnCount($boxHelper->getBoxColumns($this->_boxClass, $this->_pageType));
46
+
47
+ parent::_construct();
48
+ }
49
+ }
app/code/community/Me/Gravity/Block/Catalog/Product/View/Js/Gravity.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Catalog_Product_View_Js_Gravity
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Catalog_Product_View_Js_Gravity
15
+ */
16
+ class Me_Gravity_Block_Catalog_Product_View_Js_Gravity extends Mage_Catalog_Block_Product_View
17
+ {
18
+ /**
19
+ * Get extension is properly enabled
20
+ *
21
+ * @return bool
22
+ */
23
+ public function isEnabled()
24
+ {
25
+ return $this->getGravityHelper()->isFullyEnabled();
26
+ }
27
+
28
+ /**
29
+ * Get current customer id
30
+ *
31
+ * @return int|null
32
+ */
33
+ public function getCustomerId()
34
+ {
35
+ return Mage::getSingleton('customer/session')->getCustomerId();
36
+ }
37
+
38
+ /**
39
+ * Get current Gravity category id
40
+ *
41
+ * @return bool
42
+ */
43
+ public function getGravityCategoryId()
44
+ {
45
+ $currentCategory = Mage::registry('current_category');
46
+
47
+ if (!is_null($currentCategory) && $currentCategory->getId()) {
48
+ return $currentCategory->getId();
49
+ }
50
+
51
+ return false;
52
+ }
53
+
54
+ /**
55
+ * Get Gravity extension helper
56
+ *
57
+ * @return Me_Gravity_Helper_Data
58
+ */
59
+ public function getGravityHelper()
60
+ {
61
+ return Mage::helper('me_gravity');
62
+ }
63
+ }
app/code/community/Me/Gravity/Block/Catalogsearch/Advanced/Js/Gravity.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Catalogsearch_Advanced_Js_Gravity
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Catalogsearch_Advanced_Js_Gravity
15
+ */
16
+ class Me_Gravity_Block_Catalogsearch_Advanced_Js_Gravity extends Mage_CatalogSearch_Block_Advanced_Result
17
+ {
18
+ /**
19
+ * Get extension is properly enabled
20
+ *
21
+ * @return bool
22
+ */
23
+ public function isEnabled()
24
+ {
25
+ return $this->getGravityHelper()->isFullyEnabled();
26
+ }
27
+
28
+ /**
29
+ * Get search criterias
30
+ *
31
+ * @return array
32
+ */
33
+ public function getSearchCriterias()
34
+ {
35
+ return $this->getSearchModel()->getSearchCriterias();
36
+ }
37
+
38
+ /**
39
+ * Get current customer id
40
+ *
41
+ * @return int|null
42
+ */
43
+ public function getCustomerId()
44
+ {
45
+ return Mage::getSingleton('customer/session')->getCustomerId();
46
+ }
47
+
48
+ /**
49
+ * Get Gravity extension helper
50
+ *
51
+ * @return Me_Gravity_Helper_Data
52
+ */
53
+ public function getGravityHelper()
54
+ {
55
+ return Mage::helper('me_gravity');
56
+ }
57
+ }
app/code/community/Me/Gravity/Block/Catalogsearch/Boxes/Result.php ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_CatalogSearch_Boxes_Result
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_CatalogSearch_Boxes_Result
15
+ */
16
+ class Me_Gravity_Block_Catalogsearch_Boxes_Result extends Me_Gravity_Block_Recommendation
17
+ {
18
+ /**
19
+ * @var array|null
20
+ */
21
+ protected $_keywords = null;
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ protected $_boxClass = 'search';
27
+
28
+ /**
29
+ * @var string
30
+ */
31
+ protected $_pageType = 'search';
32
+
33
+ /**
34
+ * Construct
35
+ *
36
+ * @return void
37
+ */
38
+ protected function _construct()
39
+ {
40
+ $boxHelper = $this->_getGravityBoxHelper();
41
+
42
+ $this->setRecommendationType(Me_Gravity_Model_Method_Request::SEARCH_RESULT_PAGE);
43
+
44
+ $boxTitle = $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
45
+ ? $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
46
+ : $this->getGravityHelper()->__('Recommended for you');
47
+ $this->setRecommendationTitle($boxTitle);
48
+
49
+ $this->setRecommendationLimit($boxHelper->getBoxLimit($this->_boxClass, $this->_pageType));
50
+ $this->setBoxColumnCount($boxHelper->getBoxColumns($this->_boxClass, $this->_pageType));
51
+
52
+ $this->_setSearchKeywords();
53
+
54
+ parent::_construct();
55
+ }
56
+
57
+ /**
58
+ * Get recommended items
59
+ *
60
+ * @return $this|bool
61
+ */
62
+ public function getProductCollection()
63
+ {
64
+ if ($this->getRecommendationType()) {
65
+
66
+ $items = Mage::getModel('me_gravity/method_request')->sendRequest(
67
+ Me_Gravity_Model_Method_Request::EVENT_TYPE_GET,
68
+ array(
69
+ 'type' => $this->_recommendationType,
70
+ 'limit' => $this->_recommendationLimit,
71
+ 'keywords' => $this->_keywords ? $this->_keywords : null
72
+ )
73
+ );
74
+
75
+ if (!empty($items)) {
76
+
77
+ $this->_recommendationId = key($items);
78
+ $itemCollection = $this->_getProductCollection();
79
+ $itemCollection->addAttributeToFilter('entity_id', array('in' => $items));
80
+ $itemCollection->load();
81
+
82
+ } else {
83
+
84
+ $itemCollection = null;
85
+
86
+ }
87
+
88
+ return $itemCollection;
89
+
90
+ } else {
91
+
92
+ return null;
93
+
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Get search keywords
99
+ *
100
+ * @return string
101
+ */
102
+ public function getSearchKeyword()
103
+ {
104
+ return Mage::helper('catalogsearch')->getEscapedQueryText();
105
+ }
106
+
107
+ /**
108
+ * Get search criterias
109
+ *
110
+ * @return array
111
+ */
112
+ public function getSearchCriterias()
113
+ {
114
+ return $this->getRequest()->getQuery();
115
+ }
116
+
117
+ /**
118
+ * Get all search keyword
119
+ *
120
+ * @return array
121
+ */
122
+ public function getSearchKeywords()
123
+ {
124
+ return $this->_keywords;
125
+ }
126
+
127
+ /**
128
+ * Set current search keywords
129
+ *
130
+ * @return array
131
+ * @throws Exception
132
+ */
133
+ protected function _setSearchKeywords()
134
+ {
135
+ try {
136
+
137
+ if (is_null($this->_keywords)) {
138
+ if ($this->getSearchKeyword()) {
139
+ $this->_keywords['searchKeyword'] = $this->getSearchKeyword();
140
+ }
141
+ $searchCriterias = $this->getSearchCriterias();
142
+ if (isset($searchCriterias['q'])) {
143
+ unset($searchCriterias['q']);
144
+ }
145
+ if (!empty($searchCriterias)) {
146
+ foreach ($searchCriterias as $key => $criteria) {
147
+ if ($key == 'price') {
148
+
149
+ if (isset($criteria['from'])) {
150
+ $this->_keywords['minPrice'] = $criteria['from'];
151
+ }
152
+ if (isset($criteria['to'])) {
153
+ $this->_keywords['maxPrice'] = $criteria['to'];
154
+ }
155
+
156
+ } else {
157
+ if (is_array($criteria)) {
158
+ $this->_keywords[$key] = $this->escapeHtml(strtolower(implode(',', $criteria)));
159
+ } else {
160
+ $this->_keywords[$key] = $this->escapeHtml(strtolower($criteria));
161
+ }
162
+
163
+ }
164
+
165
+ }
166
+ }
167
+
168
+ }
169
+
170
+ return $this->_keywords;
171
+
172
+ } catch (Mage_Core_Exception $e) {
173
+ $this->getGravityHelper()->getLogger($e->getMessage());
174
+ } catch (Exception $e) {
175
+ $this->getGravityHelper()->getLogger(
176
+ $e->getMessage(),
177
+ $this->getGravityHelper()->__('An error occurred while setting search keywords.')
178
+ );
179
+ }
180
+ }
181
+ }
app/code/community/Me/Gravity/Block/Catalogsearch/Js/Gravity.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Catalogsearch_Js_Gravity
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Catalogsearch_Js_Gravity
15
+ */
16
+ class Me_Gravity_Block_Catalogsearch_Js_Gravity extends Mage_CatalogSearch_Block_Result
17
+ {
18
+ /**
19
+ * Get extension is properly enabled
20
+ *
21
+ * @return bool
22
+ */
23
+ public function isEnabled()
24
+ {
25
+ return $this->getGravityHelper()->isFullyEnabled();
26
+ }
27
+
28
+ /**
29
+ * Get search keywords
30
+ *
31
+ * @return string
32
+ */
33
+ public function getSearchKeyword()
34
+ {
35
+ return $this->helper('catalogsearch')->getEscapedQueryText();
36
+ }
37
+
38
+ /**
39
+ * Get current customer id
40
+ *
41
+ * @return int|null
42
+ */
43
+ public function getCustomerId()
44
+ {
45
+ return Mage::getSingleton('customer/session')->getCustomerId();
46
+ }
47
+
48
+ /**
49
+ * Get Gravity extension helper
50
+ *
51
+ * @return Me_Gravity_Helper_Data
52
+ */
53
+ public function getGravityHelper()
54
+ {
55
+ return Mage::helper('me_gravity');
56
+ }
57
+ }
app/code/community/Me/Gravity/Block/Checkout/Cart/Boxes/Cart.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Checkout_Cart_Boxes_Cart
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Checkout_Cart_Boxes_Cart
15
+ */
16
+ class Me_Gravity_Block_Checkout_Cart_Boxes_Cart extends Me_Gravity_Block_Recommendation
17
+ {
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $_boxClass = 'cart';
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ protected $_pageType = 'cart';
27
+
28
+ /**
29
+ * @var array
30
+ */
31
+ protected $_itemsInCart = array();
32
+
33
+ /**
34
+ * Construct
35
+ *
36
+ * @return void
37
+ */
38
+ protected function _construct()
39
+ {
40
+ $boxHelper = $this->_getGravityBoxHelper();
41
+
42
+ $this->setRecommendationType(Me_Gravity_Model_Method_Request::CART_PAGE);
43
+
44
+ $boxTitle = $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
45
+ ? $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
46
+ : $this->getGravityHelper()->__('Personal Product(s)');
47
+ $this->setRecommendationTitle($boxTitle);
48
+
49
+ $this->setRecommendationLimit($boxHelper->getBoxLimit($this->_boxClass, $this->_pageType));
50
+ $this->setBoxColumnCount($boxHelper->getBoxColumns($this->_boxClass, $this->_pageType));
51
+
52
+ $this->_itemsInCart = $this->_getProductIdsInCart();
53
+
54
+ parent::_construct();
55
+ }
56
+
57
+ /**
58
+ * Get cart items
59
+ *
60
+ * @return $this|bool
61
+ */
62
+ public function getProductCollection()
63
+ {
64
+ if ($this->getRecommendationType()) {
65
+
66
+ $items = Mage::getModel('me_gravity/method_request')->sendRequest(
67
+ Me_Gravity_Model_Method_Request::EVENT_TYPE_GET,
68
+ array(
69
+ 'type' => $this->_recommendationType,
70
+ 'limit' => $this->_recommendationLimit,
71
+ 'itemsInCart' => $this->_itemsInCart ? $this->_itemsInCart : null
72
+ )
73
+ );
74
+
75
+ if (!empty($items)) {
76
+ $this->_recommendationId = key($items);
77
+ $itemCollection = $this->_getProductCollection();
78
+ $itemCollection->addAttributeToFilter('entity_id', array('in' => $items));
79
+ $itemCollection->load();
80
+
81
+ } else {
82
+
83
+ $itemCollection = null;
84
+
85
+ }
86
+
87
+ return $itemCollection;
88
+
89
+ } else {
90
+
91
+ return null;
92
+
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Get cart product ids
98
+ *
99
+ * @return array
100
+ */
101
+ public function getCartItems()
102
+ {
103
+ return $this->_itemsInCart;
104
+ }
105
+ }
app/code/community/Me/Gravity/Block/General/Boxes/Best.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_General_Boxes_Best
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_General_Boxes_Best
15
+ */
16
+ class Me_Gravity_Block_General_Boxes_Best extends Me_Gravity_Block_Recommendation
17
+ {
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $_boxClass = 'best';
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ protected $_pageType = 'general';
27
+
28
+ /**
29
+ * Construct
30
+ *
31
+ * @return void
32
+ */
33
+ protected function _construct()
34
+ {
35
+ $boxHelper = $this->_getGravityBoxHelper();
36
+
37
+ $this->setRecommendationType(Me_Gravity_Model_Method_Request::GENERAL_PERSONAL_BEST);
38
+
39
+ $boxTitle = $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
40
+ ? $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
41
+ : $this->getGravityHelper()->__('Recommended for you');
42
+ $this->setRecommendationTitle($boxTitle);
43
+
44
+ $this->setRecommendationLimit($boxHelper->getBoxLimit($this->_boxClass, $this->_pageType));
45
+ $this->setBoxColumnCount($boxHelper->getBoxColumns($this->_boxClass, $this->_pageType));
46
+
47
+ parent::_construct();
48
+ }
49
+ }
app/code/community/Me/Gravity/Block/General/Boxes/History.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_General_Boxes_History
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_General_Boxes_History
15
+ */
16
+ class Me_Gravity_Block_General_Boxes_History extends Me_Gravity_Block_Recommendation
17
+ {
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $_boxClass = 'history';
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ protected $_pageType = 'general';
27
+
28
+ /**
29
+ * Construct
30
+ *
31
+ * @return void
32
+ */
33
+ protected function _construct()
34
+ {
35
+ $boxHelper = $this->_getGravityBoxHelper();
36
+
37
+ $this->setRecommendationType(Me_Gravity_Model_Method_Request::GENERAL_PERSONAL_HISTORY);
38
+
39
+ $boxTitle = $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
40
+ ? $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
41
+ : $this->getGravityHelper()->__('You viewed');
42
+ $this->setRecommendationTitle($boxTitle);
43
+
44
+ $this->setRecommendationLimit($boxHelper->getBoxLimit($this->_boxClass, $this->_pageType));
45
+ $this->setBoxColumnCount($boxHelper->getBoxColumns($this->_boxClass, $this->_pageType));
46
+
47
+ parent::_construct();
48
+ }
49
+ }
app/code/community/Me/Gravity/Block/General/Boxes/Others.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_General_Boxes_Others
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_General_Boxes_Others
15
+ */
16
+ class Me_Gravity_Block_General_Boxes_Others extends Me_Gravity_Block_Recommendation
17
+ {
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $_boxClass = 'others';
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ protected $_pageType = 'general';
27
+
28
+ /**
29
+ * Construct
30
+ *
31
+ * @return void
32
+ */
33
+ protected function _construct()
34
+ {
35
+ $boxHelper = $this->_getGravityBoxHelper();
36
+
37
+ $this->setRecommendationType(Me_Gravity_Model_Method_Request::GENERAL_CURRENTLY_VIEWED);
38
+
39
+ $boxTitle = $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
40
+ ? $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
41
+ : $this->getGravityHelper()->__('Others are looking at right now');
42
+ $this->setRecommendationTitle($boxTitle);
43
+
44
+ $this->setRecommendationLimit($boxHelper->getBoxLimit($this->_boxClass, $this->_pageType));
45
+ $this->setBoxColumnCount($boxHelper->getBoxColumns($this->_boxClass, $this->_pageType));
46
+
47
+ parent::_construct();
48
+ }
49
+ }
app/code/community/Me/Gravity/Block/General/Boxes/Popular.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_General_Boxes_Popular
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_General_Boxes_Popular
15
+ */
16
+ class Me_Gravity_Block_General_Boxes_Popular extends Me_Gravity_Block_Recommendation
17
+ {
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $_boxClass = 'popular';
22
+
23
+ /**
24
+ * @var string
25
+ */
26
+ protected $_pageType = 'general';
27
+
28
+ /**
29
+ * Construct
30
+ *
31
+ * @return void
32
+ */
33
+ protected function _construct()
34
+ {
35
+ $boxHelper = $this->_getGravityBoxHelper();
36
+
37
+ $this->setRecommendationType(Me_Gravity_Model_Method_Request::GENERAL_POPULAR);
38
+
39
+ $boxTitle = $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
40
+ ? $boxHelper->getBoxTitle($this->_boxClass, $this->_pageType)
41
+ : $this->getGravityHelper()->__('Top products');
42
+ $this->setRecommendationTitle($boxTitle);
43
+
44
+ $this->setRecommendationLimit($boxHelper->getBoxLimit($this->_boxClass, $this->_pageType));
45
+ $this->setBoxColumnCount($boxHelper->getBoxColumns($this->_boxClass, $this->_pageType));
46
+
47
+ parent::_construct();
48
+ }
49
+ }
app/code/community/Me/Gravity/Block/Page/Js/Gravity.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Page_Js_Gravity
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Page_Js_Gravity
15
+ */
16
+ class Me_Gravity_Block_Page_Js_Gravity extends Me_Gravity_Block_Abstract
17
+ {
18
+ /**
19
+ * Get Gravity customer Id
20
+ *
21
+ * @return string
22
+ */
23
+ public function getGravityCustomerId()
24
+ {
25
+ return $this->getGravityHelper()->getApiUser();
26
+ }
27
+
28
+ /**
29
+ * Get current customer id
30
+ *
31
+ * @return int|null
32
+ */
33
+ public function getCustomerId()
34
+ {
35
+ return Mage::getSingleton('customer/session')->getCustomerId();
36
+ }
37
+ }
app/code/community/Me/Gravity/Block/Recommendation.php ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Recommendation
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Recommendation
15
+ */
16
+ class Me_Gravity_Block_Recommendation extends Mage_Catalog_Block_Product_Abstract
17
+ {
18
+ /**
19
+ * @var Mage_Catalog_Model_Resource_Product_Collection
20
+ */
21
+ protected $_productCollection;
22
+
23
+ /**
24
+ * @var int
25
+ */
26
+ protected $_columnCount = 4;
27
+
28
+ /**
29
+ * @var string
30
+ */
31
+ protected $_recommendationType;
32
+
33
+ /**
34
+ * @var string
35
+ */
36
+ protected $_recommendationId;
37
+
38
+ /**
39
+ * @var string
40
+ */
41
+ protected $_recommendationTitle = '';
42
+
43
+ /**
44
+ * @var int
45
+ */
46
+ protected $_recommendationLimit = 10;
47
+
48
+ /**
49
+ * @var string
50
+ */
51
+ protected $_boxClass = '';
52
+
53
+ /**
54
+ * Get recommended items
55
+ *
56
+ * @return $this|bool
57
+ */
58
+ public function getProductCollection()
59
+ {
60
+ if ($this->getRecommendationType()) {
61
+
62
+ $items = Mage::getModel('me_gravity/method_request')->sendRequest(
63
+ Me_Gravity_Model_Method_Request::EVENT_TYPE_GET,
64
+ array(
65
+ 'type' => $this->_recommendationType,
66
+ 'limit' => $this->_recommendationLimit
67
+ )
68
+ );
69
+
70
+ if (!empty($items)) {
71
+
72
+ $this->_recommendationId = key($items);
73
+ $itemCollection = $this->_getProductCollection();
74
+ $itemCollection->addAttributeToFilter('entity_id', array('in' => $items));
75
+ $itemCollection->load();
76
+
77
+ } else {
78
+
79
+ $itemCollection = null;
80
+
81
+ }
82
+
83
+ return $itemCollection;
84
+
85
+ } else {
86
+
87
+ return null;
88
+
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Prepare product collection
94
+ *
95
+ * @return Mage_Catalog_Model_Resource_Product_Collection
96
+ */
97
+ protected function _getProductCollection()
98
+ {
99
+ if (is_null($this->_productCollection)) {
100
+
101
+ $collection = Mage::getResourceModel('catalog/product_collection')
102
+ ->addStoreFilter();
103
+
104
+ $this->_addProductAttributesAndPrices($collection);
105
+
106
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($collection);
107
+
108
+ $this->_productCollection = $collection;
109
+ }
110
+
111
+ return $this->_productCollection;
112
+ }
113
+
114
+ /**
115
+ * Get collection before rendering
116
+ *
117
+ * @return Mage_Core_Block_Abstract
118
+ */
119
+ protected function _beforeToHtml()
120
+ {
121
+ if (!$this->getGravityHelper()->useGravityTemplate()) {
122
+ $this->_getProductCollection();
123
+ }
124
+ return parent::_beforeToHtml();
125
+ }
126
+
127
+ /**
128
+ * Get recommendation id
129
+ *
130
+ * @return string
131
+ */
132
+ public function getRecommendationId()
133
+ {
134
+ return $this->_recommendationId;
135
+ }
136
+
137
+ /**
138
+ * Set type parameter
139
+ *
140
+ * @param string $type recommendation type
141
+ * @return string
142
+ */
143
+ public function setRecommendationType($type = '')
144
+ {
145
+ $this->_recommendationType = $type;
146
+ }
147
+
148
+ /**
149
+ * Get type
150
+ *
151
+ * @return string
152
+ */
153
+ public function getRecommendationType()
154
+ {
155
+ return $this->_recommendationType;
156
+ }
157
+
158
+ /**
159
+ * Set box title
160
+ *
161
+ * @param string $title box title
162
+ * @return void
163
+ */
164
+ public function setRecommendationTitle($title = '')
165
+ {
166
+ $this->_recommendationTitle = $title;
167
+ }
168
+
169
+ /**
170
+ * Get box title
171
+ *
172
+ * @return string
173
+ */
174
+ public function getRecommendationTitle()
175
+ {
176
+ return $this->_recommendationTitle;
177
+ }
178
+
179
+ /**
180
+ * Set item limit
181
+ *
182
+ * @param int $limit item limit
183
+ * @return void
184
+ */
185
+ public function setRecommendationLimit($limit = 10)
186
+ {
187
+ $this->_recommendationLimit = $limit;
188
+ }
189
+
190
+ /**
191
+ * Get item limit
192
+ *
193
+ * @return string
194
+ */
195
+ public function getRecommendationLimit()
196
+ {
197
+ return $this->_recommendationLimit;
198
+ }
199
+
200
+ /**
201
+ * Set box column count
202
+ *
203
+ * @param int $columns column count
204
+ * @return void
205
+ */
206
+ public function setBoxColumnCount($columns = 4)
207
+ {
208
+ $this->_columnCount = $columns;
209
+ }
210
+
211
+ /**
212
+ * Get box column count
213
+ *
214
+ * @return int
215
+ */
216
+ public function getBoxColumnCount()
217
+ {
218
+ return $this->_columnCount;
219
+ }
220
+
221
+ /**
222
+ * Get box class
223
+ *
224
+ * @return string
225
+ */
226
+ public function getBoxClass()
227
+ {
228
+ return $this->_boxClass;
229
+ }
230
+
231
+ /**
232
+ * Get product ids in cart
233
+ *
234
+ * @return array
235
+ */
236
+ protected function _getProductIdsInCart()
237
+ {
238
+ return Mage::getSingleton('checkout/cart')->getProductIds();
239
+ }
240
+
241
+ /**
242
+ * Retrieve Gravity boxes helper
243
+ *
244
+ * @return Me_Gravity_Helper_Boxes
245
+ */
246
+ protected function _getGravityBoxHelper()
247
+ {
248
+ return Mage::helper('me_gravity/boxes');
249
+ }
250
+
251
+ /**
252
+ * Get Gravity extension helper
253
+ *
254
+ * @return Me_Gravity_Helper_Data
255
+ */
256
+ public function getGravityHelper()
257
+ {
258
+ return Mage::helper('me_gravity');
259
+ }
260
+ }
app/code/community/Me/Gravity/Block/Widget/Boxes/Widget.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Widget_Boxes_Widget
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Widget_Boxes_Widget
15
+ * @method string getEventType()
16
+ * @method string getBoxTitle()
17
+ * @method int getBoxLimit()
18
+ * @method int getBoxColumns()
19
+ */
20
+ class Me_Gravity_Block_Widget_Boxes_Widget extends Me_Gravity_Block_Recommendation implements Mage_Widget_Block_Interface
21
+ {
22
+ /**
23
+ * @var string
24
+ */
25
+ protected $_boxClass = 'widget';
26
+
27
+ /**
28
+ * Allowed types
29
+ *
30
+ * @var array
31
+ */
32
+ protected $_allowedTypes = array(
33
+ 'personal_best',
34
+ 'personal_history',
35
+ 'currently_viewed',
36
+ 'popular'
37
+ );
38
+
39
+ /**
40
+ * Construct
41
+ *
42
+ * @return void
43
+ */
44
+ protected function _construct()
45
+ {
46
+ $boxHelper = $this->_getGravityBoxHelper();
47
+
48
+ if (!$this->setRecommendationType($this->getEventType())) {
49
+ return;
50
+ }
51
+
52
+ $this->setTemplate('me/gravity/widget/boxes/widget.phtml');
53
+ $this->setRecommendationTitle($this->getBoxTitle());
54
+ $this->setRecommendationLimit($this->getBoxLimit());
55
+ $this->setBoxColumnCount($this->getBoxColumns());
56
+
57
+ parent::_construct();
58
+ }
59
+
60
+ /**
61
+ * Set type parameter
62
+ *
63
+ * @param string $type recommendation type
64
+ * @return string|void
65
+ */
66
+ public function setRecommendationType($type = '')
67
+ {
68
+ if (in_array($type, $this->_allowedTypes)) {
69
+ $this->_recommendationType = $type;
70
+
71
+ return $this->_recommendationType;
72
+ } else {
73
+ return false;
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Set item limit
79
+ *
80
+ * @param int $limit limit
81
+ * @return int|void
82
+ */
83
+ public function setRecommendationLimit($limit = 10)
84
+ {
85
+ if (intval($limit)) {
86
+ $this->_recommendationLimit = $limit;
87
+ } else {
88
+ return 5;
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Set box column count
94
+ *
95
+ * @param int $columns column count
96
+ * @return int|void
97
+ */
98
+ public function setBoxColumnCount($columns = 4)
99
+ {
100
+ if (intval($columns)) {
101
+ $this->_columnCount = $columns;
102
+ } else {
103
+ return 4;
104
+ }
105
+ }
106
+ }
app/code/community/Me/Gravity/Helper/Boxes.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Helper_Boxes
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Helper_Boxes
15
+ */
16
+ class Me_Gravity_Helper_Boxes extends Mage_Core_Helper_Data
17
+ {
18
+ /**
19
+ * Get box enabled on product page
20
+ *
21
+ * @param string $boxName box name
22
+ * @param string $pageType page type
23
+ * @param integer|string|Mage_Core_Model_Store $store store
24
+ * @return bool
25
+ */
26
+ public function getBoxEnabled($boxName = '', $pageType = '', $store = null)
27
+ {
28
+ if ($boxName && $pageType) {
29
+ return Mage::getStoreConfigFlag('gravity/' . $pageType . '_display/' . $boxName . '_box', $store);
30
+ } else {
31
+ return false;
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Get box layout on product page
37
+ *
38
+ * @param string $boxName box name
39
+ * @param string $pageType page type
40
+ * @param integer|string|Mage_Core_Model_Store $store store
41
+ * @return bool
42
+ */
43
+ public function getBoxLayout($boxName = '', $pageType = '', $store = null)
44
+ {
45
+ if ($boxName && $pageType) {
46
+ return Mage::getStoreConfig('gravity/' . $pageType . '_display/' . $boxName . '_box_layout', $store);
47
+ } else {
48
+ return false;
49
+ }
50
+
51
+ }
52
+
53
+ /**
54
+ * Get box title
55
+ *
56
+ * @param string $boxName box name
57
+ * @param string $pageType page type
58
+ * @param integer|string|Mage_Core_Model_Store $store store
59
+ * @return bool
60
+ */
61
+ public function getBoxTitle($boxName = '', $pageType = '', $store = null)
62
+ {
63
+ if ($boxName && $pageType) {
64
+ return Mage::getStoreConfig('gravity/' . $pageType . '_display/' . $boxName . '_box_title', $store);
65
+ } else {
66
+ return false;
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Get box items limit
72
+ *
73
+ * @param string $boxName box name
74
+ * @param string $pageType page type
75
+ * @param integer|string|Mage_Core_Model_Store $store store
76
+ * @return bool
77
+ */
78
+ public function getBoxLimit($boxName = '', $pageType = '', $store = null)
79
+ {
80
+ if ($boxName && $pageType) {
81
+ return Mage::getStoreConfig('gravity/' . $pageType . '_display/' . $boxName . '_box_limit', $store);
82
+ } else {
83
+ return false;
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Get box column count
89
+ *
90
+ * @param string $boxName box name
91
+ * @param string $pageType page type
92
+ * @param integer|string|Mage_Core_Model_Store $store store
93
+ * @return bool
94
+ */
95
+ public function getBoxColumns($boxName = '', $pageType = '', $store = null)
96
+ {
97
+ if ($boxName && $pageType) {
98
+ return Mage::getStoreConfig('gravity/' . $pageType . '_display/' . $boxName . '_box_columns', $store);
99
+ } else {
100
+ return false;
101
+ }
102
+ }
103
+ }
app/code/community/Me/Gravity/Helper/Data.php ADDED
@@ -0,0 +1,398 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Helper_Data
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Helper_Data
15
+ */
16
+ class Me_Gravity_Helper_Data extends Mage_Core_Helper_Data
17
+ {
18
+ /**
19
+ * Extension log filename
20
+ *
21
+ * @var string
22
+ */
23
+ protected $_logfile = 'gravity.log';
24
+
25
+ /**
26
+ * Path to store config if extension is enabled
27
+ *
28
+ * @var string
29
+ */
30
+ const XML_PATH_ENABLED = 'gravity/config/enabled';
31
+
32
+ /**
33
+ * Path to store config if preview mode is enabled
34
+ *
35
+ * @var string
36
+ */
37
+ const XML_PATH_PREVIEW = 'gravity/config/preview';
38
+
39
+ /**
40
+ * Path to store config if debug mode is enabled
41
+ *
42
+ * @var string
43
+ */
44
+ const XML_PATH_DEBUG = 'gravity/debug/log';
45
+
46
+ /**
47
+ * Path to store config API username
48
+ *
49
+ * @var string
50
+ */
51
+ const XML_PATH_API_USER = 'gravity/config/api_user';
52
+
53
+ /**
54
+ * Path to store config API password
55
+ *
56
+ * @var string
57
+ */
58
+ const XML_PATH_API_PASSWORD = 'gravity/config/api_password';
59
+
60
+ /**
61
+ * Path to store config catalog export path
62
+ *
63
+ * @var string
64
+ */
65
+ const XML_PATH_EXPORT_PATH = 'gravity/export/catalog_path';
66
+
67
+ /**
68
+ * Path to store config use Gravity template
69
+ *
70
+ * @var string
71
+ */
72
+ const XML_PATH_USE_TEMPLATE = 'gravity/config/template';
73
+
74
+ /**
75
+ * Path to store config catalog export all
76
+ *
77
+ * @var string
78
+ */
79
+ const XML_CATALOG_EXPORT_ALL_PATH = 'gravity/export/all';
80
+
81
+ /**
82
+ * Path to store config catalog export maximum
83
+ *
84
+ * @var string
85
+ */
86
+ const XML_CATALOG_EXPORT_MAX_PATH = 'gravity/export/max';
87
+
88
+ /**
89
+ * Path to store config customer export all
90
+ *
91
+ * @var string
92
+ */
93
+ const XML_CUSTOMER_EXPORT_ALL_PATH = 'gravity/customer_export/all';
94
+
95
+ /**
96
+ * Path to store config customer export maximum
97
+ *
98
+ * @var string
99
+ */
100
+ const XML_CUSTOMER_EXPORT_MAX_PATH = 'gravity/customer_export/max';
101
+
102
+ /**
103
+ * Path to store config additional catalog attributes for export
104
+ *
105
+ * @var string
106
+ */
107
+ const XML_PATH_EXPORT_CATALOG_ADDITIONAL = 'gravity/export/additional';
108
+
109
+ /**
110
+ * Path to store config additional customer attributes for export
111
+ *
112
+ * @var string
113
+ */
114
+ const XML_PATH_EXPORT_CUSTOMER_ADDITIONAL = 'gravity/cutomer_export/additional';
115
+
116
+ /**
117
+ * Path to store config only salable parameter for export
118
+ *
119
+ * @var string
120
+ */
121
+ const XML_PATH_EXPORT_ONLY_SALABLE = 'gravity/export/only_salable';
122
+
123
+ /**
124
+ * Path to store config customer update synchronisation
125
+ *
126
+ * @var string
127
+ */
128
+ const XML_PATH_CUSTOMER_UPDATE = 'gravity/sync/customer_update';
129
+
130
+ /**
131
+ * Path to store config product update synchronisation
132
+ *
133
+ * @var string
134
+ */
135
+ const XML_PATH_PRODUCT_UPDATE = 'gravity/sync/product_update';
136
+
137
+ /**
138
+ * Path to store config customer register synchronisation
139
+ *
140
+ * @var string
141
+ */
142
+ const XML_PATH_CUSTOMER_REGISTER = 'gravity/sync/customer_registration';
143
+
144
+ /**
145
+ * Path to store config enabled pages in general layout
146
+ *
147
+ * @var string
148
+ */
149
+ const XML_PATH_ENABLED_PAGES = 'gravity/general_display/pages';
150
+
151
+ /**
152
+ * Checks whether extension is enabled
153
+ *
154
+ * @param integer|string|Mage_Core_Model_Store $store store
155
+ * @return boolean
156
+ */
157
+ public function isEnabled($store = null)
158
+ {
159
+ return Mage::getStoreConfigFlag(self::XML_PATH_ENABLED, $store);
160
+ }
161
+
162
+ /**
163
+ * Checks whether extension is in preview mode
164
+ *
165
+ * @param integer|string|Mage_Core_Model_Store $store store
166
+ * @return boolean
167
+ */
168
+ public function isPreviewMode($store = null)
169
+ {
170
+ if ($this->isFullyEnabled()) {
171
+ return Mage::getStoreConfigFlag(self::XML_PATH_PREVIEW, $store);
172
+ } else {
173
+ return false;
174
+ }
175
+ }
176
+
177
+ /**
178
+ * Checks whether extension is properly enabled, has API user and password
179
+ *
180
+ * @return bool
181
+ */
182
+ public function isFullyEnabled()
183
+ {
184
+ if ($this->isEnabled() && $this->getApiUser() && $this->getApiPassword()) {
185
+ return true;
186
+ }
187
+
188
+ return false;
189
+ }
190
+
191
+ /**
192
+ * Write log
193
+ *
194
+ * @param string|array|object $log log
195
+ * @return void
196
+ */
197
+ public function getLogger($log)
198
+ {
199
+ Mage::log($log, null, $this->_logfile, true);
200
+ }
201
+
202
+ /**
203
+ * Checks whether debug mode is enabled
204
+ *
205
+ * @param integer|string|Mage_Core_Model_Store $store store
206
+ * @return boolean
207
+ */
208
+ public function getDebugMode($store = null)
209
+ {
210
+ return Mage::getStoreConfigFlag(self::XML_PATH_DEBUG, $store);
211
+ }
212
+
213
+ /**
214
+ * Get API username
215
+ *
216
+ * @param integer|string|Mage_Core_Model_Store $store store
217
+ * @return boolean
218
+ */
219
+ public function getApiUser($store = null)
220
+ {
221
+ $apiUser = Mage::getStoreConfig(self::XML_PATH_API_USER, $store);
222
+ if ($apiUser) {
223
+ return $apiUser;
224
+ }
225
+
226
+ return false;
227
+ }
228
+
229
+ /**
230
+ * Get API password
231
+ *
232
+ * @param integer|string|Mage_Core_Model_Store $store store
233
+ * @return boolean
234
+ */
235
+ public function getApiPassword($store = null)
236
+ {
237
+ $apiPassword = Mage::getStoreConfig(self::XML_PATH_API_PASSWORD, $store);
238
+ if ($apiPassword) {
239
+ return $apiPassword;
240
+ }
241
+
242
+ return false;
243
+ }
244
+
245
+ /**
246
+ * Get catalog export file path
247
+ *
248
+ * @param integer|string|Mage_Core_Model_Store $store store
249
+ * @return string
250
+ */
251
+ public function getExportFilePath($store = null)
252
+ {
253
+ return Mage::getStoreConfig(self::XML_PATH_EXPORT_PATH, $store);
254
+ }
255
+
256
+ /**
257
+ * Get additional catalog attributes for export
258
+ *
259
+ * @param integer|string|Mage_Core_Model_Store $store store
260
+ * @return array|boolean
261
+ */
262
+ public function getAdditionalCatalogAttributes($store = null)
263
+ {
264
+ $additionalAttributes = Mage::getStoreConfig(self::XML_PATH_EXPORT_CATALOG_ADDITIONAL, $store);
265
+ if (!empty($additionalAttributes)) {
266
+ return explode(',', $additionalAttributes);
267
+ } else {
268
+ return false;
269
+ }
270
+ }
271
+
272
+ /**
273
+ * Get additional catalog attributes for export
274
+ *
275
+ * @param integer|string|Mage_Core_Model_Store $store store
276
+ * @return array|boolean
277
+ */
278
+ public function getAdditionalCustomerAttributes($store = null)
279
+ {
280
+ $additionalAttributes = Mage::getStoreConfig(self::XML_PATH_EXPORT_CUSTOMER_ADDITIONAL, $store);
281
+ if (!empty($additionalAttributes)) {
282
+ return explode(',', $additionalAttributes);
283
+ } else {
284
+ return false;
285
+ }
286
+ }
287
+
288
+ /**
289
+ * Get catalog export all products
290
+ *
291
+ * @param integer|string|Mage_Core_Model_Store $store store
292
+ * @return bool
293
+ */
294
+ public function getCatalogExportAll($store = null)
295
+ {
296
+ return Mage::getStoreConfigFlag(self::XML_CATALOG_EXPORT_ALL_PATH, $store);
297
+ }
298
+
299
+ /**
300
+ * Get catalog export max size
301
+ *
302
+ * @param integer|string|Mage_Core_Model_Store $store store
303
+ * @return bool
304
+ */
305
+ public function getCatalogMaxLimit($store = null)
306
+ {
307
+ return Mage::getStoreConfig(self::XML_CATALOG_EXPORT_MAX_PATH, $store);
308
+ }
309
+
310
+ /**
311
+ * Get customer export all
312
+ *
313
+ * @param integer|string|Mage_Core_Model_Store $store store
314
+ * @return bool
315
+ */
316
+ public function getCustomerExportAll($store = null)
317
+ {
318
+ return Mage::getStoreConfigFlag(self::XML_CUSTOMER_EXPORT_ALL_PATH, $store);
319
+ }
320
+
321
+ /**
322
+ * Get customer export max size
323
+ *
324
+ * @param integer|string|Mage_Core_Model_Store $store store
325
+ * @return bool
326
+ */
327
+ public function getCustomerMaxLimit($store = null)
328
+ {
329
+ return Mage::getStoreConfig(self::XML_CUSTOMER_EXPORT_MAX_PATH, $store);
330
+ }
331
+
332
+ /**
333
+ * Get catalog export only salable products
334
+ *
335
+ * @param integer|string|Mage_Core_Model_Store $store store
336
+ * @return bool
337
+ */
338
+ public function getOnlySalable($store = null)
339
+ {
340
+ return Mage::getStoreConfigFlag(self::XML_PATH_EXPORT_ONLY_SALABLE, $store);
341
+ }
342
+
343
+ /**
344
+ * Get boxes use Gravity template
345
+ *
346
+ * @param integer|string|Mage_Core_Model_Store $store store
347
+ * @return bool
348
+ */
349
+ public function useGravityTemplate($store = null)
350
+ {
351
+ return Mage::getStoreConfigFlag(self::XML_PATH_USE_TEMPLATE, $store);
352
+ }
353
+
354
+ /**
355
+ * Get customer update synchronisation enabled
356
+ *
357
+ * @param integer|string|Mage_Core_Model_Store $store store
358
+ * @return bool
359
+ */
360
+ public function getCustomerUpdateEnabled($store = null)
361
+ {
362
+ return Mage::getStoreConfigFlag(self::XML_PATH_CUSTOMER_UPDATE, $store);
363
+ }
364
+
365
+ /**
366
+ * Get customer registration synchronisation enabled
367
+ *
368
+ * @param integer|string|Mage_Core_Model_Store $store store
369
+ * @return bool
370
+ */
371
+ public function getCustomerRegisterEnabled($store = null)
372
+ {
373
+ return Mage::getStoreConfigFlag(self::XML_PATH_CUSTOMER_REGISTER, $store);
374
+ }
375
+
376
+
377
+ /**
378
+ * Get product update synchronisation enabled
379
+ *
380
+ * @param integer|string|Mage_Core_Model_Store $store store
381
+ * @return string
382
+ */
383
+ public function getProductUpdateEnabled($store = null)
384
+ {
385
+ return Mage::getStoreConfigFlag(self::XML_PATH_PRODUCT_UPDATE, $store);
386
+ }
387
+
388
+ /**
389
+ * Get enabled pages in general layout
390
+ *
391
+ * @param integer|string|Mage_Core_Model_Store $store store
392
+ * @return bool
393
+ */
394
+ public function getEnabledPages($store = null)
395
+ {
396
+ return Mage::getStoreConfig(self::XML_PATH_ENABLED_PAGES, $store);
397
+ }
398
+ }
app/code/community/Me/Gravity/Model/Client/GravityClient.php ADDED
@@ -0,0 +1,951 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The GravityClient and related classes are used to connect to and communicate with the
4
+ * Gravity recommendation engine.
5
+ *
6
+ * @package GravityClient
7
+ * @author Péter Ritzinger
8
+ */
9
+
10
+ /**
11
+ * The GravityClient class can be used to send events, item and user information to
12
+ * the recommendation engine and get recommendations.
13
+ *
14
+ * Example usage:
15
+ *
16
+ * <pre>
17
+ * function createGravityClient() {
18
+ * $config = new GravityClientConfig();
19
+ * $config->remoteUrl = 'https://saas.gravityrd.com/grrec-CustomerID-war/WebshopServlet';
20
+ * $config->user = 'sampleUser';
21
+ * $config->password = 'samplePasswd';
22
+ * $config->retry = 3
23
+ * return new GravityClient($config);
24
+ * }
25
+ * $client = createGravityClient();
26
+ * $context = new GravityRecommendationContext();
27
+ * $context->numberLimit = 5;
28
+ * $context->scenarioId = 'HOMEPAGE_MAIN';
29
+ * $client->getItemRecommendation('user1', '123456789abcdef', $context);
30
+ * </pre>
31
+ *
32
+ * Please do not modify the GravityClient.php file (e.g. do not write your configuration parameters into the GravityClient.php file).
33
+ * Using an unmodified client makes version updates easier.
34
+ * Use your own factory function (like createGravityClient in the example above) to pass your configuration information to the GravityClient constructor.
35
+ *
36
+ */
37
+
38
+ class GravityClient {
39
+
40
+ /**
41
+ * The version info of the client.
42
+ */
43
+ private $version = '1.0.9';
44
+
45
+ /**
46
+ * Creates a new client instance with the specified configuration
47
+ * @param GravityClientConfig <var>$config</var> The configuration
48
+ */
49
+ public function __construct(GravityClientConfig $config) {
50
+ if ($config->timeoutSeconds <= 0) {
51
+ throw new GravityException(
52
+ 'Invalid configuration. Timeout must be a positive integer.',
53
+ new GravityFaultInfo(GRAVITY_ERRORCODE_CONFIG_ERROR));
54
+ }
55
+ if (!$config->remoteUrl) {
56
+ throw new GravityException(
57
+ 'Invalid configuration. Remote URL must be specified.',
58
+ new GravityFaultInfo(GRAVITY_ERRORCODE_CONFIG_ERROR));
59
+ }
60
+ $this->config = $config;
61
+ }
62
+
63
+ /**
64
+ * Adds an event to the recommendation engine.
65
+ *
66
+ * @param GravityEvent <var>$event</var> The event to add.
67
+ * @param boolean <var>$async</var> true if the call is asynchronous. An asynchronous call
68
+ * returns immediately after an input data checking,
69
+ * a synchronous call returns only after the data is saved to database.
70
+ */
71
+ public function addEvent(GravityEvent $event, $async) {
72
+ $this->addEvents(array($event), $async);
73
+ }
74
+
75
+ /**
76
+ * Adds multiple events to the recommendation engine.
77
+ *
78
+ * @param GravityEvent[] <var>$events</var> The events to add.
79
+ * @param boolean <var>$async</var> true if the call is asynchronous. An asynchronous call
80
+ * returns immediately after an input data checking,
81
+ * a synchronous call returns only after the data is saved to database.
82
+ */
83
+ public function addEvents(array $events, $async) {
84
+ $this->sendRequest('addEvents', array('async' => $async), $events, false);
85
+ }
86
+
87
+ /**
88
+ * Adds an item to the recommendation engine.
89
+ * If the item already exists with the specified itemId,
90
+ * the entire item along with its NameValue pairs will be replaced to the new item specified here.
91
+ *
92
+ * @param GravityItem <var>$item</var> The item to add
93
+ * @param boolean <var>$async</var> true if the call is asynchronous. An asynchronous call
94
+ * returns immediately after an input data checking,
95
+ * a synchronous call returns only after the data is saved to database.
96
+ */
97
+ public function addItem(GravityItem $item, $async) {
98
+ $this->addItems(array($item), $async);
99
+ }
100
+
101
+ /**
102
+ * Adds items to the recommendation engine.
103
+ * If an item already exists with the specified itemId,
104
+ * the entire item along with its NameValue pairs will be replaced to the new item specified here.
105
+ *
106
+ * @param GravityItem[] <var>$items</var> The items to add
107
+ * @param boolean <var>$async</var> true if the call is asynchronous. An asynchronous call
108
+ * returns immediately after an input data checking,
109
+ * a synchronous call returns only after the data is saved to database.
110
+ */
111
+ public function addItems(array $items, $async) {
112
+ $this->sendRequest('addItems', array('async' => $async), $items, false);
113
+ }
114
+
115
+ /**
116
+ * Existing item will be updated. If item does not exist Exception will be thrown.
117
+ * Update rules:
118
+ * - Key-value pairs won't be deleted only existing ones updated or new ones added. But If a key occurs in the key
119
+ * value list, then all values with the given key will be deleted and new values added in the recengine.
120
+ * - Hidden field has to be always specified!
121
+ *
122
+ * @param GravityItem $item The item to update
123
+ */
124
+ public function updateItem(GravityItem $item) {
125
+ $this->updateItems(array($item));
126
+ }
127
+
128
+ /**
129
+ * Existing items will be updated. If item does not exist Exception will be thrown.
130
+ * Update rules:
131
+ * - Key-value pairs won't be deleted only existing ones updated or new ones added. But If a key occurs in the key
132
+ * value list, then all values with the given key will be deleted and new values added in the recengine.
133
+ * - Hidden field has to be always specified!
134
+ *
135
+ * @param GravityItem[] $items The items to update
136
+ */
137
+ public function updateItems(array $items) {
138
+ $this->sendRequest('updateItems', NULL, $items, false);
139
+ }
140
+
141
+
142
+ /**
143
+ * Adds user to the recommendation engine.
144
+ * If the user already exists with the specified userId,
145
+ * the entire user will be replaced with the new user specified here.
146
+ *
147
+ * @param GravityUser <var>$user</var> The user to add.
148
+ * @param boolean <var>$async</var> true if the call is asynchronous. An asynchronous call
149
+ * returns immediately after an input data checking,
150
+ * a synchronous call returns only after the data is saved to database.
151
+ */
152
+ public function addUser(GravityUser $user, $async) {
153
+ $this->addUsers(array($user), $async);
154
+ }
155
+
156
+ /**
157
+ * Adds users to the recommendation engine. The existing users will be updated.
158
+ * If a user already exists with the specified userId,
159
+ * the entire user will be replaced with the new user specified here.
160
+ *
161
+ * @param GravityUser[] <var>$users</var> The users to add.
162
+ * @param boolean <var>$async</var> true if the call is asynchronous. An asynchronous call
163
+ * returns immediately after an input data checking,
164
+ * a synchronous call returns only after the data is saved to database.
165
+ */
166
+ public function addUsers(array $users, $async) {
167
+ $this->sendRequest('addUsers', array('async' => $async), $users, false);
168
+ }
169
+
170
+ /**
171
+ * Returns a list of recommended items, based on the given context parameters.
172
+ *
173
+ * @param string <var>$userId</var> The identifier of the logged in user. If no user is logged in, null should be specified.
174
+ * @param string <var>$cookieId</var> It should be a permanent identifier for the end users computer, preserving its value across browser sessions.
175
+ * It should be always specified.
176
+ * @param GravityRecommendationContext <var>$context</var>
177
+ * Additional information which describes the actual scenario.
178
+ * @return GravityItemRecommendation
179
+ * An object containing the recommended items and other information about the recommendation.
180
+ */
181
+ public function getItemRecommendation($userId, $cookieId, GravityRecommendationContext $context) {
182
+ return $this->sendRequest(
183
+ 'getItemRecommendation',
184
+ array(
185
+ 'userId' => $userId,
186
+ 'cookieId' => $cookieId,
187
+ ),
188
+ $context,
189
+ true
190
+ );
191
+ }
192
+
193
+ /**
194
+ * Simple test function to test without side effects whether the service is alive.
195
+ * @return string "Hello " + <code>$name</code>
196
+ */
197
+ public function test($name) {
198
+ return $this->sendRequest('test', array('name' => $name), $name, true);
199
+ }
200
+
201
+ /**
202
+ * Simple test function to test throwing an exception.
203
+ */
204
+ public function testException() {
205
+ $this->sendRequest('testException', null, null, true);
206
+ }
207
+
208
+ private function getRequestQueryString($methodName, $queryStringParams) {
209
+ $queryString = $queryStringParams ? http_build_query($queryStringParams, null, '&') : '';
210
+ if ($queryString) {
211
+ $queryString = "&" . $queryString;
212
+ }
213
+ return "?method=" . urlencode($methodName) . $queryString;
214
+ }
215
+
216
+ private function sendRequest($methodName, $queryStringParams, $requestBody, $hasAnswer) {
217
+ // get the # of retries
218
+ $retry = 0;
219
+ if(isset($this->config->retry) && is_int($this->config->retry)) {
220
+ $retry = $this->config->retry;
221
+ }
222
+
223
+ $ch = curl_init();
224
+ curl_setopt($ch, CURLOPT_URL, $this->config->remoteUrl . "/" . $methodName . $this->getRequestQueryString($methodName, $queryStringParams));
225
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array("X-Gravity-RecEng-ClientVersion: $this->version",'Expect:')); // disable Expect: 100-Continue, it would be an unnecessary roundtrip
226
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
227
+
228
+ if (is_int($this->config->timeoutSeconds)) {
229
+ curl_setopt($ch, CURLOPT_TIMEOUT, $this->config->timeoutSeconds);
230
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $this->config->timeoutSeconds);
231
+ }
232
+ else {
233
+ curl_setopt($ch, CURLOPT_TIMEOUT_MS, $this->config->timeoutSeconds*1000);
234
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->config->timeoutSeconds*1000);
235
+ }
236
+
237
+ if (strpos($this->config->remoteUrl, 'https') === 0) {
238
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->config->verifyPeer);
239
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
240
+ }
241
+
242
+ if ($this->config->user) {
243
+ curl_setopt($ch, CURLOPT_USERPWD, $this->config->user . ':' . $this->config->password);
244
+ }
245
+
246
+ if ($requestBody) {
247
+ curl_setopt($ch, CURLOPT_POST, true);
248
+ curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($requestBody));
249
+ }
250
+
251
+ $result = curl_exec($ch);
252
+
253
+ $retryEnabled = in_array($methodName, array("addUsers", "addItems"));
254
+
255
+ if($retryEnabled && curl_errno($ch) == 28){
256
+ while($retry > 0 && curl_errno($ch) == 28){
257
+ curl_exec($ch);
258
+ $retry--;
259
+ }
260
+ }
261
+
262
+ $rc = $this->handleError($ch, $result);
263
+ if (is_resource($ch)) {
264
+ curl_close($ch);
265
+ }
266
+ if ($hasAnswer) {
267
+ return json_decode($result, false);
268
+ } else {
269
+ return null;
270
+ }
271
+ }
272
+
273
+ private function handleError($ch, $result) {
274
+ $errorNumber = curl_errno($ch);
275
+ if ($errorNumber != 0) {
276
+ $errorMessage = curl_error($ch);
277
+ curl_close($ch);
278
+ switch ($errorNumber) {
279
+ case 6: //CURLE_COULDNT_RESOLVE_HOST
280
+ throw new GravityException(
281
+ "Could not resolve host error during curl_exec(): $errorMessage",
282
+ new GravityFaultInfo(GRAVITY_ERRORCODE_COMM_HOSTRESOLVE));
283
+ case 7: //CURLE_COULDNT_CONNECT
284
+ throw new GravityException(
285
+ "Could not connect to host error during curl_exec(): $errorMessage",
286
+ new GravityFaultInfo(GRAVITY_ERRORCODE_COMM_CONNECT));
287
+ case 28: //CURLE_OPERATION_TIMEDOUT
288
+ throw new GravityException(
289
+ "Timeout error during curl_exec(): $errorMessage",
290
+ new GravityFaultInfo(GRAVITY_ERRORCODE_COMM_TIMEOUT));
291
+ default:
292
+ throw new GravityException(
293
+ "Error during curl_exec(): $errorMessage",
294
+ new GravityFaultInfo(GRAVITY_ERRORCODE_COMM_OTHER));
295
+ }
296
+ } else {
297
+ $responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
298
+ if ($responseCode != 200) {
299
+ $e = json_decode($result, false);
300
+ $supplement = "";
301
+ if (is_object($e)) {
302
+ $supplement = ", Message: $e->message";
303
+ }
304
+ throw new GravityException(
305
+ "Non-200 HTTP response code: $responseCode $supplement",
306
+ new GravityFaultInfo(GRAVITY_ERRORCODE_COMM_HTTPERRORCODE));
307
+ }
308
+ return $responseCode;
309
+ }
310
+ }
311
+
312
+ /**
313
+ * The client configuration.
314
+ *
315
+ * @var GravityClientConfig
316
+ */
317
+ private $config;
318
+ }
319
+
320
+
321
+ /**
322
+ * Contains a list of recommended items. This class is here only to describe the result,
323
+ * the actual result will not be an instance of this class because of json deserialization.
324
+ */
325
+ class GravityItemRecommendation {
326
+ function __construct() {
327
+ }
328
+
329
+ /**
330
+ *
331
+ * Array containing the recommended items.
332
+ * This is populated only if the scenario specifies to do so, otherwise this is null.
333
+ * itemIds is always populated.
334
+ * The items in this list only have the NameValues specified by the scenario.
335
+ * The list of NameValues specified by the scenario can be overridden by the
336
+ * GravityRecommendationContext resultNameValues on a per request basis.
337
+ *
338
+ * @var GravityItem[]
339
+ */
340
+ public $items;
341
+
342
+ /**
343
+ *
344
+ * The identifiers of the recommended items. Only if not a NameValue recommendation.
345
+ *
346
+ * @var int
347
+ */
348
+ public $itemIds;
349
+
350
+ /**
351
+ *
352
+ * The unique identifier of the recommendation generated by the recommendation engine.
353
+ * Strings in the PHP client are always UTF-8 encoded.
354
+ *
355
+ * @var string
356
+ */
357
+ public $recommendationId;
358
+
359
+ /**
360
+ * Array containing additional name-value pairs for recommendations.
361
+ * e.g.: AllItemCount for paging responses.
362
+ *
363
+ * @var GravityNameValue[]
364
+ */
365
+ public $outputNameValues;
366
+ }
367
+
368
+ /**
369
+ * Describes an event for the recommendation engine, for example a user viewed an item.
370
+ */
371
+ class GravityEvent {
372
+ function __construct() {
373
+ $this->time = time();
374
+ $this->nameValues = array();
375
+ }
376
+
377
+ /**
378
+ *
379
+ * The event type determines the namevalues which can be passed.
380
+ * <p>Possible list event types, which can be expanded based on what can the external system support:</p>
381
+ * <table border="1">
382
+ * <tr><th><code>Event Type</code><th>Category</th></th><th>Description</th><th>NameValues for the event</th></tr>
383
+ * <tr><td><code>VIEW</code></td><td>GENERAL</td><td>The user viewed the info page of an item.</td><td></td></tr>
384
+ * <tr><td><code>BUY</code></td><td>GENERAL</td><td>The user bought an item.</td><td>
385
+ * <table>
386
+ * <tr><td><code>OrderId</code></td><td></td></tr>
387
+ * <tr><td><code>UnitPrice</code></td><td>Formatted as a decimal number, for example 1234 or 12345.67</td></tr>
388
+ * <tr><td><code>Currency</code></td><td></td></tr>
389
+ * <tr><td><code>Quantity</code></td><td>Formatted as a decimal number.</td></tr>
390
+ * </table>
391
+ * </td></tr>
392
+ * <tr><td><code>RATING</code></td><td>GENERAL</td><td>The user rated an item.</td><td>
393
+ * <table>
394
+ * <tr><td><code>Value</code></td><td>The value of the rating.</td></tr>
395
+ * </table>
396
+ * </td></tr>
397
+ * <tr><td><code>ADD_TO_CART</code></td><td>GENERAL</td><td>The user added an item to the shopping cart.</td><td>
398
+ * <table>
399
+ * <tr><td><code>Quantity</code></td><td></td></tr>
400
+ * </table>
401
+ * </td></tr>
402
+ * <tr><td><code>REMOVE_FROM_CART</code></td><td>GENERAL</td><td>The user removed an item from the shopping cart.</td><td>
403
+ * <table>
404
+ * <tr><td><code>Quantity</code></td><td></td></tr>
405
+ * </table>
406
+ * </td></tr>
407
+ * <tr><td><code>ADD_TO_FAVORITES</code></td><td>GENERAL</td><td>The user added the item to his favorites.</td><td>
408
+ * <table>
409
+ * <tr><td><code>ListId</code></td><td>Use if the webshop supports multiple favorites lists.</td></tr>
410
+ * </table>
411
+ * </td></tr>
412
+ * <tr><td><code>REMOVE_FROM_FAVORITES</code></td><td>GENERAL</td><td>The user removed an item from his favorites.</td><td>
413
+ * <table>
414
+ * <tr><td><code>ListId</code></td><td>Use if the webshop supports multiple favorites lists.</td></tr>
415
+ * </table>
416
+ * </td></tr>
417
+ * <tr><td><code>REC_CLICK</code></td><td>GENERAL</td><td>The user clicked on a recommended item.</td><td>
418
+ * <table>
419
+ * <tr><td><code>Position</code></td><td>The position of the clicked item in the recommendation list. The position of the first item is 1.</td></tr>
420
+ * </table>
421
+ * </td></tr>
422
+ * <tr><td><code>LOGIN</code></td><td>GENERAL</td><td>The user logged in to the site. For this event the cookieId and also the userId must be specified.</td><td></td></tr>
423
+ * <tr><td><code>ADD_TO_WISHLIST</code></td><td>ADDITIONAL</td><td>The user added the item to his wishlist.</td><td>
424
+ * <table>
425
+ * <tr><td><code>ListId</code></td><td>Use if the webshop supports multiple wishlists.</td></tr>
426
+ * </table>
427
+ * </td></tr>
428
+ * <tr><td><code>REMOVE_FROM_WISHLIST</code></td><td>ADDITIONAL</td><td>The user removed an item from his wishlist.</td><td>
429
+ * <table>
430
+ * <tr><td><code>ListId</code></td><td>Use if the webshop supports multiple wishlists.</td></tr>
431
+ * </table>
432
+ * </td></tr>
433
+ * <tr><td><code>HIDE_PRODUCT</code></td><td>ADDITIONAL</td><td>The user hides a product that should not be recommended to him.</td><td></td></tr>
434
+ * <tr><td><code>UNHIDE_PRODUCT</code></td><td>ADDITIONAL</td><td>The user unhides a product that he marked as hidden previously.</td><td></td></tr>
435
+ * <tr><td><code>PRODUCT_SEARCH</code></td><td>ADDITIONAL</td><td>A list of products was displayed to the user, for example by browsing a category or by free text search.</td><td>
436
+ * <table>
437
+ * <tr><td><code>SearchString</code></td><td>The search string, if the list is based on a free text search.</td></tr>
438
+ * <tr><td><code>Filter.*</code></td><td>If the listing is based on comparing an item namevalue to a filter value, you can provide the actual filter here.
439
+ * For example, if the user was browsing a specific category, name='Filter.CategoryId' and value='CategoryA' can be specified.</td></tr>
440
+ * </table>
441
+ * </td></tr>
442
+ * <tr><td><code>NEXT_RECOMMENDATION</code></td><td>ADDITIONAL</td><td>The user asked for more recommendation.</td><td></td></tr>
443
+ * <tr><td><code>COMMENT</code></td><td>ADDITIONAL</td><td>The user wrote a comment for the item.</td><td></td></tr>
444
+ * <tr><td><code>NOT_INTERESTED</code></td><td>ADDITIONAL</td><td>The user would not like this item and similar items to be recommended to him, but he also does not want to give a negative rating for this item.</td><td></td></tr>
445
+ * <tr><td><code>LETTER_READ</code></td><td>ADDITIONAL</td><td>T The user read a letter which sent for him by the system (eg. a newsletter).</td><td></td></tr>
446
+ * <tr><td><code>CLICK_OUT</code></td><td>PRICE COMPARISON</td><td>The user jumps to an external webshop to buy the product. Used by price comparison sites.</td><td></td></tr>
447
+ * <tr><td><code>LANCE</code></td><td>AUCTION</td><td>The user place a bid on the item.</td><td><code>Value</code>The value of the bid as a decimal number.</td></tr>
448
+ * <tr><td><code>LETTER_SEND</code></td><td>AUCTION, ADVERTISING</td><td>The user sent a message to the advertiser.</td><td></td></tr>
449
+ * <tr><td><code>ADD_ITEM</code></td><td>AUCTION, ADVERTISING</td><td>The user added an item to the site.</td><td></td></tr>
450
+ * <tr><td><code>FREE_VIEW</code></td><td>MEDIA</td><td>The user wached/listened an item for free.</td><td><code>Duration</code>How long the user wached the item in seconds as a decimal number.</td></tr>
451
+ * <tr><td><code>PAID_VIEW</code></td><td>MEDIA</td><td>The user payed for waching/listening an item.</td><td>
452
+ * <table>
453
+ * <tr><td><code>Duration</code></td><td>How long the user wached the item in seconds. A decimal number.</td></tr>
454
+ * <tr><td><code>Value</code></td><td>How much the user payed for waching the item. A decimal number.</td></tr>
455
+ * </table>
456
+ * </td></tr>
457
+ * <tr><td><code>SUBSCRIPTION_VIEW</code></td><td>MEDIA</td><td>The user watched an item that was available for him by a subscription.</td><td>
458
+ * <table>
459
+ * <tr><td><code>Duration</code></td><td>How long the user wached the item in seconds. A decimal number.</td></tr>
460
+ * </table>
461
+ * </td></tr>
462
+ * <tr><td><code>FOLLOW_USER</code></td><td>SOCIAL</td><td>The user follows an other user.</td><td><code>OtherUserId</code>The identifier of the followed user.</td></tr>
463
+ * <tr><td><code>SHARE</code></td><td>SOCIAL</td><td>The user share the item on a social site (eg. Facebook, Twitter,...).</td><td></td></tr>
464
+ * <tr><td><code>REDEEM</code></td><td>COUPON</td><td>The user redeem the item (eg. a coupon).</td><td></td></tr>
465
+ * </table>
466
+ *
467
+ * @var string
468
+ */
469
+ public $eventType;
470
+
471
+ /**
472
+ *
473
+ * This is the identifier of the item which was viewed/bought/etc. by the user.
474
+ * Set to null if it does no make sense, for example in case of a login event.
475
+ * Strings in the PHP client are always UTF-8 encoded.
476
+ *
477
+ * @var string
478
+ */
479
+ public $itemId;
480
+
481
+ /**
482
+ *
483
+ * It should be an id of a previous recommendation, if this event is a consequence of a recommendation.
484
+ * Strings in the PHP client are always UTF-8 encoded.
485
+ *
486
+ * @var string
487
+ */
488
+ public $recommendationId;
489
+
490
+ /**
491
+ *
492
+ * The UNIX timestamp of the event, as returned by the standard time() PHP function.
493
+ *
494
+ * @var int
495
+ */
496
+ public $time;
497
+
498
+ /**
499
+ *
500
+ * This is the identifier of the user who generated the event.
501
+ * If unknown set to null (for example if the user is not logged in yet).
502
+ * Strings in the PHP client are always UTF-8 encoded.
503
+ *
504
+ * @var string
505
+ */
506
+ public $userId;
507
+
508
+ /**
509
+ *
510
+ * A cookieId should be a permanent identifier for the end users computer, preserving its value across browser sessions.
511
+ * This way not logged in users can be recognized, if they have logged in previously from the same computer.
512
+ * The cookieId should be always specified.
513
+ * Strings in the PHP client are always UTF-8 encoded.
514
+ *
515
+ * @var string
516
+ */
517
+ public $cookieId;
518
+
519
+ /**
520
+ *
521
+ * The NameValues for the event. The possible list of namevalues depends on the event type.
522
+ * NameValues provide additional description of the event.
523
+ * There can multiple NameValues with the same name.
524
+ * The order of NameValues will not be preserved, but the order of the values for the same name will be preserved.
525
+ *
526
+ * @var GravityNameValue[]
527
+ */
528
+ public $nameValues;
529
+ }
530
+
531
+ /**
532
+ * A user in the recommendation system. A user is an entity which generates event, and can get recommendations.
533
+ */
534
+ class GravityUser {
535
+ function __construct() {
536
+ $this->nameValues = array();
537
+ }
538
+
539
+ /**
540
+ *
541
+ * This is a unqiue identifier for a registered user.
542
+ * Strings in the PHP client are always UTF-8 encoded.
543
+ *
544
+ * @var string
545
+ */
546
+ public $userId;
547
+
548
+ /**
549
+ *
550
+ * NameValues provide additional description of the user.
551
+ * There can multiple NameValues with the same name.
552
+ * The order of NameValues will not be preserved.
553
+ *
554
+ * The recommendation engine in most cases does not require detailed information about the users, usually only some basic information can be used to enhance the quality of recommendation.
555
+ * For example:
556
+ * <table border="1">
557
+ * <tr><th>Name</th><th>Description</th></tr>
558
+ * <tr><td>ZipCode</td><td>The zip code of the user.</td></tr>
559
+ * <tr><td>City</td><td>The city of the user.</td></tr>
560
+ * <tr><td>Country</td><td>The country of the user.</td></tr>
561
+ * </table>
562
+ *
563
+ * @var GravityNameValue[]
564
+ */
565
+ public $nameValues;
566
+
567
+ /**
568
+ *
569
+ * True if the user is hidden. A no more existing user should be set to hidden.
570
+ *
571
+ * @var boolean
572
+ */
573
+ public $hidden;
574
+ }
575
+
576
+ /**
577
+ * An item is something that can be recommended to users.
578
+ */
579
+ class GravityItem {
580
+ function __construct() {
581
+ $this->fromDate = 0;
582
+ $this->toDate = 2147483647;
583
+ $this->nameValues = array();
584
+ }
585
+
586
+ /**
587
+ *
588
+ * The itemId is a unique identifier of the item.
589
+ * Strings in the PHP client are always UTF-8 encoded.
590
+ *
591
+ * @var string
592
+ */
593
+ public $itemId;
594
+
595
+ /**
596
+ * The item title. This is a short, human-readable name of the item.
597
+ * If the title is available in multiple languages, try to use your system's primary language, for example English.
598
+ * Strings in the PHP client are always UTF-8 encoded.
599
+ *
600
+ * @var string
601
+ */
602
+ public $title;
603
+
604
+ /**
605
+ *
606
+ * The type of the item. It can be used to create different item families.
607
+ * The purpose of itemtype is to differentiate items which will have different namevalue properties.
608
+ * Examples:
609
+ * <ul>
610
+ * <li>Book</li>
611
+ * <li>Ticket</li>
612
+ * <li>Computer</li>
613
+ * <li>Food</li>
614
+ * </ul>
615
+ *
616
+ * @var string
617
+ */
618
+ public $itemType;
619
+
620
+ /**
621
+ * The value of hidden. A hidden item will be never recommended.
622
+ *
623
+ * @var boolean
624
+ */
625
+ public $hidden;
626
+
627
+ /**
628
+ *
629
+ * An item is never recommended before this date.
630
+ * The date in unixtime format, the number of seconds elapsed since 1970.01.01 00:00:00 UTC, as returned by the standard time() PHP function.
631
+ * Set it to 0 if not important.
632
+ *
633
+ * @var int
634
+ */
635
+ public $fromDate;
636
+
637
+ /**
638
+ *
639
+ * An item is never recommended after this date.
640
+ * The date in unixtime format, the number of seconds elapsed since 1970.01.01 00:00:00 UTC, as returned by the standard time() PHP function.
641
+ * Set it to a big number (eg. 2147483647) if not important.
642
+ *
643
+ * @var int
644
+ */
645
+ public $toDate;
646
+
647
+
648
+ /**
649
+ *
650
+ * The NameValues for the item.
651
+ * <p>NameValues provide additional description of the item.</p>
652
+ * <p>There can multiple NameValues with the same name.</p>
653
+ * <p>The order of NameValues among different names will not be preserved, but the order of the values for the same name will be preserved.</p>
654
+ * <p>The recommendation engine can be configured to use some properties to create a relation between items.</p>
655
+ * <p>A possible list of names:</p>
656
+ * <table border="1">
657
+ * <tr><th>Name</th><th>Localizable</th><th>Description</th></tr>
658
+ * <tr><td>Title</td><td>Yes</td><td>The title of the item.</td></tr>
659
+ * <tr><td>Description</td><td>Yes</td><td>The description of item.</td></tr>
660
+ * <tr><td>CategoryPath</td><td>No</td><td>The full path of the item's category.
661
+ * For example, CategoryPath might be "books/computers/databases" for a book about databases.
662
+ * CategoryPath can be repeated if an item belongs to multiple categories. Use "/" only for separating levels.
663
+ * Later it is possible to use the recommendation engine to filter the list of items based on category, so it can provide recommendations for "Computer Books" category or only for "Computer Books &gt; Database" category.
664
+ * </td></tr>
665
+ * <tr><td>Tags</td><td>No</td><td>Tags for the item. Specify a separate namevalue for each tag.</td></tr>
666
+ * <tr><td>State</td><td>No</td><td>The state of the item, for example 'available', 'out of stock' etc.</td></tr>
667
+ * <tr><td>Price</td><td>No</td><td>The price of the item.</td></tr>
668
+ * </table>
669
+ *
670
+ * The recommendation engine can accept arbitrary namevalues, the list above is just an example of basic properties that are used almost everywhere.
671
+ * The NameValues which are relevant to business rules and possible content based filtering should be provided to the recommendation engine.
672
+ *
673
+ * <p>You can use localization by appending a language identifier to the Name of the NameValue. For example, Title_EN, Title_HU.
674
+ * It is possible to use both non-localized and localized version.
675
+ * </p>
676
+ *
677
+ * @var GravityNameValue[]
678
+ */
679
+ public $nameValues;
680
+
681
+ }
682
+
683
+ /**
684
+ * Contains information for a recommendation request.
685
+ */
686
+ class GravityRecommendationContext {
687
+ function __construct() {
688
+ $this->recommendationTime = time();
689
+ }
690
+
691
+ /**
692
+ *
693
+ * The time of the recommendation (seconds in unixtime format), the time when it will be shown to the end user.
694
+ * Use a value as returned by the standard time() PHP function.
695
+ *
696
+ * @var int
697
+ */
698
+ public $recommendationTime;
699
+
700
+ /**
701
+ *
702
+ * The value of the maximum number of items in the result.
703
+ * The maximum number of the items in the result can be also limited by the configuration of the scenario.
704
+ * If set to 0, this number of items is determined by the scenario.
705
+ *
706
+ * @var int
707
+ */
708
+ public $numberLimit;
709
+
710
+ /**
711
+ *
712
+ * The value of scenarioId. Scenarios are defined by the scenario management API.
713
+ * A scenario describes a way how recommended items will be filtered, ordered.
714
+ *
715
+ * @var string
716
+ */
717
+ public $scenarioId;
718
+
719
+ /**
720
+ *
721
+ * The NameValues for the context.
722
+ * NameValues can describe the parameters for the actual scenario, like current item id, filtering by category etc.
723
+ * Item-to-item recommendation is possible by a specific scenario which parses a NameValue describing the current item,
724
+ * or multiple NameValues if there are multiple actual items.
725
+ * The list of allowed names depends on the actual scenario.
726
+ * <p>The scenario can also specify that the result is not a list of items, but a list of values of item NameValues.</p>
727
+
728
+ * <table border="1">
729
+ * <tr><th>Name</th><th>Description</th></tr>
730
+ * <tr><td>CurrentItemId</td><td>The identifier of the actual item, if the current page is an item page.</td></tr>
731
+ * <tr><td>ItemOnPage</td><td>Identifier of item displayed elsewhere on the page. They will be excluded from recommendation. This namevalue can be used multiple times to provide a list of items.</td></tr>
732
+ * <tr><td>CartItemId</td><td>Identifier of item in the current shopping cart. This can provide additional information to improve the quality of recommendation. This namevalue must be used as many times as many items the shopping cart contains.</td></tr>
733
+ * <tr><td>CartItemQuantity</td><td>The quantity of items in the current shopping cart, in the same order as CartItemId namevalues.</td></tr>
734
+ * <tr><td>Filter.*</td><td>If specified, only items having the specified name and value as metadata will be in the result.
735
+ * For example, the namevalue with name='Filter'.'CategoryId' and value='A' means that only items belonging to category 'A' will be in the result.</td></tr>
736
+ *
737
+ * </table>
738
+ *
739
+ * @var GravityNameValue[]
740
+ */
741
+ public $nameValues;
742
+
743
+ /**
744
+ * If not null, specifies which NameValues of the recommended items should be included in the result.
745
+ * If null, the returned NameValues are determined by the actual scenario.
746
+ *
747
+ * @var GravityNameValue[]
748
+ */
749
+ public $resultNameValues;
750
+
751
+ }
752
+
753
+
754
+ /**
755
+ * A name and a value. This can be used to provide information about items, users and events.
756
+ */
757
+ class GravityNameValue {
758
+ /**
759
+ *
760
+ * The name.
761
+ * Strings in the PHP client are always UTF-8 encoded.
762
+ *
763
+ * @var string
764
+ */
765
+ public $name;
766
+
767
+ /**
768
+ *
769
+ * The value.
770
+ * Strings in the PHP client are always UTF-8 encoded.
771
+ *
772
+ * @var string
773
+ */
774
+ public $value;
775
+
776
+ /**
777
+ * Creates a new instance of a namevalue pair.
778
+ * Strings in the PHP client are always UTF-8 encoded.
779
+ *
780
+ * @param string <var>$name</var> The name.
781
+ * @param string <var>$value</var> The value.
782
+ */
783
+ public function __construct($name, $value) {
784
+ $this->name = $name;
785
+ $this->value = $value;
786
+ }
787
+ }
788
+
789
+
790
+
791
+ class GravityClientConfig {
792
+ function __construct() {
793
+ $this->timeoutSeconds = 3;
794
+ $this->verifyPeer = true;
795
+ }
796
+
797
+ /**
798
+ * The URL of the server side interface. It has no default value, must be specified.
799
+ * Strings in the PHP client are always UTF-8 encoded.
800
+ *
801
+ * @var string
802
+ */
803
+ public $remoteUrl;
804
+
805
+ /**
806
+ * The timeout for the operations in seconds. The default value is 3 seconds.
807
+ * Double values are supported after PHP version 5.2.3 (uses miliseconds timeout)
808
+ * @var int
809
+ */
810
+ public $timeoutSeconds;
811
+
812
+ /**
813
+ * The setting of cURL option <code>CURLOPT_SSL_VERIFYPEER</code> in case of https connection.
814
+ * Set it to <code>false</code> if your server could not accept our certificate.
815
+ * The default value is true.
816
+ * Leave it blank in case of http connection.
817
+ *
818
+ * @var boolean
819
+ */
820
+ public $verifyPeer;
821
+
822
+ /**
823
+ *
824
+ * The user name for the http authenticated connection. Leave it blank in case of
825
+ * connection without authentication.
826
+ *
827
+ * @var string
828
+ */
829
+ public $user;
830
+
831
+ /**
832
+ * The password for the http authenticated connection. Leave it blank in case of
833
+ * connection without authentication.
834
+ *
835
+ * @var string
836
+ */
837
+ public $password;
838
+
839
+ }
840
+
841
+ /**
842
+ * The client was initilized with invalid configuration.
843
+ * You should never use the value of the constant, always use it be referencing its name.
844
+ */
845
+ define('GRAVITY_ERRORCODE_CONFIG_ERROR', -1);
846
+
847
+ /**
848
+ * Unknown error during communication.
849
+ * You should never use the value of the constant, always use it be referencing its name.
850
+ */
851
+ define('GRAVITY_ERRORCODE_COMM_OTHER', -2);
852
+
853
+ /**
854
+ * Could not resolve the remote host name.
855
+ * You should never use the value of the constant, always use it be referencing its name.
856
+ */
857
+ define('GRAVITY_ERRORCODE_COMM_HOSTRESOLVE', -3);
858
+
859
+ /**
860
+ * Timeout during communication.
861
+ * You should never use the value of the constant, always use it be referencing its name.
862
+ */
863
+ define('GRAVITY_ERRORCODE_COMM_TIMEOUT', -4);
864
+
865
+ /**
866
+ * Could not connect to remote host.
867
+ * You should never use the value of the constant, always use it be referencing its name.
868
+ */
869
+ define('GRAVITY_ERRORCODE_COMM_CONNECT', -5);
870
+
871
+ /**
872
+ * A non-200 HTTP response code was received.
873
+ * You should never use the value of the constant, always use it be referencing its name.
874
+ */
875
+ define('GRAVITY_ERRORCODE_COMM_HTTPERRORCODE', -6);
876
+
877
+ /**
878
+ * The exception class used by the recommendation engine client in case of an error.
879
+ */
880
+ class GravityException extends Exception {
881
+ /**
882
+ * Creates a new instance of GravityException.
883
+ *
884
+ * @param string <var>$message</var> The error message.
885
+ * @param GravityFaultInfo <var>$faultInfo</var> Contains information about the error.
886
+ *
887
+ */
888
+ public function __construct($message, $faultInfo) {
889
+ parent::__construct($message, $faultInfo->errorCode);
890
+ $this->faultInfo = $faultInfo;
891
+ }
892
+
893
+ /**
894
+ * The object describing the error.
895
+ *
896
+ * @var GravityFaultInfo
897
+ */
898
+ public $faultInfo;
899
+ }
900
+
901
+ /**
902
+ * Describes the error occured during a request.
903
+ */
904
+ class GravityFaultInfo {
905
+ function __construct($errorCode) {
906
+ $this->errorCode = $errorCode;
907
+ }
908
+
909
+ public $errorCode;
910
+ }
911
+
912
+ /**
913
+ * This class used to deserialize exceptions coming from the recommendation engine.
914
+ */
915
+ class GravityRecEngException {
916
+
917
+ public $message;
918
+
919
+ /**
920
+ *
921
+ * Currently defined error codes:
922
+ * <ul>
923
+ * <li>ERR_ITEMS_IS_NULL</li>
924
+ * <li>ERR_ITEMS_HAS_NULL_ELEMENT</li>
925
+ * <li>ERR_ITEMID_IS_NULL_OR_EMPTY</li>
926
+ * <li>ERR_USERS_IS_NULL</li>
927
+ * <li>ERR_USERS_HAS_NULL_ELEMENT</li>
928
+ * <li>ERR_USERID_IS_NULL_OR_EMPTY</li>
929
+ * <li>ERR_RATINGS_IS_NULL</li>
930
+ * <li>ERR_RATINGS_HAS_NULL_ELEMENT</li>
931
+ * <li>ERR_RECOMMENDATIONID_IS_NULL_OR_EMPTY</li>
932
+ * <li>ERR_ITEM_NOT_FOUND</li>
933
+ * <li>ERR_USER_NOT_FOUND</li>
934
+ * <li>ERR_EVENTS_IS_NULL</li>
935
+ * <li>ERR_EVENTS_HAS_NULL_ELEMENT</li>
936
+ * <li>ERR_INVALID_EVENT_TYPE</li>
937
+ * <li>ERR_PARAM_IS_NULL</li>
938
+ * <li>ERR_NAMEVALUE_IS_NULL</li>
939
+ * <li>ERR_NAME_IN_NAMEVALUE_IS_NULL_OR_EMPTY</li>
940
+ * <li>ERR_VALUE_IN_NAMEVALUE_IS_NULL</li>
941
+ * <li>ERR_NAME_IN_NAMEVALUE_IS_NOT_ALLOWED</li>
942
+ * <li>ERR_ITEMID_INVALID_FROMTODATE</li>
943
+ * <li>ERR_INVALID_EVENT_RECOMMENDATIONID</li>
944
+ * <li>ERR_INTERNAL_ERROR</li>
945
+ * <li>ERR_INVALID_METHOD_NAME</li>
946
+ * </ul>
947
+ *
948
+ * @var string
949
+ */
950
+ public $faultInfo;
951
+ }
app/code/community/Me/Gravity/Model/Customers.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Model_Customers
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Model_Customers
15
+ */
16
+ class Me_Gravity_Model_Customers extends Me_Gravity_Model_Export_Customer_Customer
17
+ {
18
+ /**
19
+ * Base export headers
20
+ *
21
+ * @var array
22
+ */
23
+ protected $_headers = array(
24
+ 'userid'
25
+ );
26
+
27
+ /**
28
+ * Generate TSV file
29
+ *
30
+ * @param int $storeId store id
31
+ * @return array|bool
32
+ * @throws Mage_Core_Exception
33
+ */
34
+ public function generateCustomersTsv($storeId = 0)
35
+ {
36
+ $customerCollection = $this->getCustomerCollection($storeId);
37
+
38
+ if ($customerCollection->getSize()) {
39
+
40
+ $io = new Varien_Io_File();
41
+
42
+ $path = Mage::getBaseDir('var') . DS . 'gravity' . DS;
43
+ $name = md5(microtime());
44
+ $file = $path . DS . $name . '.tsv';
45
+
46
+ $io->setAllowCreateFolders(true);
47
+ $io->open(array('path' => $path));
48
+ $io->streamOpen($file, 'w+');
49
+ $io->streamLock(true);
50
+ $io->streamWriteCsv($this->getExportHeaders(), "\t");
51
+
52
+ foreach ($customerCollection as $customer) {
53
+
54
+ $row = array();
55
+ foreach ($this->getExportHeaders() as $attributeCode) {
56
+ if ($attributeCode == $this->_headers[0]) {
57
+ $row[] = $customer->getEntityId();
58
+ } else {
59
+ $row[] = $this->getAttributeValueByCode($customer, $attributeCode);
60
+ }
61
+ }
62
+
63
+ $io->streamWriteCsv($row, "\t");
64
+ }
65
+
66
+ $io->streamUnlock();
67
+ $io->streamClose();
68
+
69
+ return array(
70
+ 'type' => 'filename',
71
+ 'value' => $file,
72
+ 'rm' => true // can delete file after use
73
+ );
74
+
75
+ } else {
76
+
77
+ Mage::throwException($this->_helper->__('Empty customer collection.'));
78
+ return false;
79
+ }
80
+ }
81
+
82
+ /**
83
+ * Get export headers
84
+ *
85
+ * @return array
86
+ */
87
+ public function getExportHeaders()
88
+ {
89
+ $exportAttrCodes = $this->getExportAttrCodes();
90
+
91
+ if (!empty($this->_attributeValues)) {
92
+ $exportAttrCodes = array_merge($exportAttrCodes, array_keys($this->_attributeValues));
93
+ }
94
+
95
+ return array_merge($this->_headers, $exportAttrCodes);
96
+ }
97
+
98
+ /**
99
+ * Get additional customer attributes value
100
+ *
101
+ * @param Mage_Customer_Model_Customer $customer customer
102
+ * @param string $attributeCode attribute code
103
+ * @return string
104
+ */
105
+ public function getAttributeValueByCode(Mage_Customer_Model_Customer $customer, $attributeCode = '')
106
+ {
107
+ $customerValue = '';
108
+
109
+ if ($attributeCode) {
110
+
111
+ if (array_key_exists($attributeCode, $this->_attributeValues)
112
+ && !empty($this->_attributeValues[$attributeCode])
113
+ && $customer->getData($attributeCode)
114
+ ) {
115
+ $customerValue = $this->_attributeValues[$attributeCode][$customer->getData($attributeCode)];
116
+ } elseif ($customer->getData($attributeCode)) {
117
+ $customerValue = $customer->getData($attributeCode);
118
+ }
119
+
120
+ }
121
+
122
+ return $customerValue;
123
+ }
124
+ }
app/code/community/Me/Gravity/Model/Export/Abstract.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Model_Export_Abstract
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Model_Export_Abstract
15
+ */
16
+ abstract class Me_Gravity_Model_Export_Abstract
17
+ {
18
+ /**
19
+ * @var Me_Gravity_Helper_Data
20
+ */
21
+ protected $_helper;
22
+
23
+ /**
24
+ * Base attributes to export
25
+ *
26
+ * @var array
27
+ */
28
+ protected $_baseAttributeCodes = array();
29
+
30
+ /**
31
+ * Disabled attribute types
32
+ *
33
+ * @var array
34
+ */
35
+ protected $_excludedAttributesTypes = array();
36
+
37
+ /**
38
+ * Disabled attribute codes
39
+ *
40
+ * @var array
41
+ */
42
+ protected $_excludedAttributeCodes = array();
43
+
44
+ /**
45
+ * Attributes with index (not label) value.
46
+ *
47
+ * @var array
48
+ */
49
+ protected $_indexValueAttributes = array();
50
+
51
+ /**
52
+ * Attribute code to its values. Only attributes with options and only default store values used.
53
+ *
54
+ * @var array
55
+ */
56
+ protected $_attributeValues = array();
57
+
58
+ /**
59
+ * Constructor
60
+ */
61
+ public function __construct()
62
+ {
63
+ $this->_helper = Mage::helper('me_gravity');
64
+ }
65
+
66
+ /**
67
+ * Entity attributes collection getter.
68
+ *
69
+ * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Attribute_Collection
70
+ */
71
+ public function getAttributeCollection()
72
+ {
73
+ return Mage::getResourceModel('catalog/product_attribute_collection');
74
+ }
75
+
76
+ /**
77
+ * Customer entity attributes collection getter.
78
+ *
79
+ * @return Mage_Customer_Model_Resource_Attribute_Collection
80
+ */
81
+ public function getCustomerAttributeCollection()
82
+ {
83
+ return Mage::getResourceModel('customer/attribute_collection');
84
+ }
85
+
86
+ /**
87
+ * Get attributes to filter
88
+ *
89
+ * @return array
90
+ */
91
+ public function getExportAttrCodes()
92
+ {
93
+ return $this->_baseAttributeCodes;
94
+ }
95
+
96
+ /**
97
+ * Get excluded attribute types
98
+ *
99
+ * @return array
100
+ */
101
+ public function getExcludedAttributeTypes()
102
+ {
103
+ return $this->_excludedAttributesTypes;
104
+ }
105
+
106
+ /**
107
+ * Get excluded attribute codes
108
+ *
109
+ * @return array
110
+ */
111
+ public function getExcludeAttributeCodes()
112
+ {
113
+ return $this->_excludedAttributeCodes;
114
+ }
115
+
116
+ /**
117
+ * Returns attributes all values in label-value or value-value pairs form. Labels are lower-cased.
118
+ *
119
+ * @param Mage_Eav_Model_Entity_Attribute_Abstract $attribute attribute
120
+ * @return array
121
+ */
122
+ public function getAttributeOptions(Mage_Eav_Model_Entity_Attribute_Abstract $attribute)
123
+ {
124
+ $options = array();
125
+
126
+ if ($attribute->usesSource()) {
127
+
128
+ $index = in_array($attribute->getAttributeCode(), $this->_indexValueAttributes) ? 'value' : 'label';
129
+
130
+ // only default (admin) store values used
131
+ $attribute->setStoreId(Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID);
132
+
133
+ try {
134
+ foreach ($attribute->getSource()->getAllOptions(false) as $option) {
135
+ foreach (is_array($option['value']) ? $option['value'] : array($option) as $innerOption) {
136
+ if (strlen($innerOption['value'])) { // skip ' -- Please Select -- ' option
137
+ $options[$innerOption['value']] = $innerOption[$index];
138
+ }
139
+ }
140
+ }
141
+ } catch (Exception $e) {
142
+ // ignore exceptions connected with source models
143
+ }
144
+ }
145
+
146
+ return $options;
147
+ }
148
+ }
app/code/community/Me/Gravity/Model/Export/Catalog/Product.php ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Model_Export_Catalog_Product
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Model_Export_Catalog_Product
15
+ */
16
+ class Me_Gravity_Model_Export_Catalog_Product extends Me_Gravity_Model_Export_Abstract
17
+ {
18
+ /**
19
+ * Maximum items to export
20
+ *
21
+ * @var int
22
+ */
23
+ const MAX_LIMIT = 1000;
24
+
25
+ /**
26
+ * Base attributes to export
27
+ *
28
+ * @var array
29
+ */
30
+ protected $_baseAttributeCodes = array(
31
+ 'status',
32
+ 'visibility',
33
+ 'name',
34
+ 'description',
35
+ 'image',
36
+ 'url_path',
37
+ 'price',
38
+ 'special_price',
39
+ 'special_from_date',
40
+ 'special_to_date'
41
+ );
42
+
43
+ /**
44
+ * Disabled attribute types
45
+ *
46
+ * @var array
47
+ */
48
+ protected $_excludedAttributesTypes = array(
49
+ 'price',
50
+ 'date',
51
+ 'media_image'
52
+ );
53
+
54
+ /**
55
+ * Disabled attribute codes
56
+ *
57
+ * @var array
58
+ */
59
+ protected $_excludedAttributeCodes = array(
60
+ 'custom_design',
61
+ 'custom_layout_update',
62
+ 'gallery',
63
+ 'media_gallery',
64
+ 'msrp_display_actual_price_type',
65
+ 'msrp_enabled',
66
+ 'options_container',
67
+ 'price_view',
68
+ 'tier_price'
69
+ );
70
+
71
+ /**
72
+ * Attributes with index (not label) value.
73
+ *
74
+ * @var array
75
+ */
76
+ protected $_indexValueAttributes = array(
77
+ 'status',
78
+ 'tax_class_id',
79
+ 'visibility',
80
+ 'gift_message_available',
81
+ 'custom_design'
82
+ );
83
+
84
+ /**
85
+ * @var Mage_Catalog_Model_Resource_Product_Collection
86
+ */
87
+ protected $_productCollection;
88
+
89
+ /**
90
+ * Categories ID to text-path hash.
91
+ *
92
+ * @var array
93
+ */
94
+ protected $_categories = array();
95
+
96
+ /**
97
+ * Root category names for each category
98
+ *
99
+ * @var array
100
+ */
101
+ protected $_rootCategories = array();
102
+
103
+ /**
104
+ * Constructor
105
+ */
106
+ public function __construct()
107
+ {
108
+ parent::__construct();
109
+
110
+ $this->_initCategories();
111
+ $this->_initAttributes();
112
+ }
113
+
114
+ /**
115
+ * Export product collection
116
+ *
117
+ * @param int $storeId store id
118
+ * @return Mage_Catalog_Model_Resource_Product_Collection
119
+ */
120
+ public function getProductCollection($storeId = 0)
121
+ {
122
+ if (is_null($this->_productCollection)) {
123
+
124
+ $this->_productCollection = $this->_addBaseAttributes($this->_getProductCollection())
125
+ ->setStoreId($storeId)
126
+ ->addWebsiteFilter(Mage::app()->getStore($storeId)->getWebsiteId())
127
+ ->addCategoryIds();
128
+
129
+ if ($this->_helper->getOnlySalable()) {
130
+ $this->_productCollection->addFinalPrice();
131
+ }
132
+
133
+ if (!$this->_helper->getCatalogExportAll()) {
134
+ if ($this->_helper->getCatalogMaxLimit()) {
135
+ $this->_productCollection->setPageSize((int)$this->_helper->getCatalogMaxLimit());
136
+ } else {
137
+ $this->_productCollection->setPageSize(self::MAX_LIMIT);
138
+ }
139
+ }
140
+
141
+ $this->_productCollection->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
142
+
143
+ $this->_productCollection->load();
144
+
145
+ }
146
+
147
+ return $this->_productCollection;
148
+ }
149
+
150
+ /**
151
+ * Add base attributes to collection
152
+ *
153
+ * @param Mage_Catalog_Model_Resource_Product_Collection $collection collection
154
+ * @return Mage_Catalog_Model_Resource_Product_Collection
155
+ */
156
+ protected function _addBaseAttributes(Mage_Catalog_Model_Resource_Product_Collection $collection)
157
+ {
158
+ $exportAttrCodes = $this->getExportAttrCodes();
159
+
160
+ if (!empty($this->_attributeValues)) {
161
+ $exportAttrCodes = array_merge($exportAttrCodes, array_keys($this->_attributeValues));
162
+ }
163
+
164
+ foreach ($this->getAttributeCollection() as $attribute) {
165
+
166
+ $attributeCode = $attribute->getAttributeCode();
167
+
168
+ if (in_array($attributeCode, $exportAttrCodes) && !in_array($attributeCode, $this->_excludedAttributeCodes)) {
169
+ $collection->addAttributeToSelect($attributeCode);
170
+ }
171
+
172
+ }
173
+
174
+ return $collection;
175
+ }
176
+
177
+ /**
178
+ * Get base product collection
179
+ *
180
+ * @return Mage_Catalog_Model_Resource_Product_Collection
181
+ */
182
+ protected function _getProductCollection()
183
+ {
184
+ return Mage::getResourceModel('catalog/product_collection');
185
+ }
186
+
187
+ /**
188
+ * Initialize categories ID to text-path hash.
189
+ *
190
+ * @return Me_Gravity_Model_Export_Catalog_Product
191
+ */
192
+ protected function _initCategories()
193
+ {
194
+ $collection = Mage::getResourceModel('catalog/category_collection')->addNameToResult();
195
+
196
+ foreach ($collection as $category) {
197
+ $structure = preg_split('#/+#', $category->getPath());
198
+ $pathSize = count($structure);
199
+ if ($pathSize > 1) {
200
+ $path = array();
201
+ for ($i = 1; $i < $pathSize; $i++) {
202
+ $path[] = $collection->getItemById($structure[$i])->getName();
203
+ }
204
+ $this->_rootCategories[$category->getId()] = array_shift($path);
205
+ if ($pathSize > 2) {
206
+ $this->_categories[$category->getId()] = implode('/', $path);
207
+ }
208
+ }
209
+
210
+ }
211
+ return $this;
212
+ }
213
+
214
+ /**
215
+ * Initialize attribute option values and types
216
+ *
217
+ * @return $this
218
+ */
219
+ protected function _initAttributes()
220
+ {
221
+ if ($additionalAttributes = $this->_helper->getAdditionalCatalogAttributes()) {
222
+ foreach (Mage::getResourceModel('catalog/product_attribute_collection') as $attribute) {
223
+ if (in_array($attribute->getAttributeCode(), $additionalAttributes)) {
224
+ $this->_attributeValues[$attribute->getAttributeCode()] = $this->getAttributeOptions($attribute);
225
+ }
226
+ }
227
+ }
228
+
229
+ return $this;
230
+ }
231
+ }
app/code/community/Me/Gravity/Model/Export/Customer/Customer.php ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Model_Export_Customer_Customer
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Model_Export_Customer_Customer
15
+ */
16
+ class Me_Gravity_Model_Export_Customer_Customer extends Me_Gravity_Model_Export_Abstract
17
+ {
18
+ /**
19
+ * Maximum customers to export
20
+ *
21
+ * @var int
22
+ */
23
+ const MAX_LIMIT = 1000;
24
+
25
+ /**
26
+ * Base attributes to export
27
+ *
28
+ * @var array
29
+ */
30
+ protected $_baseAttributeCodes = array(
31
+ 'email',
32
+ 'firstname',
33
+ 'lastname'
34
+ );
35
+
36
+ /**
37
+ * Disabled attribute codes
38
+ *
39
+ * @var array
40
+ */
41
+ protected $_excludedAttributeCodes = array(
42
+ 'confirmation',
43
+ 'created_at',
44
+ 'created_in',
45
+ 'default_billing',
46
+ 'default_shipping',
47
+ 'disable_auto_group_change',
48
+ 'password_hash',
49
+ 'reward_update_notification',
50
+ 'reward_warning_notification',
51
+ 'rp_token',
52
+ 'rp_token_created_at'
53
+ );
54
+
55
+ /**
56
+ * @var Mage_Customer_Model_Resource_Customer_Collection
57
+ */
58
+ protected $_customerCollection;
59
+
60
+ /**
61
+ * Constructor
62
+ */
63
+ public function __construct()
64
+ {
65
+ parent::__construct();
66
+
67
+ $this->_initAttributes();
68
+ }
69
+
70
+ /**
71
+ * Export product collection
72
+ *
73
+ * @param int $storeId store id
74
+ * @return Mage_Customer_Model_Resource_Customer_Collection
75
+ */
76
+ public function getCustomerCollection($storeId = 0)
77
+ {
78
+ if (is_null($this->_customerCollection)) {
79
+
80
+ $this->_customerCollection = $this->_addBaseAttributes($this->_getCustomerCollection())
81
+ ->addAttributeToFilter('website_id', Mage::app()->getStore($storeId)->getWebsiteId());
82
+
83
+ if (!$this->_helper->getCustomerExportAll()) {
84
+ if ($this->_helper->getCustomerMaxLimit()) {
85
+ $this->_customerCollection->setPageSize((int)$this->_helper->getCustomerMaxLimit());
86
+ } else {
87
+ $this->_customerCollection->setPageSize(self::MAX_LIMIT);
88
+ }
89
+ }
90
+
91
+ $this->_customerCollection->load();
92
+
93
+ }
94
+
95
+ return $this->_customerCollection;
96
+ }
97
+
98
+ /**
99
+ * Get base customer collection
100
+ *
101
+ * @return Mage_Customer_Model_Resource_Customer_Collection
102
+ */
103
+ protected function _getCustomerCollection()
104
+ {
105
+ return Mage::getResourceModel('customer/customer_collection');
106
+ }
107
+
108
+ /**
109
+ * Add base attributes to collection
110
+ *
111
+ * @param Mage_Customer_Model_Resource_Customer_Collection $collection collection
112
+ * @return Mage_Customer_Model_Resource_Customer_Collection
113
+ */
114
+ protected function _addBaseAttributes(Mage_Customer_Model_Resource_Customer_Collection $collection)
115
+ {
116
+ $exportAttrCodes = $this->getExportAttrCodes();
117
+
118
+ if (!empty($this->_attributeValues)) {
119
+ $exportAttrCodes = array_merge($exportAttrCodes, array_keys($this->_attributeValues));
120
+ }
121
+
122
+ foreach ($this->getCustomerAttributeCollection() as $attribute) {
123
+
124
+ $attributeCode = $attribute->getAttributeCode();
125
+
126
+ if (in_array($attributeCode, $exportAttrCodes) && !in_array($attributeCode, $this->_excludedAttributeCodes)) {
127
+ $collection->addAttributeToSelect($attributeCode);
128
+ }
129
+
130
+ }
131
+
132
+ return $collection;
133
+ }
134
+
135
+ /**
136
+ * Initialize attribute option values and types
137
+ *
138
+ * @return $this
139
+ */
140
+ protected function _initAttributes()
141
+ {
142
+ if ($additionalAttributes = $this->_helper->getAdditionalCustomerAttributes()) {
143
+ foreach ($this->getCustomerAttributeCollection() as $attribute) {
144
+ if (in_array($attribute->getAttributeCode(), $additionalAttributes)) {
145
+ $this->_attributeValues[$attribute->getAttributeCode()] = $this->getAttributeOptions($attribute);
146
+ }
147
+ }
148
+ }
149
+
150
+ return $this;
151
+ }
152
+ }
app/code/community/Me/Gravity/Model/Method/Abstract.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Model_Method_Abstract
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Model_Method_Abstract
15
+ */
16
+ abstract class Me_Gravity_Model_Method_Abstract extends Varien_Object
17
+ {
18
+ /**
19
+ * @var Me_Gravity_Helper_Data
20
+ */
21
+ protected $_helper;
22
+
23
+ /**
24
+ * Communication method features
25
+ *
26
+ * @var bool
27
+ */
28
+ protected $_canDebugLog = false;
29
+ protected $_canSendRequest = false;
30
+
31
+ /**
32
+ * Check debug logging availability
33
+ *
34
+ * @return bool
35
+ */
36
+ public function canDebugLog()
37
+ {
38
+ return $this->_canDebugLog;
39
+ }
40
+
41
+ /**
42
+ * Check send request availability
43
+ *
44
+ * @return bool
45
+ */
46
+ public function canSendRequest()
47
+ {
48
+ return $this->_canSendRequest;
49
+ }
50
+
51
+ /**
52
+ * Send data
53
+ *
54
+ * @param string $type event type
55
+ * @param array $params parameters
56
+ * @return $this
57
+ * @throws Mage_Core_Exception
58
+ */
59
+ public function sendRequest($type, $params = array())
60
+ {
61
+ if (!$this->canSendRequest()) {
62
+ Mage::throwException($this->_getGravityHelper()->__('Send action is not available.'));
63
+ }
64
+
65
+ return $this;
66
+ }
67
+
68
+ /**
69
+ * Retrieve Gravity extension helper
70
+ *
71
+ * @return Me_Gravity_Helper_Data
72
+ */
73
+ protected function _getGravityHelper()
74
+ {
75
+ return Mage::helper('me_gravity');
76
+ }
77
+ }
app/code/community/Me/Gravity/Model/Method/Request.php ADDED
@@ -0,0 +1,553 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Salesautopilot_Model_Method_Request
4
+ *
5
+ * @category Me
6
+ * @package Me_Salesautopilot
7
+ * @author Sági Attila <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Model_Method_Request
15
+ */
16
+ require_once 'app/code/community/Me/Gravity/Model/Client/GravityClient.php';
17
+
18
+ class Me_Gravity_Model_Method_Request extends Me_Gravity_Model_Method_Abstract
19
+ {
20
+ /**
21
+ * Request event type
22
+ */
23
+ const EVENT_TYPE_GET = 'GET';
24
+
25
+ /**
26
+ * Send event type
27
+ */
28
+ const EVENT_TYPE_SEND = 'SEND';
29
+
30
+ /**
31
+ * Test event type
32
+ */
33
+ const EVENT_TYPE_TEST = 'TEST';
34
+
35
+ /**
36
+ * Update / add event type
37
+ */
38
+ const EVENT_TYPE_UPDATE = 'UPDATE';
39
+
40
+ /**
41
+ * Event type customer update
42
+ */
43
+ const EVENT_TYPE_CUSTOMER_UPDATE = 'CUSTOMER_UPDATE';
44
+
45
+ /**
46
+ * Event type product update
47
+ */
48
+ const EVENT_TYPE_PRODUCT_UPDATE = 'PRODUCT_UPDATE';
49
+
50
+ /**
51
+ * Event type add to cart
52
+ */
53
+ const EVENT_TYPE_ADD_TO_CART = 'ADD_TO_CART';
54
+
55
+ /**
56
+ * Event type remove from cart
57
+ */
58
+ const EVENT_TYPE_REMOVE_FROM_CART = 'REMOVE_FROM_CART';
59
+
60
+ /**
61
+ * Event type buy
62
+ */
63
+ const EVENT_TYPE_BUY = 'BUY';
64
+
65
+ /**
66
+ * Product page similar
67
+ */
68
+ const PRODUCT_PAGE_SIMILAR = 'ITEM_PAGE_SIMILAR';
69
+
70
+ /**
71
+ * Product page personal
72
+ */
73
+ const PRODUCT_PAGE_PERSONAL = 'ITEM_PAGE_PERSONAL';
74
+
75
+ /**
76
+ * Product page accessories
77
+ */
78
+ const PRODUCT_PAGE_ACCESSORIES = 'ITEM_PAGE_ACCESSORIES';
79
+
80
+ /**
81
+ * Category page personal
82
+ */
83
+ const CATEGORY_PAGE_PERSONAL = 'CATEGORY_PAGE_PERSONAL';
84
+
85
+ /**
86
+ * Category page top
87
+ */
88
+ const CATEGORY_PAGE_TOP = 'CATEGORY_PAGE_POP';
89
+
90
+ /**
91
+ * Cart page
92
+ */
93
+ const CART_PAGE = 'CART_PAGE';
94
+
95
+ /**
96
+ * Search result page
97
+ */
98
+ const SEARCH_RESULT_PAGE = 'LISTING_PAGE';
99
+
100
+ /**
101
+ * General page, Personal Best Box
102
+ */
103
+ const GENERAL_PERSONAL_BEST = 'PERSONAL_BEST';
104
+
105
+ /**
106
+ * General page, History Box
107
+ */
108
+ const GENERAL_PERSONAL_HISTORY = 'PERSONAL_HISTORY';
109
+
110
+ /**
111
+ * General page, Currently Viewed Box
112
+ */
113
+ const GENERAL_CURRENTLY_VIEWED = 'CURRENTLY_VIEWED';
114
+
115
+ /**
116
+ * General page, Popular Box
117
+ */
118
+ const GENERAL_POPULAR = 'POPULAR';
119
+
120
+ /**
121
+ * Gravity cookie name
122
+ */
123
+ const GRAVITY_COOKIE_NAME = 'gr_reco';
124
+
125
+ /**
126
+ * Path to store config API password
127
+ *
128
+ * @var string
129
+ */
130
+ const XML_PATH_API_URL = 'gravity/config/api_url';
131
+
132
+ /**
133
+ * Communication method features
134
+ *
135
+ * @var bool
136
+ */
137
+ protected $_canSendRequest = true;
138
+
139
+ /**
140
+ * Gravity unique cookie id
141
+ *
142
+ * @var string
143
+ */
144
+ protected $_gravityCookie = '';
145
+
146
+ /**
147
+ * Constructor
148
+ *
149
+ * @return void
150
+ */
151
+ public function _construct()
152
+ {
153
+ parent::_construct();
154
+
155
+ $this->_helper = $this->_getGravityHelper();
156
+ if ($this->_helper->getDebugMode()) {
157
+ $this->_canDebugLog = true;
158
+ }
159
+ }
160
+
161
+ /**
162
+ * Send request
163
+ *
164
+ * @param string $type event type
165
+ * @param array $params parameters
166
+ * @throws Exception
167
+ * @return $this|bool
168
+ */
169
+ public function sendRequest($type, $params = array())
170
+ {
171
+ parent::sendRequest($type, $params);
172
+
173
+ if (!$this->_helper->isFullyEnabled()) {
174
+ $this->_helper->getLogger($this->_helper->__('Invalid Gravity extension configuration.'));
175
+ return false;
176
+ }
177
+
178
+ try {
179
+
180
+ $client = $this->_init();
181
+ $this->_getGravityCookie();
182
+
183
+ if ($this->_canDebugLog) {
184
+ $this->_helper->getLogger($type);
185
+ if (isset($params['type']) && $params['type']) {
186
+ $this->_helper->getLogger($params['type']);
187
+ }
188
+ }
189
+
190
+ switch ($type) {
191
+ case self::EVENT_TYPE_GET:
192
+ $result = $this->_getRecommendationItems($client, $params);
193
+ break;
194
+ case self::EVENT_TYPE_TEST:
195
+ $result = $client->test($this->_helper->getApiUser());
196
+ break;
197
+ case self::EVENT_TYPE_SEND:
198
+ $result = $this->_sendEvent($client, $params);
199
+ break;
200
+ case self::EVENT_TYPE_UPDATE:
201
+ $result = $this->_sendUpdate($client, $params);
202
+ break;
203
+ default:
204
+ return false;
205
+ }
206
+
207
+ if ($this->_canDebugLog && $result) {
208
+ $this->_helper->getLogger($result);
209
+ }
210
+
211
+ return $this->_validateResult($result);
212
+
213
+ } catch (Mage_Core_Exception $e) {
214
+
215
+ $this->_helper->getLogger($e->getMessage());
216
+
217
+ } catch (Exception $e) {
218
+
219
+ $this->_helper->getLogger($e->getMessage());
220
+
221
+ }
222
+
223
+ return $this;
224
+ }
225
+
226
+ /**
227
+ * Send event
228
+ *
229
+ * @param GravityClient $client client
230
+ * @param array $params parameters
231
+ * @throws Mage_Core_Exception
232
+ * @return object|array
233
+ */
234
+ protected function _sendEvent($client, $params)
235
+ {
236
+ if (!isset($params['type'])) {
237
+ Mage::throwException($this->_helper->__('Invalid recommendation type'));
238
+ }
239
+
240
+ $event = new GravityEvent();
241
+ if (isset($params['type']) && $params['type']) {
242
+ $event->eventType = $params['type'];
243
+ } else {
244
+ Mage::throwException($this->_helper->__('Invalid event type'));
245
+ }
246
+
247
+ $event->userId = $this->_getCustomerId();
248
+ $event->cookieId = $this->_getGravityCookie();
249
+ $event->time = time();
250
+
251
+ switch ($params['type']) {
252
+ case self::EVENT_TYPE_ADD_TO_CART:
253
+ if (isset($params['product'])
254
+ && isset($params['qty'])
255
+ && $params['product']
256
+ && $params['qty']
257
+ ) {
258
+ $event->itemId = $params['product'];
259
+ $qty = new GravityNameValue('quantity', $params['qty']);
260
+ $price = new GravityNameValue('price', $params['price']);
261
+ $event->nameValues = array($qty, $price);
262
+ if ($this->_canDebugLog) {
263
+ $this->_helper->getLogger('Item id: ' . $event->itemId);
264
+ $this->_helper->getLogger('Qty: ' . $params['qty']);
265
+ }
266
+ } else {
267
+ Mage::throwException($this->_helper->__('Invalid ' . $params['type'] . ' parameters'));
268
+ }
269
+ break;
270
+ case self::EVENT_TYPE_REMOVE_FROM_CART:
271
+ if (isset($params['product']) && isset($params['qty']) && $params['product'] && $params['qty']) {
272
+ $event->itemId = $params['product'];
273
+ $qty = new GravityNameValue('quantity', $params['qty']);
274
+ $event->nameValues = array($qty);
275
+ if ($this->_canDebugLog) {
276
+ $this->_helper->getLogger('Item id: ' . $event->itemId);
277
+ $this->_helper->getLogger('Qty: ' . $params['qty']);
278
+ }
279
+ } else {
280
+ Mage::throwException($this->_helper->__('Invalid ' . $params['type'] . ' parameters'));
281
+ }
282
+ break;
283
+ case self::EVENT_TYPE_BUY:
284
+ if (isset($params['orderId'])
285
+ && isset($params['itemId'])
286
+ && isset($params['unitPrice'])
287
+ && isset($params['quantity'])
288
+ && $params['orderId']
289
+ && $params['itemId']
290
+ && $params['unitPrice']
291
+ && $params['quantity']
292
+ ) {
293
+ $event->itemId = $params['itemId'];
294
+ $quantity = new GravityNameValue('quantity', $params['quantity']);
295
+ $unitPrice = new GravityNameValue('unitPrice', $params['unitPrice']);
296
+ $currency = new GravityNameValue('currency', $params['currency']);
297
+ $orderId = new GravityNameValue('orderId', $params['orderId']);
298
+ $event->nameValues = array($quantity, $unitPrice, $currency, $orderId);
299
+ if ($this->_canDebugLog) {
300
+ $this->_helper->getLogger('Item id: ' . $event->itemId);
301
+ $this->_helper->getLogger('Qty: ' . $params['quantity']);
302
+ $this->_helper->getLogger('UnitPrice: ' . $params['unitPrice']);
303
+ $this->_helper->getLogger('Currency: ' . $params['currency']);
304
+ $this->_helper->getLogger('OrderId: ' . $params['orderId']);
305
+ }
306
+ } else {
307
+ Mage::throwException($this->_helper->__('Invalid ' . $params['type'] . ' parameters'));
308
+ }
309
+ break;
310
+ default:
311
+ return false;
312
+ }
313
+
314
+ $eventsToAdd = array($event);
315
+ $async = false;
316
+ try {
317
+
318
+ $result = $client->addEvents($eventsToAdd, $async);
319
+
320
+ return $result;
321
+
322
+ } catch (GravityException $e) {
323
+ $this->_helper->getLogger($this->_helper->__('Error happened by sending the event!'));
324
+ $this->_helper->getLogger($this->_helper->__('Message: ' . $e->getMessage() . ' Fault info: ' . $e->faultInfo));
325
+ }
326
+ }
327
+
328
+ /**
329
+ * Get recommendation
330
+ *
331
+ * @param GravityClient $client client
332
+ * @param array $params parameters
333
+ * @throws Mage_Core_Exception
334
+ * @return object
335
+ */
336
+ protected function _getRecommendationItems($client, $params)
337
+ {
338
+ if (!isset($params['type'])) {
339
+ Mage::throwException($this->_helper->__('Invalid recommendation type.'));
340
+ }
341
+
342
+ if ($this->_helper->getDebugMode()) {
343
+ $this->_helper->getLogger($params);
344
+ }
345
+
346
+ $userId = $this->_getCustomerId();
347
+ $cookieId = $this->_gravityCookie;
348
+ $recommendationContext = new GravityRecommendationContext();
349
+ $recommendationContext->scenarioId = $params['type'];
350
+
351
+ if (isset($params['limit']) && $params['limit']) {
352
+ $recommendationContext->numberLimit = $params['limit'];
353
+ } else {
354
+ $recommendationContext->numberLimit = 5;
355
+ }
356
+
357
+ if (isset($params['itemId']) && $params['itemId']) {
358
+ $pageItemId = new GravityNameValue('currentItemId', 'ItemID_' . $params['itemId']);
359
+ $recommendationContext->nameValues = array($pageItemId);
360
+ }
361
+
362
+ if (isset($params['itemsInCart']) && is_array($params['itemsInCart']) && $params['itemsInCart']) {
363
+ foreach ($params['itemsInCart'] as $itemId) {
364
+ $itemId = new GravityNameValue('cartItemId', $itemId);
365
+ $recommendationContext->nameValues = array($itemId);
366
+ }
367
+ }
368
+
369
+ if (isset($params['filters']) && is_array($params['filters']) && $params['filters']) {
370
+ foreach ($params['filters'] as $key => $filter) {
371
+ $nameValue = new GravityNameValue($key, $filter);
372
+ $recommendationContext->nameValues = array($nameValue);
373
+ }
374
+ }
375
+
376
+ if (isset($params['keywords']) && is_array($params['keywords']) && $params['keywords']) {
377
+ foreach ($params['keywords'] as $key => $filter) {
378
+ $nameValue = new GravityNameValue($key, $filter);
379
+ $recommendationContext->nameValues = array($nameValue);
380
+ }
381
+ }
382
+
383
+ $recommendationContext->recommendationTime = time();
384
+
385
+ $itemRecommendation = null;
386
+ try {
387
+
388
+ $itemRecommendation = $client->getItemRecommendation($userId, $cookieId, $recommendationContext);
389
+
390
+ return $itemRecommendation;
391
+
392
+ } catch (GravityException $e) {
393
+
394
+ $this->_helper->getLogger($this->_helper->__('Error happened by getting the item recommendation!'));
395
+ $this->_helper->getLogger($e->getMessage());
396
+ $this->_helper->getLogger($e->faultInfo);
397
+
398
+ }
399
+ }
400
+
401
+ /**
402
+ * Send update
403
+ *
404
+ * @param GravityClient $client client
405
+ * @param array $params parameters
406
+ * @throws Mage_Core_Exception
407
+ * @return object
408
+ */
409
+ protected function _sendUpdate($client, $params)
410
+ {
411
+ if (!isset($params['type'])) {
412
+ Mage::throwException($this->_helper->__('Invalid recommendation type.'));
413
+ }
414
+
415
+ try {
416
+ $result = '';
417
+ switch ($params['type']) {
418
+ case self::EVENT_TYPE_CUSTOMER_UPDATE:
419
+ if (isset($params['userid']) && $params['userid']) {
420
+ $user = new GravityUser();
421
+ $user->userId = $params['userid'];
422
+ $user->hidden = false;
423
+
424
+ if ($this->_canDebugLog) {
425
+ $this->_helper->getLogger('userId: ' .$params['userid']);
426
+ }
427
+
428
+ unset($params['type']);
429
+ unset($params['userid']);
430
+ foreach ($params as $attribute => $value) {
431
+ if ($value) {
432
+ $user->nameValues[] = new GravityNameValue($attribute, $value);
433
+ }
434
+ }
435
+ $result = $client->addUser($user, true);
436
+
437
+ } else {
438
+ Mage::throwException($this->_helper->__('Invalid ' . $params['type'] . ' parameters'));
439
+ }
440
+ break;
441
+ case self::EVENT_TYPE_PRODUCT_UPDATE:
442
+ if (isset($params['itemid']) && isset($params['title']) && $params['itemid'] && $params['title']) {
443
+ $item = new GravityItem();
444
+ $item->itemId = $params['itemid'];
445
+ $item->title = $params['title'];
446
+ $item->hidden = $params['hidden'];
447
+ if ($this->_canDebugLog) {
448
+ $this->_helper->getLogger('itemId: ' .$params['itemid']);
449
+ }
450
+
451
+ unset($params['type']);
452
+ unset($params['itemid']);
453
+ unset($params['hidden']);
454
+ foreach ($params as $attribute => $value) {
455
+ if ($value) {
456
+ $item->nameValues[] = new GravityNameValue($attribute, $value);
457
+ }
458
+ }
459
+ $isAsync = true;
460
+ $result = $client->addItem($item, $isAsync);
461
+
462
+ } else {
463
+ Mage::throwException($this->_helper->__('Invalid ' . $params['type'] . ' parameters'));
464
+ }
465
+ break;
466
+ default:
467
+ return false;
468
+ }
469
+
470
+ return $result;
471
+
472
+ } catch (GravityException $e) {
473
+
474
+ $this->_helper->getLogger($this->_helper->__('Error happened by adding user!'));
475
+ $this->_helper->getLogger($e->getMessage());
476
+ $this->_helper->getLogger($e->faultInfo);
477
+
478
+ }
479
+ }
480
+
481
+ /**
482
+ * Validate result
483
+ *
484
+ * @param stdClass $result result
485
+ * @return null|string|array
486
+ */
487
+ protected function _validateResult($result)
488
+ {
489
+ $answer = array();
490
+
491
+ if ($result && $result instanceof stdClass) {
492
+
493
+ $answer[$result->recommendationId] = $result->itemIds;
494
+ return $answer;
495
+
496
+ } elseif ($result && is_string($result)) {
497
+
498
+ return $result;
499
+
500
+ }
501
+
502
+ return null;
503
+ }
504
+
505
+ /**
506
+ * Init Gravity Client
507
+ *
508
+ * @return GravityClient object
509
+ */
510
+ protected function _init()
511
+ {
512
+ $config = new GravityClientConfig();
513
+ $config->remoteUrl = $this->_getApiUrl();
514
+ $config->user = $this->_helper->getApiUser();
515
+ $config->password = $this->_helper->getApiPassword();
516
+ return new GravityClient($config);
517
+ }
518
+
519
+ /**
520
+ * Get current customer id
521
+ *
522
+ * @return mixed
523
+ */
524
+ protected function _getCustomerId()
525
+ {
526
+ return Mage::getSingleton('customer/session')->getCustomer()->getId();
527
+ }
528
+
529
+ /**
530
+ * Get API URL
531
+ *
532
+ * @param integer|string|Mage_Core_Model_Store $store store
533
+ * @return boolean
534
+ */
535
+ private function _getApiUrl($store = null)
536
+ {
537
+ return Mage::getStoreConfig(self::XML_PATH_API_URL, $store);
538
+ }
539
+
540
+ /**
541
+ * Get Gravity cookie
542
+ *
543
+ * @return string
544
+ */
545
+ private function _getGravityCookie()
546
+ {
547
+ if (!$this->_gravityCookie) {
548
+ $this->_gravityCookie = Mage::getModel('core/cookie')->get(self::GRAVITY_COOKIE_NAME);
549
+ }
550
+
551
+ return $this->_gravityCookie;
552
+ }
553
+ }
app/code/community/Me/Gravity/Model/Observer.php ADDED
@@ -0,0 +1,660 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Abstract
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Block_Abstract
15
+ */
16
+ class Me_Gravity_Model_Observer
17
+ {
18
+ /**
19
+ * App Gravity block to catalog product view
20
+ *
21
+ * @param Varien_Event_Observer $observer observer
22
+ * @return void|boolean
23
+ */
24
+ public function setGravityProductBlock(Varien_Event_Observer $observer)
25
+ {
26
+ if (!$this->_getGravityHelper()->isFullyEnabled()) {
27
+ return false;
28
+ }
29
+
30
+ if ($this->_getGravityHelper()->isPreviewMode()) {
31
+ $previewParam = Mage::app()->getRequest()->getParam('gr_reco_test');
32
+ if (!isset($previewParam) || $previewParam != 'true') {
33
+ return false;
34
+ }
35
+ }
36
+
37
+ $controller = $observer->getAction();
38
+ if ($controller->getFullActionName() == 'catalog_product_view') {
39
+
40
+ $layout = $controller->getLayout();
41
+ $this->_setProductPageBoxes($layout);
42
+
43
+ } elseif ($controller->getFullActionName() == 'catalog_category_view') {
44
+
45
+ $layout = $controller->getLayout();
46
+ $this->_setCategoryPageBoxes($layout);
47
+
48
+ } elseif ($controller->getFullActionName() == 'catalogsearch_result_index'
49
+ || $controller->getFullActionName() == 'catalogsearch_advanced_result'
50
+ ) {
51
+
52
+ $layout = $controller->getLayout();
53
+ $this->_setSearchResultBox($layout);
54
+
55
+ } elseif ($controller->getFullActionName() == 'checkout_cart_index') {
56
+
57
+ $layout = $controller->getLayout();
58
+ $this->_setCartPageBox($layout);
59
+
60
+ } else {
61
+ $enabledPages = explode(',', $this->_getGravityHelper()->getEnabledPages());
62
+ $homePagePath = $this->_getHomePagePath();
63
+ if ($enabledPages
64
+ && ($controller->getFullActionName() == 'cms_index_index' && in_array($homePagePath, $enabledPages))
65
+ || ($controller->getFullActionName() == 'cms_page_view' && in_array($observer->getAction()->getRequest()->getOriginalPathInfo(), $enabledPages))
66
+ || in_array($controller->getFullActionName(), $enabledPages)
67
+ ) {
68
+ $layout = $controller->getLayout();
69
+ $this->_setGeneralBoxes($layout);
70
+ }
71
+
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Gravity add to cart event observer
77
+ *
78
+ * @param Varien_Event_Observer $observer observer
79
+ * @return $this|boolean
80
+ */
81
+ public function gravityAddToCart(Varien_Event_Observer $observer)
82
+ {
83
+ if (!$this->_getGravityHelper()->isFullyEnabled()) {
84
+ return false;
85
+ }
86
+
87
+ try {
88
+ $requestParams = Mage::app()->getRequest()->getParams();
89
+ $product = $observer->getProduct();
90
+
91
+ if (!is_null($product) && $product->getId() && isset($requestParams['product']) && $requestParams['product']) {
92
+
93
+ Mage::getModel('me_gravity/method_request')->sendRequest(
94
+ Me_Gravity_Model_Method_Request::EVENT_TYPE_SEND,
95
+ array(
96
+ 'type' => Me_Gravity_Model_Method_Request::EVENT_TYPE_ADD_TO_CART,
97
+ 'product' => $requestParams['product'],
98
+ 'qty' => isset($requestParams['qty']) ? $requestParams['qty'] : 1,
99
+ 'price' => $product->getFinalPrice()
100
+ )
101
+ );
102
+
103
+ }
104
+ } catch (Mage_Core_Exception $e) {
105
+ $this->_getGravityHelper()->getLogger($e->getMessage());
106
+ } catch (Exception $e) {
107
+ $this->_getGravityHelper()->getLogger(
108
+ $e->getMessage(),
109
+ $this->_getGravityHelper()->__('An error occurred while sending add to cart event to Gravity.')
110
+ );
111
+ }
112
+
113
+ return $this;
114
+ }
115
+
116
+ /**
117
+ * Gravity update cart event observer
118
+ *
119
+ * @param Varien_Event_Observer $observer observer
120
+ * @return $this|boolean
121
+ */
122
+ public function gravityUpdateCart(Varien_Event_Observer $observer)
123
+ {
124
+ if (!$this->_getGravityHelper()->isFullyEnabled()) {
125
+ return false;
126
+ }
127
+
128
+ $cart = $observer->getEvent()->getCart();
129
+ $data = $observer->getEvent()->getInfo();
130
+
131
+ if ($cart && $data) {
132
+
133
+ try {
134
+
135
+ foreach ($data as $itemId => $itemInfo) {
136
+
137
+ if ($item = $cart->getQuote()->getItemById($itemId)) {
138
+
139
+ Mage::getModel('me_gravity/method_request')->sendRequest(
140
+ Me_Gravity_Model_Method_Request::EVENT_TYPE_SEND,
141
+ array(
142
+ 'type' => Me_Gravity_Model_Method_Request::EVENT_TYPE_ADD_TO_CART,
143
+ 'product' => $item->getProductId(),
144
+ 'qty' => $itemInfo['qty'],
145
+ 'price' => $item->getPrice()
146
+ )
147
+ );
148
+
149
+ }
150
+
151
+ }
152
+
153
+ } catch (Mage_Core_Exception $e) {
154
+ $this->_getGravityHelper()->getLogger($e->getMessage());
155
+ } catch (Exception $e) {
156
+ $this->_getGravityHelper()->getLogger(
157
+ $e->getMessage(),
158
+ $this->_getGravityHelper()->__('An error occurred while sending cart update event to Gravity.')
159
+ );
160
+ }
161
+ }
162
+
163
+ return $this;
164
+ }
165
+
166
+ /**
167
+ * Gravity remove from cart event observer
168
+ *
169
+ * @param Varien_Event_Observer $observer observer
170
+ * @return $this|boolean
171
+ */
172
+ public function gravityRemoveFromCart(Varien_Event_Observer $observer)
173
+ {
174
+ if (!$this->_getGravityHelper()->isFullyEnabled()) {
175
+ return false;
176
+ }
177
+
178
+ try {
179
+ $product = $observer->getQuoteItem()->getProduct();
180
+ $qty = $observer->getQuoteItem()->getQty();
181
+
182
+ if (!is_null($product) && $product->getId()) {
183
+
184
+ Mage::getModel('me_gravity/method_request')->sendRequest(
185
+ Me_Gravity_Model_Method_Request::EVENT_TYPE_SEND,
186
+ array(
187
+ 'type' => Me_Gravity_Model_Method_Request::EVENT_TYPE_REMOVE_FROM_CART,
188
+ 'product' => $product->getId(),
189
+ 'qty' => isset($qty) ? $qty : 1
190
+ )
191
+ );
192
+
193
+ }
194
+
195
+ } catch (Mage_Core_Exception $e) {
196
+ $this->_getGravityHelper()->getLogger($e->getMessage());
197
+ } catch (Exception $e) {
198
+ $this->_getGravityHelper()->getLogger(
199
+ $e->getMessage(),
200
+ $this->_getGravityHelper()->__('An error occurred while sending remove form cart event to Gravity.')
201
+ );
202
+ }
203
+
204
+ return $this;
205
+ }
206
+
207
+ /**
208
+ * Gravity buy event observer
209
+ *
210
+ * @param Varien_Event_Observer $observer observer
211
+ * @return $this|boolean
212
+ */
213
+ public function gravitySendBuy(Varien_Event_Observer $observer)
214
+ {
215
+ if (!$this->_getGravityHelper()->isFullyEnabled()) {
216
+ return false;
217
+ }
218
+
219
+ try {
220
+
221
+ $order = $observer->getOrder();
222
+ if (!is_null($order) && $order->getId()) {
223
+
224
+ $orderItem = array();
225
+ $orderId = $order->getEntityId();
226
+ $baseCurrency = $order->getBaseCurrencyCode();
227
+ foreach ($order->getAllItems() as $item) {
228
+
229
+ Mage::getModel('me_gravity/method_request')->sendRequest(
230
+ Me_Gravity_Model_Method_Request::EVENT_TYPE_SEND,
231
+ array(
232
+ 'type' => Me_Gravity_Model_Method_Request::EVENT_TYPE_BUY,
233
+ 'orderId' => $orderId,
234
+ 'itemId' => $item->getProduct()->getId(),
235
+ 'unitPrice' => $item->getBasePrice(),
236
+ 'quantity' => $item->getQtyOrdered(),
237
+ 'currency' => $baseCurrency
238
+ )
239
+ );
240
+ }
241
+
242
+ }
243
+
244
+ } catch (Mage_Core_Exception $e) {
245
+ $this->_getGravityHelper()->getLogger($e->getMessage());
246
+ } catch (Exception $e) {
247
+ $this->_getGravityHelper()->getLogger(
248
+ $e->getMessage(),
249
+ $this->_getGravityHelper()->__('An error occurred while sending buy event to Gravity.')
250
+ );
251
+ }
252
+
253
+ return $this;
254
+ }
255
+
256
+ /**
257
+ * Gravity customer update event observer
258
+ *
259
+ * @param Varien_Event_Observer $observer observer
260
+ * @return $this|bool
261
+ */
262
+ public function gravityUserUpdate(Varien_Event_Observer $observer)
263
+ {
264
+ if (!$this->_getGravityHelper()->isFullyEnabled() || !$this->_getGravityHelper()->getCustomerUpdateEnabled()) {
265
+ return false;
266
+ }
267
+
268
+ try {
269
+
270
+ $customer = $observer->getCustomer();
271
+ if (!is_null($customer) && $customer->getId()) {
272
+
273
+ $parameters = array(
274
+ 'type' => Me_Gravity_Model_Method_Request::EVENT_TYPE_CUSTOMER_UPDATE
275
+ );
276
+
277
+ $exportModel = Mage::getModel('me_gravity/customers');
278
+ foreach ($exportModel->getExportHeaders() as $attribute) {
279
+ if ($attribute == 'userid') {
280
+ $parameters[$attribute] = $customer->getId();
281
+ } elseif ($attributeValue = $exportModel->getAttributeValueByCode($customer, $attribute)) {
282
+ $parameters[$attribute] = $attributeValue;
283
+ }
284
+ }
285
+
286
+ Mage::getModel('me_gravity/method_request')->sendRequest(
287
+ Me_Gravity_Model_Method_Request::EVENT_TYPE_UPDATE,
288
+ $parameters
289
+ );
290
+
291
+ }
292
+
293
+ } catch (Mage_Core_Exception $e) {
294
+ $this->_getGravityHelper()->getLogger($e->getMessage());
295
+ } catch (Exception $e) {
296
+ $this->_getGravityHelper()->getLogger(
297
+ $e->getMessage(),
298
+ $this->_getGravityHelper()->__('An error occurred while sending customer update event to Gravity.')
299
+ );
300
+ }
301
+
302
+ return $this;
303
+ }
304
+
305
+ /**
306
+ * Gravity customer registration event observer
307
+ *
308
+ * @param Varien_Event_Observer $observer observer
309
+ * @return $this|bool
310
+ */
311
+ public function gravityCustomerRegistration(Varien_Event_Observer $observer)
312
+ {
313
+ if (!$this->_getGravityHelper()->isFullyEnabled() || !$this->_getGravityHelper()->getCustomerRegisterEnabled()) {
314
+ return false;
315
+ }
316
+
317
+ try {
318
+
319
+ $customer = $observer->getCustomer();
320
+ if (!is_null($customer) && $customer->getId()) {
321
+
322
+ $parameters = array(
323
+ 'type' => Me_Gravity_Model_Method_Request::EVENT_TYPE_CUSTOMER_UPDATE,
324
+ 'userid' => $customer->getId(),
325
+ 'email' => $customer->getEmail(),
326
+ 'firstname' => $customer->getFirstname(),
327
+ 'lastname' => $customer->getLastname()
328
+ );
329
+
330
+ Mage::getModel('me_gravity/method_request')->sendRequest(
331
+ Me_Gravity_Model_Method_Request::EVENT_TYPE_UPDATE,
332
+ $parameters
333
+ );
334
+
335
+ }
336
+
337
+ } catch (Mage_Core_Exception $e) {
338
+ $this->_getGravityHelper()->getLogger($e->getMessage());
339
+ } catch (Exception $e) {
340
+ $this->_getGravityHelper()->getLogger(
341
+ $e->getMessage(),
342
+ $this->_getGravityHelper()->__('An error occurred while sending customer register event to Gravity.')
343
+ );
344
+ }
345
+
346
+ return $this;
347
+ }
348
+
349
+ /**
350
+ * Gravity product update event observer
351
+ *
352
+ * @param Varien_Event_Observer $observer observer
353
+ * @return $this
354
+ */
355
+ public function gravityProductUpdate(Varien_Event_Observer $observer)
356
+ {
357
+ if (!$this->_getGravityHelper()->isFullyEnabled() || !$this->_getGravityHelper()->getProductUpdateEnabled()) {
358
+ return false;
359
+ }
360
+
361
+ try {
362
+ $storeId = Mage::app()->getDefaultStoreView()->getId();
363
+ $product = $observer->getProduct();
364
+ if (!is_null($product) && $product->getId()) {
365
+
366
+ $baseUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
367
+ $exportModel = Mage::getModel('me_gravity/products');
368
+ $productUrl = htmlspecialchars($baseUrl . $product->getUrlPath());
369
+ $parameters = array(
370
+ 'type' => Me_Gravity_Model_Method_Request::EVENT_TYPE_PRODUCT_UPDATE,
371
+ 'itemid' => $product->getId(),
372
+ 'title' => htmlspecialchars($product->getName()),
373
+ 'hidden' => ($product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE) ? 'true' : 'false',
374
+ 'link' => $productUrl ? $productUrl : $product->getProductUrl(),
375
+ 'image_link' => htmlspecialchars($this->_getCatalogBaseMediaUrl() . $product->getImage()),
376
+ 'description' => htmlspecialchars($product->getDescription()),
377
+ 'price' => $product->getFinalPrice(),
378
+ 'categoryPath' => $exportModel->getCategoryPath($product->getCategoryIds()),
379
+ 'categoryId' => implode($product->getCategoryIds())
380
+ );
381
+
382
+ $additionalParameters = $exportModel->getAdditionalAttributesXml($product, false);
383
+ if ($additionalParameters) {
384
+ $parameters = array_merge($parameters, $additionalParameters);
385
+ }
386
+
387
+ Mage::getModel('me_gravity/method_request')->sendRequest(
388
+ Me_Gravity_Model_Method_Request::EVENT_TYPE_UPDATE,
389
+ $parameters
390
+ );
391
+
392
+ }
393
+
394
+ } catch (Mage_Core_Exception $e) {
395
+ $this->_getGravityHelper()->getLogger($e->getMessage());
396
+ } catch (Exception $e) {
397
+ $this->_getGravityHelper()->getLogger(
398
+ $e->getMessage(),
399
+ $this->_getGravityHelper()->__('An error occurred while sending product update event to Gravity.')
400
+ );
401
+ }
402
+
403
+ return $this;
404
+ }
405
+
406
+ /**
407
+ * Set general page boxes
408
+ *
409
+ * @param Mage_Core_Model_Layout $layout layout
410
+ * @return void
411
+ */
412
+ protected function _setGeneralBoxes($layout)
413
+ {
414
+ $boxHelper = $this->_getGravityBoxHelper();
415
+
416
+ $boxNames = array(
417
+ 'best',
418
+ 'history',
419
+ 'others',
420
+ 'popular'
421
+ );
422
+
423
+ foreach ($boxNames as $name) {
424
+
425
+ if ($boxHelper->getBoxEnabled($name, 'general')) {
426
+
427
+ $block = $layout->createBlock('me_gravity/general_boxes_' . $name)
428
+ ->setName('me.gravity.general.' . $name);
429
+
430
+ if (Me_Gravity_Model_System_Config_Source_Layout_Layout::LAYOUT_CONTENT == $boxHelper->getBoxLayout($name, 'general')) {
431
+ $block->setTemplate('me/gravity/general/boxes/default.phtml');
432
+ if ($reference = $layout->getBlock(Me_Gravity_Model_System_Config_Source_Layout_Layout::LAYOUT_CONTENT)) {
433
+ $reference->append($block);
434
+ }
435
+ } else {
436
+ $block->setTemplate('me/gravity/general/boxes/sidebar.phtml');
437
+ if ($reference = $layout->getBlock($boxHelper->getBoxLayout($name, 'general'))) {
438
+ $reference->append($block);
439
+ }
440
+ }
441
+ }
442
+
443
+ }
444
+ }
445
+
446
+ /**
447
+ * Set category page boxes
448
+ *
449
+ * @param Mage_Core_Model_Layout $layout layout
450
+ * @return void
451
+ */
452
+ protected function _setCategoryPageBoxes($layout)
453
+ {
454
+ $boxHelper = $this->_getGravityBoxHelper();
455
+
456
+ $boxNames = array(
457
+ 'personal',
458
+ 'top'
459
+ );
460
+
461
+ foreach ($boxNames as $name) {
462
+
463
+ if ($boxHelper->getBoxEnabled($name, 'category')) {
464
+
465
+ $block = $layout->createBlock('me_gravity/catalog_category_boxes_' . $name)
466
+ ->setName('me.gravity.category.' . $name);
467
+
468
+ if (Me_Gravity_Model_System_Config_Source_Layout_Layout::LAYOUT_CONTENT == $boxHelper->getBoxLayout($name, 'category')) {
469
+ $block->setTemplate('me/gravity/catalog/category/boxes/default.phtml');
470
+ if ($reference = $layout->getBlock(Me_Gravity_Model_System_Config_Source_Layout_Layout::LAYOUT_CONTENT)) {
471
+ $reference->append($block);
472
+ }
473
+ } else {
474
+ $block->setTemplate('me/gravity/catalog/category/boxes/sidebar.phtml');
475
+ if ($reference = $layout->getBlock($boxHelper->getBoxLayout($name, 'category'))) {
476
+ $reference->append($block);
477
+ }
478
+ }
479
+ }
480
+
481
+ }
482
+ }
483
+
484
+ /**
485
+ * Set product page boxes
486
+ *
487
+ * @param Mage_Core_Model_Layout $layout layout
488
+ * @return void
489
+ */
490
+ protected function _setProductPageBoxes($layout)
491
+ {
492
+ $boxHelper = $this->_getGravityBoxHelper();
493
+
494
+ $boxNames = array(
495
+ 'similar',
496
+ 'personal',
497
+ 'accessories'
498
+ );
499
+
500
+ foreach ($boxNames as $name) {
501
+
502
+ if ($boxHelper->getBoxEnabled($name, 'product')) {
503
+ $block = $layout->createBlock('me_gravity/catalog_product_view_boxes_' . $name)
504
+ ->setName('me.gravity.product.view.' . $name);
505
+ if (Me_Gravity_Model_System_Config_Source_Layout_Layout::LAYOUT_CONTENT == $boxHelper->getBoxLayout($name, 'product')) {
506
+ $block->setTemplate('me/gravity/catalog/product/view/boxes/default.phtml');
507
+ if ($reference = $layout->getBlock(Me_Gravity_Model_System_Config_Source_Layout_Layout::LAYOUT_CONTENT)) {
508
+ $reference->append($block);
509
+ }
510
+ } else {
511
+ $block->setTemplate('me/gravity/catalog/product/view/boxes/sidebar.phtml');
512
+ if ($reference = $layout->getBlock($boxHelper->getBoxLayout($name, 'product'))) {
513
+ $reference->append($block);
514
+ }
515
+ }
516
+ }
517
+
518
+ }
519
+ }
520
+
521
+ /**
522
+ * Set search result page box
523
+ *
524
+ * @param Mage_Core_Model_Layout $layout layout
525
+ * @return void
526
+ */
527
+ protected function _setSearchResultBox($layout)
528
+ {
529
+ $boxHelper = $this->_getGravityBoxHelper();
530
+
531
+ if ($boxHelper->getBoxEnabled('search', 'search')) {
532
+
533
+ $block = $layout->createBlock('me_gravity/catalogsearch_boxes_result')
534
+ ->setName('me.gravity.catalogsearch.result');
535
+
536
+ if (Me_Gravity_Model_System_Config_Source_Layout_Layout::LAYOUT_CONTENT == $boxHelper->getBoxLayout('search', 'search')) {
537
+ $block->setTemplate('me/gravity/catalogsearch/boxes/default.phtml');
538
+ if ($reference = $layout->getBlock(Me_Gravity_Model_System_Config_Source_Layout_Layout::LAYOUT_CONTENT)) {
539
+ $reference->append($block);
540
+ }
541
+ } else {
542
+ $block->setTemplate('me/gravity/catalogsearch/boxes/sidebar.phtml');
543
+ if ($reference = $layout->getBlock($boxHelper->getBoxLayout('search', 'search'))) {
544
+ $reference->append($block);
545
+ }
546
+ }
547
+ }
548
+ }
549
+
550
+ /**
551
+ * Set cart page box
552
+ *
553
+ * @param Mage_Core_Model_Layout $layout layout
554
+ * @return void
555
+ */
556
+ protected function _setCartPageBox($layout)
557
+ {
558
+ $boxHelper = $this->_getGravityBoxHelper();
559
+
560
+ if ($boxHelper->getBoxEnabled('cart', 'cart')) {
561
+
562
+ $block = $layout->createBlock('me_gravity/checkout_cart_boxes_cart')
563
+ ->setName('me.gravity.checkout.cart');
564
+
565
+ if (Me_Gravity_Model_System_Config_Source_Layout_Layout::LAYOUT_CONTENT == $boxHelper->getBoxLayout('cart', 'cart')) {
566
+ $block->setTemplate('me/gravity/checkout/cart/boxes/default.phtml');
567
+ if ($reference = $layout->getBlock(Me_Gravity_Model_System_Config_Source_Layout_Layout::LAYOUT_CONTENT)) {
568
+ $reference->append($block);
569
+ }
570
+ } else {
571
+ $block->setTemplate('me/gravity/checkout/cart/boxes/boxes/sidebar.phtml');
572
+ if ($reference = $layout->getBlock($boxHelper->getBoxLayout('cart', 'cart'))) {
573
+ $reference->append($block);
574
+ }
575
+ }
576
+ }
577
+ }
578
+
579
+ /**
580
+ * Schedule catalog export
581
+ *
582
+ * @return void|boolean
583
+ */
584
+ public function scheduledExport()
585
+ {
586
+ $gravityHelper = $this->_getGravityHelper();
587
+
588
+ try {
589
+
590
+ $currentStore = Mage::app()->getStore()->getCode();
591
+ $gravityHelper->getLogger('$currentStore: ' . $currentStore);
592
+ Mage::app()->setCurrentStore('admin');
593
+
594
+ foreach (Mage::app()->getStores() as $store) {
595
+
596
+ if (!$gravityHelper->isEnabled($store->getId())) {
597
+ continue;
598
+ }
599
+
600
+ $filename = Mage::getModel('me_gravity/products')->generateCatalogXml($store->getId());
601
+ if ($filename) {
602
+ $gravityHelper->getLogger($gravityHelper->__('Store Id: %s exported to %s', $store->getId(), $filename));
603
+ } else {
604
+ $gravityHelper->getLogger($gravityHelper->__('Store Id: %s exported error', $store->getId()));
605
+ }
606
+ }
607
+
608
+ Mage::app()->setCurrentStore($currentStore);
609
+
610
+ } catch (Mage_Core_Exception $e) {
611
+ $gravityHelper->getLogger($e->getMessage());
612
+ } catch (Exception $e) {
613
+ $gravityHelper->getLogger(
614
+ $e->getMessage(),
615
+ $gravityHelper->__('An error occurred while exporting products')
616
+ );
617
+ }
618
+ }
619
+
620
+ /**
621
+ * Retrieve Gravity boxes helper
622
+ *
623
+ * @return Me_Gravity_Helper_Boxes
624
+ */
625
+ protected function _getGravityBoxHelper()
626
+ {
627
+ return Mage::helper('me_gravity/boxes');
628
+ }
629
+
630
+ /**
631
+ * Retrieve Gravity extension helper
632
+ *
633
+ * @return Me_Gravity_Helper_Data
634
+ */
635
+ protected function _getGravityHelper()
636
+ {
637
+ return Mage::helper('me_gravity');
638
+ }
639
+
640
+ /**
641
+ * Web-based directory path of product images
642
+ *
643
+ * @return string
644
+ */
645
+ protected function _getCatalogBaseMediaUrl()
646
+ {
647
+ return Mage::getBaseUrl('media') . Mage::getSingleton('catalog/product_media_config')->getBaseMediaUrlAddition();
648
+ }
649
+
650
+ /**
651
+ * Get store home page
652
+ *
653
+ * @param integer|string|Mage_Core_Model_Store $store store
654
+ * @return string
655
+ */
656
+ protected function _getHomePagePath($store = null)
657
+ {
658
+ return Mage::getStoreConfig('web/default/cms_home_page', $store);
659
+ }
660
+ }
app/code/community/Me/Gravity/Model/Products.php ADDED
@@ -0,0 +1,289 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Model_Products
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Model_Products
15
+ */
16
+ class Me_Gravity_Model_Products extends Me_Gravity_Model_Export_Catalog_Product
17
+ {
18
+ /**
19
+ * Path to store config catalog export file save path
20
+ *
21
+ * @var string
22
+ */
23
+ const XML_CATALOG_EXPORT_PATH = 'gravity/export/catalog_path';
24
+
25
+ /**
26
+ * Real file path
27
+ *
28
+ * @var string
29
+ */
30
+ protected $_filePath;
31
+
32
+ /**
33
+ * Generate product catalog xml
34
+ *
35
+ * @param int $storeId store id
36
+ * @throws Mage_Core_Exception
37
+ * @return string
38
+ */
39
+ public function generateCatalogXml($storeId = 0)
40
+ {
41
+ $this->_validatePath($storeId);
42
+
43
+ $baseUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
44
+
45
+ $io = new Varien_Io_File();
46
+ $io->setAllowCreateFolders(true);
47
+ $io->open(array('path' => $this->_getCatalogExportPath()));
48
+
49
+ if ($io->fileExists($this->_getGravityCatalogFilename($storeId)) && !$io->isWriteable($this->_getGravityCatalogFilename($storeId))) {
50
+ Mage::throwException(
51
+ Mage::helper('me_gravity')->__(
52
+ 'File "%s" cannot be saved. Please, make sure the directory "%s" is writeable by web server.',
53
+ $this->_getGravityCatalogFilename($storeId),
54
+ $this->_getCatalogExportPath()
55
+ )
56
+ );
57
+ }
58
+
59
+ $io->streamOpen($this->_getGravityCatalogFilename($storeId));
60
+
61
+ $io->streamWrite('<?xml version="1.0"?>' . "\n");
62
+ $io->streamWrite('<rss version="2.0" xmlns:g="http://base.google.com/ns/1.0" xmlns:c="http://base.google.com/cns/1.0">');
63
+ $io->streamWrite('<channel>');
64
+ $io->streamWrite('<title>' . Mage::app()->getStore($storeId)->getFrontendName() . ' Gravity Reco item catalog</title>');
65
+ $io->streamWrite('<link>' . $baseUrl . '</link>');
66
+ $io->streamWrite('<description>' . Mage::app()->getStore($storeId)->getFrontendName() . ' item catalog description</description>');
67
+
68
+ $productCollection = $this->getProductCollection($storeId);
69
+
70
+ if ($productCollection->count()) {
71
+
72
+ foreach ($productCollection as $product) {
73
+
74
+ $xml = sprintf(
75
+ '<item><g:id>%s</g:id><title>%s</title><c:hidden>%s</c:hidden><link>%s</link><g:image_link>%s</g:image_link><c:description>%s</c:description><g:price>%.4f</g:price>%s%s</item>',
76
+ $product->getId(),
77
+ htmlspecialchars($product->getName()),
78
+ ($product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE) ? 'true' : 'false',
79
+ htmlspecialchars($baseUrl . $product->getUrlPath()),
80
+ htmlspecialchars($this->_getCatalogBaseMediaUrl() . $product->getImage()),
81
+ htmlspecialchars($product->getDescription()),
82
+ $product->getFinalPrice(),
83
+ $this->_getCategoryXml($product),
84
+ $this->getAdditionalAttributesXml($product)
85
+ );
86
+ $io->streamWrite($xml);
87
+ }
88
+
89
+ }
90
+
91
+ $io->streamWrite('</channel>');
92
+ $io->streamWrite('</rss>');
93
+ $io->streamClose();
94
+
95
+ return $this->_getGravityCatalogFilename($storeId);
96
+ }
97
+
98
+ /**
99
+ * Get category information XML part
100
+ *
101
+ * @param Mage_Catalog_Model_Product $product object
102
+ * @return string
103
+ */
104
+ protected function _getCategoryXml(Mage_Catalog_Model_Product $product)
105
+ {
106
+ $categoryXml = '';
107
+ $categoryPath = $this->getCategoryPath($product->getCategoryIds());
108
+
109
+ if ($categoryPath) {
110
+ $categoryXml = sprintf(
111
+ '<c:categoryPath>%s</c:categoryPath><c:categoryId>%s</c:categoryId>',
112
+ htmlspecialchars($categoryPath),
113
+ implode($product->getCategoryIds())
114
+ );
115
+ }
116
+
117
+ return $categoryXml;
118
+ }
119
+
120
+ /**
121
+ * Get category path by category ids
122
+ *
123
+ * @param array $categoryIds category ids
124
+ * @return string
125
+ */
126
+ public function getCategoryPath($categoryIds)
127
+ {
128
+ $categoryPath = array();
129
+
130
+ if ($categoryIds) {
131
+
132
+ foreach ($categoryIds as $categoryId) {
133
+ if (array_key_exists($categoryId, $this->_categories)) {
134
+ $categoryPath[] = $this->_categories[$categoryId];
135
+ }
136
+ }
137
+
138
+ }
139
+
140
+ return implode(',', $categoryPath);
141
+ }
142
+
143
+ /**
144
+ * Get additional product attributes XML
145
+ *
146
+ * @param Mage_Catalog_Model_Product $product product
147
+ * @param boolean $asXml as xml
148
+ * @return string|array
149
+ */
150
+ public function getAdditionalAttributesXml(Mage_Catalog_Model_Product $product, $asXml = true)
151
+ {
152
+ $additionalXml = '';
153
+
154
+ if (!empty($this->_attributeValues)) {
155
+
156
+ foreach ($this->_attributeValues as $attributeCode => $attributeValues) {
157
+
158
+ $additionalValues = array();
159
+ $productValue = $product->getData($attributeCode);
160
+ if ($productValue) {
161
+
162
+ if (is_array($productValue)) {
163
+ foreach ($productValue as $optionId) {
164
+ if (array_key_exists($optionId, $this->_attributeValues[$attributeCode])) {
165
+ $additionalValues[] = $this->_attributeValues[$attributeCode][$optionId];
166
+ }
167
+ }
168
+ } else {
169
+ if (array_key_exists($productValue, $this->_attributeValues[$attributeCode])) {
170
+ $additionalValues[] = $this->_attributeValues[$attributeCode][$productValue];
171
+ } else {
172
+
173
+ $additionalValues[] = $productValue;
174
+
175
+ }
176
+ }
177
+
178
+ if (!empty($additionalValues)) {
179
+
180
+ if ($asXml) {
181
+ $additionalXml .= sprintf(
182
+ '<' . $attributeCode . '>%s</' . $attributeCode . '>',
183
+ htmlspecialchars(implode(',', $additionalValues))
184
+ );
185
+ } else {
186
+ $additionalXml[$attributeCode] = htmlspecialchars(implode(',', $additionalValues));
187
+ }
188
+
189
+ }
190
+
191
+ }
192
+
193
+ }
194
+
195
+ }
196
+
197
+ return $additionalXml;
198
+ }
199
+
200
+ /**
201
+ * Return real file path
202
+ *
203
+ * @return string
204
+ */
205
+ protected function _getCatalogExportPath()
206
+ {
207
+ if (is_null($this->_filePath)) {
208
+ $this->_filePath = str_replace('//', '/', Mage::getBaseDir() . DS . $this->_getCatalogFilePath());
209
+ }
210
+ return $this->_filePath;
211
+ }
212
+
213
+ /**
214
+ * Validate catalog export file save path
215
+ *
216
+ * @param int $storeId store id
217
+ * @throws Mage_Core_Exception
218
+ * @return void
219
+ */
220
+ protected function _validatePath($storeId)
221
+ {
222
+ $io = new Varien_Io_File();
223
+ $realPath = $io->getCleanPath(Mage::getBaseDir() . '/' . $this->_getCatalogFilePath());
224
+
225
+ /**
226
+ * Check path is allow
227
+ */
228
+ if (!$io->allowedPath($realPath, Mage::getBaseDir())) {
229
+ Mage::throwException($this->_helper->__('Please define correct path'));
230
+ }
231
+ /**
232
+ * Check exists and writeable path
233
+ */
234
+ if (!$io->fileExists($realPath, false)) {
235
+ Mage::throwException(
236
+ $this->_helper->__(
237
+ 'Please create the specified folder "%s" before saving the sitemap.',
238
+ Mage::helper('core')->escapeHtml($this->_getCatalogFilePath())
239
+ )
240
+ );
241
+ }
242
+
243
+ if (!$io->isWriteable($realPath)) {
244
+ Mage::throwException($this->_helper->__('Please make sure that "%s" is writable by web-server.', $this->_getCatalogFilePath()));
245
+ }
246
+ /**
247
+ * Check allow filename
248
+ */
249
+ if (!preg_match('#^[a-zA-Z0-9_\.]+$#', $this->_getGravityCatalogFilename($storeId))) {
250
+ Mage::throwException(
251
+ $this->_helper->__(
252
+ 'Please use only letters (a-z or A-Z), numbers (0-9) or underscore (_) in the filename. No spaces or other characters are allowed.'
253
+ )
254
+ );
255
+ }
256
+ }
257
+
258
+ /**
259
+ * Get catalog export filename
260
+ *
261
+ * @param int $storeId store id
262
+ * @return string
263
+ */
264
+ protected function _getGravityCatalogFilename($storeId)
265
+ {
266
+ return 'gravity_' . $storeId . '.xml';
267
+ }
268
+
269
+ /**
270
+ * Web-based directory path of product images
271
+ *
272
+ * @return string
273
+ */
274
+ protected function _getCatalogBaseMediaUrl()
275
+ {
276
+ return Mage::getBaseUrl('media') . Mage::getSingleton('catalog/product_media_config')->getBaseMediaUrlAddition();
277
+ }
278
+
279
+ /**
280
+ * Get catalog export file path
281
+ *
282
+ * @param integer|string|Mage_Core_Model_Store $store store
283
+ * @return bool
284
+ */
285
+ private function _getCatalogFilePath($store = null)
286
+ {
287
+ return Mage::getStoreConfig(self::XML_CATALOG_EXPORT_PATH, $store);
288
+ }
289
+ }
app/code/community/Me/Gravity/Model/System/Config/Backend/Catalog/Cron.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Model_System_Config_Backend_Catalog_Cron
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Model_System_Config_Backend_Catalog_Cron
15
+ */
16
+ class Me_Gravity_Model_System_Config_Backend_Catalog_Cron extends Mage_Core_Model_Config_Data
17
+ {
18
+ /**
19
+ * Path to store config cron job schedule time
20
+ *
21
+ * @var string
22
+ */
23
+ const CRON_STRING_PATH = 'crontab/jobs/me_gravity_catalog_generate/schedule/cron_expr';
24
+
25
+ /**
26
+ * Path to store config catalog export cron model
27
+ *
28
+ * @var string
29
+ */
30
+ const CRON_MODEL_PATH = 'crontab/jobs/me_gravity_catalog_generate/run/model';
31
+
32
+ /**
33
+ * Set cron expression after config save
34
+ *
35
+ * @return Mage_Core_Model_Abstract|void
36
+ * @throws Exception
37
+ */
38
+ protected function _afterSave()
39
+ {
40
+ $enabled = $this->getData('groups/export/fields/catalog_cron/value');
41
+
42
+ if ($enabled) {
43
+
44
+ $time = $this->getData('groups/export/fields/catalog_cron_time/value');
45
+
46
+ $cronExprArray = array(
47
+ intval($time[1]), // Minute
48
+ intval($time[0]), // Hour
49
+ '*', // Day of the Month
50
+ '*', // Month of the Year
51
+ '*', // Day of the Week
52
+ );
53
+
54
+ $cronExprString = join(' ', $cronExprArray);
55
+
56
+ try {
57
+ Mage::getModel('core/config_data')
58
+ ->load(self::CRON_STRING_PATH, 'path')
59
+ ->setValue($cronExprString)
60
+ ->setPath(self::CRON_STRING_PATH)
61
+ ->save();
62
+ Mage::getModel('core/config_data')
63
+ ->load(self::CRON_MODEL_PATH, 'path')
64
+ ->setValue((string)Mage::getConfig()->getNode(self::CRON_MODEL_PATH))
65
+ ->setPath(self::CRON_MODEL_PATH)
66
+ ->save();
67
+ } catch (Exception $e) {
68
+ throw new Exception(Mage::helper('me_gravity')->__('Unable to save the cron catalog export expression.'));
69
+ }
70
+
71
+ }
72
+ }
73
+ }
app/code/community/Me/Gravity/Model/System/Config/Source/Catalog/Attributes.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Model_System_Config_Source_Catalog_Attributes
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Model_System_Config_Source_Catalog_Attributes
15
+ */
16
+ class Me_Gravity_Model_System_Config_Source_Catalog_Attributes
17
+ {
18
+ /**
19
+ * Retrieve option values array
20
+ *
21
+ * @return array
22
+ */
23
+ public function toOptionArray()
24
+ {
25
+ $options = array();
26
+
27
+ $exportDefault = Mage::getModel('me_gravity/export_catalog_product');
28
+ $options[] = array('label' => '', 'value' => '');
29
+ foreach ($exportDefault->getAttributeCollection() as $attribute) {
30
+
31
+ if (!in_array($attribute->getFrontendInput(), $exportDefault->getExcludedAttributeTypes())
32
+ && !in_array($attribute->getAttributeCode(), $exportDefault->getExportAttrCodes())
33
+ && !in_array($attribute->getAttributeCode(), $exportDefault->getExcludeAttributeCodes())
34
+ && $attribute->getFrontendInput()
35
+ && $attribute->getIsVisible()
36
+ ) {
37
+ $options[] = array(
38
+ 'label' => Mage::helper('catalog')->__($attribute['frontend_label']),
39
+ 'value' => $attribute['attribute_code']
40
+ );
41
+ }
42
+ }
43
+ return $options;
44
+ }
45
+ }
app/code/community/Me/Gravity/Model/System/Config/Source/Customer/Attributes.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Model_System_Config_Source_Customer_Attributes
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Model_System_Config_Source_Customer_Attributes
15
+ */
16
+ class Me_Gravity_Model_System_Config_Source_Customer_Attributes
17
+ {
18
+ /**
19
+ * Retrieve option values array
20
+ *
21
+ * @return array
22
+ */
23
+ public function toOptionArray()
24
+ {
25
+ $options = array();
26
+
27
+ $exportDefault = Mage::getModel('me_gravity/export_customer_customer');
28
+ $options[] = array('label' => '', 'value' => '');
29
+ foreach ($exportDefault->getCustomerAttributeCollection() as $attribute) {
30
+
31
+ if (!in_array($attribute->getFrontendInput(), $exportDefault->getExcludedAttributeTypes())
32
+ && !in_array($attribute->getAttributeCode(), $exportDefault->getExportAttrCodes())
33
+ && !in_array($attribute->getAttributeCode(), $exportDefault->getExcludeAttributeCodes())
34
+ && $attribute->getFrontendInput()
35
+ ) {
36
+ $options[] = array(
37
+ 'label' => Mage::helper('customer')->__($attribute['frontend_label']),
38
+ 'value' => $attribute['attribute_code']
39
+ );
40
+ }
41
+ }
42
+ return $options;
43
+ }
44
+ }
app/code/community/Me/Gravity/Model/System/Config/Source/Layout/Layout.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Model_System_Config_Source_Layout_Layout
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Model_System_Config_Source_Layout_Layout
15
+ */
16
+ class Me_Gravity_Model_System_Config_Source_Layout_Layout
17
+ {
18
+ /**
19
+ * var string
20
+ */
21
+ const LAYOUT_LEFT = 'left';
22
+
23
+ /**
24
+ * var string
25
+ */
26
+ const LAYOUT_CONTENT = 'content';
27
+
28
+ /**
29
+ * var string
30
+ */
31
+ const LAYOUT_RIGHT = 'right';
32
+
33
+
34
+ /**
35
+ * Layout option getter
36
+ *
37
+ * @return array
38
+ */
39
+ public function toOptionArray()
40
+ {
41
+ $_helper = $this->_getGravityHelper();
42
+
43
+ return array(
44
+ array('value' => self::LAYOUT_LEFT, 'label'=> $_helper->__('Left Sidebar')),
45
+ array('value' => self::LAYOUT_CONTENT, 'label'=> $_helper->__('Bottom of Content')),
46
+ array('value' => self::LAYOUT_RIGHT, 'label'=> $_helper->__('Right Sidebar'))
47
+ );
48
+ }
49
+
50
+ /**
51
+ * Retrieve Gravity extension helper
52
+ *
53
+ * @return Me_Gravity_Helper_Data
54
+ */
55
+ protected function _getGravityHelper()
56
+ {
57
+ return Mage::helper('me_gravity');
58
+ }
59
+ }
app/code/community/Me/Gravity/Model/System/Config/Source/Layout/Pages.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Model_System_Config_Source_Layout_Pages
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Model_System_Config_Source_Layout_Pages
15
+ */
16
+ class Me_Gravity_Model_System_Config_Source_Layout_Pages
17
+ {
18
+ /**
19
+ * Layout option getter
20
+ *
21
+ * @return array
22
+ */
23
+ public function toOptionArray()
24
+ {
25
+ $options = array();
26
+
27
+ $_helper = $this->_getGravityHelper();
28
+ $options[] = array('label' => '', 'value' => '');
29
+ $options = array_merge($options, Mage::getSingleton('adminhtml/system_config_source_cms_page')->toOptionArray());
30
+ $additionalOptions = array(
31
+ array('value' => 'customer_account_index', 'label'=> $_helper->__('Account Dashboard')),
32
+ array('value' => 'contacts_index_index', 'label'=> $_helper->__('Contact Us'))
33
+ );
34
+ $options = array_merge($options, $additionalOptions);
35
+
36
+ return $options;
37
+ }
38
+
39
+ /**
40
+ * Retrieve Gravity extension helper
41
+ *
42
+ * @return Me_Gravity_Helper_Data
43
+ */
44
+ protected function _getGravityHelper()
45
+ {
46
+ return Mage::helper('me_gravity');
47
+ }
48
+ }
app/code/community/Me/Gravity/controllers/Adminhtml/GravityController.php ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Adminhtml_GravityController
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+
13
+ /**
14
+ * Class Me_Gravity_Adminhtml_GravityController
15
+ */
16
+ class Me_Gravity_Adminhtml_GravityController extends Mage_Adminhtml_Controller_Action
17
+ {
18
+ /**
19
+ * Check access (in the ACL) for current user
20
+ *
21
+ * @return bool
22
+ */
23
+ protected function _isAllowed()
24
+ {
25
+ return Mage::getSingleton('admin/session')->isAllowed('system/config/gravity');
26
+ }
27
+
28
+ /**
29
+ * Export catalog action
30
+ *
31
+ * @return void
32
+ */
33
+ public function exportcatalogAction()
34
+ {
35
+ $store = $this->getRequest()->getParam('store');
36
+
37
+ try {
38
+ $storeId = Mage::app()->getStore($store)->getId();
39
+ $gravityHelper = $this->_getGravityHelper();
40
+
41
+ if (!$storeId) {
42
+ $storeId = Mage::app()->getDefaultStoreView()->getId();
43
+ }
44
+
45
+ $timeStart = microtime(true);
46
+ $resultFileName = Mage::getModel('me_gravity/products')->generateCatalogXml($storeId);
47
+ $timeEnd = microtime(true);
48
+
49
+ if ($gravityHelper->getDebugMode()) {
50
+ $gravityHelper->getLogger($this->_getGravityHelper()->__('Catalog export finished in %s seconds', $timeEnd - $timeStart));
51
+ }
52
+
53
+ $path = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK)
54
+ . $this->_getGravityHelper()->getExportFilePath() . $resultFileName;
55
+ $this->_getSession()->addSuccess(Mage::helper('me_gravity')->__('Catalog was successfully exported to %s.', $path));
56
+
57
+ } catch (Mage_Core_Exception $e) {
58
+
59
+ $this->_getSession()->addError($e->getMessage());
60
+
61
+ } catch (Exception $e) {
62
+
63
+ $this->_getSession()->addException(
64
+ $e,
65
+ $this->_getGravityHelper()->__('An error occurred while exporting catalog.')
66
+ );
67
+
68
+ }
69
+
70
+ $this->_redirectReferer();
71
+ }
72
+
73
+ /**
74
+ * Customers export action
75
+ *
76
+ * @return void
77
+ */
78
+ public function exportcustomerAction()
79
+ {
80
+ $store = $this->getRequest()->getParam('store');
81
+
82
+ try {
83
+ $storeId = Mage::app()->getStore($store)->getId();
84
+ $gravityHelper = $this->_getGravityHelper();
85
+
86
+ if (!$storeId) {
87
+ $storeId = Mage::app()->getDefaultStoreView()->getId();
88
+ }
89
+
90
+ $timeStart = microtime(true);
91
+
92
+ $fileName = 'gravity_customers.tsv';
93
+ $tsvFile = Mage::getModel('me_gravity/customers')->generateCustomersTsv($storeId);
94
+
95
+ $timeEnd = microtime(true);
96
+
97
+ if ($gravityHelper->getDebugMode()) {
98
+ $gravityHelper->getLogger($this->_getGravityHelper()->__('Customer export finished in %s seconds', $timeEnd - $timeStart));
99
+ }
100
+
101
+ $this->_prepareDownloadResponse($fileName, $tsvFile);
102
+
103
+ } catch (Mage_Core_Exception $e) {
104
+
105
+ $this->_getSession()->addError($e->getMessage());
106
+
107
+ } catch (Exception $e) {
108
+
109
+ $this->_getSession()->addException(
110
+ $e,
111
+ $this->_getGravityHelper()->__('An error occurred while exporting customers.')
112
+ );
113
+
114
+ }
115
+
116
+ $this->_redirectReferer();
117
+ }
118
+
119
+ /**
120
+ * Test connection action
121
+ *
122
+ * @return void
123
+ */
124
+ public function testAction()
125
+ {
126
+ $result = array(
127
+ 'success' => 0,
128
+ 'message' => ''
129
+ );
130
+
131
+ try {
132
+
133
+ $answer = Mage::getModel('me_gravity/method_request')->sendRequest(Me_Gravity_Model_Method_Request::EVENT_TYPE_TEST);
134
+ if ('Hello ' . $this->_getGravityHelper()->getApiUser() == $answer) {
135
+ $result['success'] = 1;
136
+ $result['message'] = $this->_getGravityHelper()->__('Connection successfully tested!');
137
+ }
138
+
139
+ } catch (Mage_Core_Exception $e) {
140
+
141
+ $result['message'] = $e->getMessage() . ' ' . $this->_getGravityHelper()->__('Connection test failed. The Page will reload automatically!');
142
+ $this->_getGravityHelper()->getLogger($e->getMessage());
143
+
144
+ } catch (Exception $e) {
145
+
146
+ $result['message'] = $this->_getGravityHelper()->__('An error occurred while testing connection. The Page will reload automatically!');
147
+ $this->_getGravityHelper()->getLogger($e);
148
+
149
+ }
150
+
151
+ Mage::app()->getResponse()->setBody(json_encode($result));
152
+ }
153
+
154
+ /**
155
+ * Get Gravity extension helper
156
+ *
157
+ * @return Me_Gravity_Helper_Data
158
+ */
159
+ protected function _getGravityHelper()
160
+ {
161
+ return Mage::helper('me_gravity');
162
+ }
163
+ }
app/code/community/Me/Gravity/etc/adminhtml.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Me
5
+ * @package Me_Gravity
6
+ * @author Attila Sági <sagi.attila@magevolve.com>
7
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
8
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
9
+ * @link http://magevolve.com
10
+ */
11
+ -->
12
+ <config>
13
+ <acl>
14
+ <resources>
15
+ <admin>
16
+ <children>
17
+ <system>
18
+ <children>
19
+ <config>
20
+ <children>
21
+ <gravity translate="title" module="me_gravity">
22
+ <title>Magevolve Gravity Reco Extension</title>
23
+ </gravity>
24
+ </children>
25
+ </config>
26
+ </children>
27
+ </system>
28
+ </children>
29
+ </admin>
30
+ </resources>
31
+ </acl>
32
+ </config>
app/code/community/Me/Gravity/etc/config.xml ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Me
5
+ * @package Me_Gravity
6
+ * @author Attila Sági <sagi.attila@magevolve.com>
7
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
8
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
9
+ * @link http://magevolve.com
10
+ */
11
+ -->
12
+ <config>
13
+ <modules>
14
+ <Me_Gravity>
15
+ <version>1.0.0.0</version>
16
+ </Me_Gravity>
17
+ </modules>
18
+ <global>
19
+ <models>
20
+ <me_gravity>
21
+ <class>Me_Gravity_Model</class>
22
+ <resourceModel>gravity_resource</resourceModel>
23
+ </me_gravity>
24
+ </models>
25
+ <helpers>
26
+ <me_gravity>
27
+ <class>Me_Gravity_Helper</class>
28
+ </me_gravity>
29
+ </helpers>
30
+ <blocks>
31
+ <me_gravity>
32
+ <class>Me_Gravity_Block</class>
33
+ </me_gravity>
34
+ </blocks>
35
+ </global>
36
+ <frontend>
37
+ <layout>
38
+ <updates>
39
+ <me_gravity>
40
+ <file>me/gravity.xml</file>
41
+ </me_gravity>
42
+ </updates>
43
+ </layout>
44
+ <events>
45
+ <controller_action_layout_generate_blocks_after>
46
+ <observers>
47
+ <me_gravity_set_handle>
48
+ <class>me_gravity/observer</class>
49
+ <method>setGravityProductBlock</method>
50
+ </me_gravity_set_handle>
51
+ </observers>
52
+ </controller_action_layout_generate_blocks_after>
53
+ <sales_quote_remove_item>
54
+ <observers>
55
+ <me_gravity_remove_from_cart_after>
56
+ <class>me_gravity/observer</class>
57
+ <method>gravityRemoveFromCart</method>
58
+ </me_gravity_remove_from_cart_after>
59
+ </observers>
60
+ </sales_quote_remove_item>
61
+ <checkout_cart_product_add_after>
62
+ <observers>
63
+ <me_gravity_add_to_cart_after>
64
+ <class>me_gravity/observer</class>
65
+ <method>gravityAddToCart</method>
66
+ </me_gravity_add_to_cart_after>
67
+ </observers>
68
+ </checkout_cart_product_add_after>
69
+ <checkout_cart_update_items_before>
70
+ <observers>
71
+ <me_gravity_update_cart_after>
72
+ <class>me_gravity/observer</class>
73
+ <method>gravityUpdateCart</method>
74
+ </me_gravity_update_cart_after>
75
+ </observers>
76
+ </checkout_cart_update_items_before>
77
+ <sales_order_place_after>
78
+ <observers>
79
+ <me_gravity_order_place_after>
80
+ <class>me_gravity/observer</class>
81
+ <method>gravitySendBuy</method>
82
+ </me_gravity_order_place_after>
83
+ </observers>
84
+ </sales_order_place_after>
85
+ <customer_register_success>
86
+ <observers>
87
+ <me_gravity_customer_register_after>
88
+ <class>me_gravity/observer</class>
89
+ <method>gravityCustomerRegistration</method>
90
+ </me_gravity_customer_register_after>
91
+ </observers>
92
+ </customer_register_success>
93
+ </events>
94
+ </frontend>
95
+ <admin>
96
+ <routers>
97
+ <adminhtml>
98
+ <args>
99
+ <modules>
100
+ <Me_Gravity before="Mage_Adminhtml">Me_Gravity_Adminhtml</Me_Gravity>
101
+ </modules>
102
+ </args>
103
+ </adminhtml>
104
+ </routers>
105
+ </admin>
106
+ <adminhtml>
107
+ <layout>
108
+ <updates>
109
+ <me_gravity>
110
+ <file>me/gravity.xml</file>
111
+ </me_gravity>
112
+ </updates>
113
+ </layout>
114
+ <translate>
115
+ <modules>
116
+ <Me_Gravity>
117
+ <files>
118
+ <default>Me_Gravity.csv</default>
119
+ </files>
120
+ </Me_Gravity>
121
+ </modules>
122
+ </translate>
123
+ <events>
124
+ <customer_save_after>
125
+ <observers>
126
+ <me_gravity_customer_save_after>
127
+ <class>me_gravity/observer</class>
128
+ <method>gravityUserUpdate</method>
129
+ </me_gravity_customer_save_after>
130
+ </observers>
131
+ </customer_save_after>
132
+ <catalog_product_save_after>
133
+ <observers>
134
+ <me_gravity_product_save_after>
135
+ <class>me_gravity/observer</class>
136
+ <method>gravityProductUpdate</method>
137
+ </me_gravity_product_save_after>
138
+ </observers>
139
+ </catalog_product_save_after>
140
+ </events>
141
+ </adminhtml>
142
+ <crontab>
143
+ <jobs>
144
+ <me_gravity_catalog_generate>
145
+ <run>
146
+ <model>me_gravity/observer::scheduledExport</model>
147
+ </run>
148
+ </me_gravity_catalog_generate>
149
+ </jobs>
150
+ </crontab>
151
+ <default>
152
+ <gravity>
153
+ <config>
154
+ <enabled>0</enabled>
155
+ <preview>1</preview>
156
+ <template>0</template>
157
+ </config>
158
+ <export>
159
+ <catalog_path>gravity_reco/</catalog_path>
160
+ <all>0</all>
161
+ <max>1000</max>
162
+ <only_salable>1</only_salable>
163
+ <catalog_cron>0</catalog_cron>
164
+ <catalog_cron_time>02,30,00</catalog_cron_time>
165
+ </export>
166
+ <cutomer_export>
167
+ <all>0</all>
168
+ <max>1000</max>
169
+ </cutomer_export>
170
+ <general_display>
171
+ <best_box>0</best_box>
172
+ <best_box_layout>content</best_box_layout>
173
+ <best_box_title>Recommended for you</best_box_title>
174
+ <best_box_limit>4</best_box_limit>
175
+ <best_box_columns>4</best_box_columns>
176
+ <history_box>0</history_box>
177
+ <history_box_layout>content</history_box_layout>
178
+ <history_box_title>You viewed</history_box_title>
179
+ <history_box_limit>4</history_box_limit>
180
+ <history_box_columns>4</history_box_columns>
181
+ <others_box>0</others_box>
182
+ <others_box_layout>content</others_box_layout>
183
+ <others_box_title>Others are looking at right now</others_box_title>
184
+ <others_box_limit>4</others_box_limit>
185
+ <others_box_columns>4</others_box_columns>
186
+ <popular_box>0</popular_box>
187
+ <popular_box_layout>content</popular_box_layout>
188
+ <popular_box_title>Top products</popular_box_title>
189
+ <popular_box_limit>4</popular_box_limit>
190
+ <popular_box_columns>4</popular_box_columns>
191
+ </general_display>
192
+ <product_display>
193
+ <similar_box>0</similar_box>
194
+ <similar_box_layout>content</similar_box_layout>
195
+ <similar_box_title>You might also like</similar_box_title>
196
+ <similar_box_limit>4</similar_box_limit>
197
+ <similar_box_columns>4</similar_box_columns>
198
+ <personal_box>0</personal_box>
199
+ <personal_box_layout>content</personal_box_layout>
200
+ <personal_box_title>Recommended for you</personal_box_title>
201
+ <personal_box_limit>4</personal_box_limit>
202
+ <personal_box_columns>4</personal_box_columns>
203
+ <accessories_box>0</accessories_box>
204
+ <accessories_box_layout>content</accessories_box_layout>
205
+ <accessories_box_title>You might also need</accessories_box_title>
206
+ <accessories_box_limit>4</accessories_box_limit>
207
+ <accessories_box_columns>4</accessories_box_columns>
208
+ </product_display>
209
+ <category_display>
210
+ <personal_box>0</personal_box>
211
+ <personal_box_layout>content</personal_box_layout>
212
+ <personal_box_title>Recommended for you</personal_box_title>
213
+ <personal_box_limit>4</personal_box_limit>
214
+ <personal_box_columns>4</personal_box_columns>
215
+ <top_box>0</top_box>
216
+ <top_box_layout>content</top_box_layout>
217
+ <top_box_title>Top Products</top_box_title>
218
+ <top_box_limit>4</top_box_limit>
219
+ <top_box_columns>4</top_box_columns>
220
+ </category_display>
221
+ <search_display>
222
+ <search_box>0</search_box>
223
+ <search_box_layout>content</search_box_layout>
224
+ <search_box_title>Recommended for you</search_box_title>
225
+ <search_box_limit>4</search_box_limit>
226
+ <search_box_columns>4</search_box_columns>
227
+ </search_display>
228
+ <cart_display>
229
+ <cart_box>0</cart_box>
230
+ <cart_box_layout>content</cart_box_layout>
231
+ <cart_box_title>Others also bought</cart_box_title>
232
+ <cart_box_limit>4</cart_box_limit>
233
+ <cart_box_columns>4</cart_box_columns>
234
+ </cart_display>
235
+ <sync>
236
+ <customer_update>0</customer_update>
237
+ <product_update>0</product_update>
238
+ <customer_registration>0</customer_registration>
239
+ </sync>
240
+ <debug>
241
+ <log>0</log>
242
+ </debug>
243
+ </gravity>
244
+ </default>
245
+ </config>
app/code/community/Me/Gravity/etc/system.xml ADDED
@@ -0,0 +1,1076 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Me
5
+ * @package Me_Gravity
6
+ * @author Attila Sági <sagi.attila@magevolve.com>
7
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
8
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
9
+ * @link http://magevolve.com
10
+ */
11
+ -->
12
+ <config>
13
+ <tabs>
14
+ <me_tab translate="label" module="me_gravity">
15
+ <label>Recommendations</label>
16
+ <sort_order>500</sort_order>
17
+ </me_tab>
18
+ </tabs>
19
+ <sections>
20
+ <gravity>
21
+ <class>separator-top</class>
22
+ <label>Gravity Reco</label>
23
+ <tab>me_tab</tab>
24
+ <frontend_type>text</frontend_type>
25
+ <sort_order>500</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ <groups>
30
+ <config translate="label">
31
+ <label>Settings</label>
32
+ <frontend_type>text</frontend_type>
33
+ <sort_order>10</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ <fields>
38
+ <enabled translate="label">
39
+ <label>Enable Extension</label>
40
+ <frontend_type>select</frontend_type>
41
+ <source_model>adminhtml/system_config_source_yesno</source_model>
42
+ <sort_order>10</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ <comment>Enable extension.</comment>
47
+ </enabled>
48
+ <preview translate="label">
49
+ <label>Enable Preview Mode</label>
50
+ <frontend_type>select</frontend_type>
51
+ <source_model>adminhtml/system_config_source_yesno</source_model>
52
+ <sort_order>20</sort_order>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>1</show_in_store>
56
+ <comment>Enabled Preview mode. In this case recommendation boxes are only visible if there is a special ?gr_reco_test=true parameter in the url. E.g.: http://example.com/example-product.html?gr_reco_test=true</comment>
57
+ </preview>
58
+ <api_user translate="label">
59
+ <label>API Username</label>
60
+ <frontend_type>text</frontend_type>
61
+ <sort_order>30</sort_order>
62
+ <show_in_default>1</show_in_default>
63
+ <show_in_website>1</show_in_website>
64
+ <show_in_store>1</show_in_store>
65
+ <comment>API user name in Gravity system.</comment>
66
+ </api_user>
67
+ <api_password translate="label">
68
+ <label>API Password</label>
69
+ <frontend_type>password</frontend_type>
70
+ <sort_order>40</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>1</show_in_store>
74
+ <comment>API password in Gravity system.</comment>
75
+ </api_password>
76
+ <api_url translate="label">
77
+ <label>API URL</label>
78
+ <frontend_type>text</frontend_type>
79
+ <sort_order>50</sort_order>
80
+ <show_in_default>1</show_in_default>
81
+ <show_in_website>1</show_in_website>
82
+ <show_in_store>1</show_in_store>
83
+ <comment>API communication URL.</comment>
84
+ </api_url>
85
+ <test translate="label">
86
+ <label>Test Connection</label>
87
+ <frontend_type>button</frontend_type>
88
+ <frontend_model>me_gravity/adminhtml_system_config_form_test</frontend_model>
89
+ <sort_order>60</sort_order>
90
+ <show_in_default>1</show_in_default>
91
+ <show_in_website>1</show_in_website>
92
+ <show_in_store>1</show_in_store>
93
+ <comment>Press button to test connection.</comment>
94
+ </test>
95
+ <template translate="label">
96
+ <label>Use Garvity Template</label>
97
+ <frontend_type>select</frontend_type>
98
+ <source_model>adminhtml/system_config_source_yesno</source_model>
99
+ <sort_order>70</sort_order>
100
+ <show_in_default>1</show_in_default>
101
+ <show_in_website>1</show_in_website>
102
+ <show_in_store>1</show_in_store>
103
+ <comment>General display setting. If YES all boxes will use Gravity template.</comment>
104
+ </template>
105
+ </fields>
106
+ </config>
107
+ <export translate="label">
108
+ <label>Export Products</label>
109
+ <frontend_type>text</frontend_type>
110
+ <sort_order>20</sort_order>
111
+ <show_in_default>1</show_in_default>
112
+ <show_in_website>1</show_in_website>
113
+ <show_in_store>1</show_in_store>
114
+ <fields>
115
+ <catalog_path translate="label">
116
+ <label>Catalog Export File Path</label>
117
+ <frontend_type>text</frontend_type>
118
+ <sort_order>10</sort_order>
119
+ <show_in_default>1</show_in_default>
120
+ <show_in_website>1</show_in_website>
121
+ <show_in_store>1</show_in_store>
122
+ <comment>Path where catalog export file will be saved. Example: "gravity_reco/" (path must be writeable)</comment>
123
+ </catalog_path>
124
+ <all translate="label">
125
+ <label>Enable All Products Export</label>
126
+ <frontend_type>select</frontend_type>
127
+ <source_model>adminhtml/system_config_source_yesno</source_model>
128
+ <sort_order>15</sort_order>
129
+ <show_in_default>1</show_in_default>
130
+ <show_in_website>1</show_in_website>
131
+ <show_in_store>1</show_in_store>
132
+ <comment>Enable all products to export. Otherwise please select NO and set the maximum number. Note: there can be performance impact during this operation.</comment>
133
+ </all>
134
+ <max translate="label">
135
+ <label>Maximum Products Export</label>
136
+ <frontend_type>text</frontend_type>
137
+ <sort_order>20</sort_order>
138
+ <show_in_default>1</show_in_default>
139
+ <show_in_website>1</show_in_website>
140
+ <show_in_store>1</show_in_store>
141
+ <comment>The maximum number of products to be exported. This number must be between 1 and 1000.</comment>
142
+ <validate>validate-number validate-number-range number-range-1-1000</validate>
143
+ <depends><all>0</all></depends>
144
+ </max>
145
+ <additional translate="label">
146
+ <label>Additional Attributes</label>
147
+ <frontend_type>multiselect</frontend_type>
148
+ <source_model>me_gravity/system_config_source_catalog_attributes</source_model>
149
+ <sort_order>30</sort_order>
150
+ <show_in_default>1</show_in_default>
151
+ <show_in_website>1</show_in_website>
152
+ <show_in_store>1</show_in_store>
153
+ <comment>Select additional attributes for catalog export.</comment>
154
+ </additional>
155
+ <only_salable translate="label">
156
+ <label>Only Salable</label>
157
+ <frontend_type>select</frontend_type>
158
+ <source_model>adminhtml/system_config_source_yesno</source_model>
159
+ <sort_order>40</sort_order>
160
+ <show_in_default>1</show_in_default>
161
+ <show_in_website>1</show_in_website>
162
+ <show_in_store>1</show_in_store>
163
+ <comment>In this case only those products will be exported which quantity higher than zero(is in stock). If your store doesn't use stock management choose YES.</comment>
164
+ </only_salable>
165
+ <catalog_cron translate="label">
166
+ <label>Enable Scheduled Export</label>
167
+ <frontend_type>select</frontend_type>
168
+ <source_model>adminhtml/system_config_source_yesno</source_model>
169
+ <backend_model>me_gravity/system_config_backend_catalog_cron</backend_model>
170
+ <sort_order>50</sort_order>
171
+ <show_in_default>1</show_in_default>
172
+ <show_in_website>1</show_in_website>
173
+ <show_in_store>1</show_in_store>
174
+ <comment>Enable scheduled export job bby cron. Note: you must configure your server to run cron jobs.</comment>
175
+ </catalog_cron>
176
+ <catalog_cron_time translate="label">
177
+ <label>Start Time</label>
178
+ <frontend_type>time</frontend_type>
179
+ <sort_order>60</sort_order>
180
+ <show_in_default>1</show_in_default>
181
+ <show_in_website>1</show_in_website>
182
+ <show_in_store>1</show_in_store>
183
+ <comment>Daily start time for automatic catalog export via cron job.</comment>
184
+ <depends><catalog_cron>1</catalog_cron></depends>
185
+ </catalog_cron_time>
186
+ <catalog translate="label">
187
+ <label>Export Product Catalog</label>
188
+ <frontend_type>button</frontend_type>
189
+ <frontend_model>me_gravity/adminhtml_system_config_form_catalog</frontend_model>
190
+ <sort_order>70</sort_order>
191
+ <show_in_default>1</show_in_default>
192
+ <show_in_website>1</show_in_website>
193
+ <show_in_store>1</show_in_store>
194
+ <comment>This will export product catalog and save in xml file. Note: there can be performance impact during this operation.</comment>
195
+ </catalog>
196
+ </fields>
197
+ </export>
198
+ <cutomer_export translate="label">
199
+ <label>Export Customers</label>
200
+ <frontend_type>text</frontend_type>
201
+ <sort_order>30</sort_order>
202
+ <show_in_default>1</show_in_default>
203
+ <show_in_website>1</show_in_website>
204
+ <show_in_store>1</show_in_store>
205
+ <fields>
206
+ <all translate="label">
207
+ <label>Enable All Customers Export</label>
208
+ <frontend_type>select</frontend_type>
209
+ <source_model>adminhtml/system_config_source_yesno</source_model>
210
+ <sort_order>5</sort_order>
211
+ <show_in_default>1</show_in_default>
212
+ <show_in_website>1</show_in_website>
213
+ <show_in_store>1</show_in_store>
214
+ <comment>Enable all customer to export. Otherwise please select NO and set the maximum number. Note: there can be performance impact during this operation.</comment>
215
+ </all>
216
+ <max translate="label">
217
+ <label>Maximum Customers Export</label>
218
+ <frontend_type>text</frontend_type>
219
+ <sort_order>10</sort_order>
220
+ <show_in_default>1</show_in_default>
221
+ <show_in_website>1</show_in_website>
222
+ <show_in_store>1</show_in_store>
223
+ <comment>The maximum number of customers to be exported. This number must be between 1 and 1000.</comment>
224
+ <validate>validate-number validate-number-range number-range-1-1000</validate>
225
+ <depends><all>0</all></depends>
226
+ </max>
227
+ <additional translate="label">
228
+ <label>Additional Attributes</label>
229
+ <frontend_type>multiselect</frontend_type>
230
+ <source_model>me_gravity/system_config_source_customer_attributes</source_model>
231
+ <sort_order>20</sort_order>
232
+ <show_in_default>1</show_in_default>
233
+ <show_in_website>1</show_in_website>
234
+ <show_in_store>1</show_in_store>
235
+ <comment>Select additional attributes for customer export.</comment>
236
+ </additional>
237
+ <customer translate="label">
238
+ <label>Export Customers</label>
239
+ <frontend_type>button</frontend_type>
240
+ <frontend_model>me_gravity/adminhtml_system_config_form_customer</frontend_model>
241
+ <sort_order>30</sort_order>
242
+ <show_in_default>1</show_in_default>
243
+ <show_in_website>1</show_in_website>
244
+ <show_in_store>1</show_in_store>
245
+ <comment>This will export customers. Note: there can be performance impact during this operation.</comment>
246
+ </customer>
247
+ </fields>
248
+ </cutomer_export>
249
+ <general_display translate="label">
250
+ <label>General Pages Display</label>
251
+ <frontend_type>text</frontend_type>
252
+ <sort_order>40</sort_order>
253
+ <show_in_default>1</show_in_default>
254
+ <show_in_website>1</show_in_website>
255
+ <show_in_store>1</show_in_store>
256
+ <fields>
257
+ <pages translate="label">
258
+ <label>Enabled Pages</label>
259
+ <frontend_type>multiselect</frontend_type>
260
+ <source_model>me_gravity/system_config_source_layout_pages</source_model>
261
+ <sort_order>1</sort_order>
262
+ <show_in_default>1</show_in_default>
263
+ <show_in_website>1</show_in_website>
264
+ <show_in_store>1</show_in_store>
265
+ <comment>Pages on general layout recommendation boxes enabled.</comment>
266
+ </pages>
267
+ <best_heading translate="label">
268
+ <label>Personal Best Box (PERSONAL_BEST)</label>
269
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
270
+ <sort_order>5</sort_order>
271
+ <show_in_default>1</show_in_default>
272
+ <show_in_website>1</show_in_website>
273
+ <show_in_store>1</show_in_store>
274
+ </best_heading>
275
+ <best_box translate="label">
276
+ <label>Enable Personal Best Box</label>
277
+ <frontend_type>select</frontend_type>
278
+ <source_model>adminhtml/system_config_source_yesno</source_model>
279
+ <sort_order>10</sort_order>
280
+ <show_in_default>1</show_in_default>
281
+ <show_in_website>1</show_in_website>
282
+ <show_in_store>1</show_in_store>
283
+ <comment>Enable "Recommended for you" box on general page views.</comment>
284
+ </best_box>
285
+ <best_box_layout translate="label">
286
+ <label>Personal Best Box Layout</label>
287
+ <frontend_type>select</frontend_type>
288
+ <source_model>me_gravity/system_config_source_layout_layout</source_model>
289
+ <sort_order>20</sort_order>
290
+ <show_in_default>1</show_in_default>
291
+ <show_in_website>1</show_in_website>
292
+ <show_in_store>1</show_in_store>
293
+ <comment>Select where "Recommended for you" box should be shown on general page views.</comment>
294
+ <depends><best_box>1</best_box></depends>
295
+ </best_box_layout>
296
+ <best_box_title translate="label">
297
+ <label>Personal Best Box Title</label>
298
+ <frontend_type>text</frontend_type>
299
+ <sort_order>30</sort_order>
300
+ <show_in_default>1</show_in_default>
301
+ <show_in_website>1</show_in_website>
302
+ <show_in_store>1</show_in_store>
303
+ <comment>"Recommended for you" box title on general page views.</comment>
304
+ <depends><best_box>1</best_box></depends>
305
+ </best_box_title>
306
+ <best_box_limit translate="label">
307
+ <label>Personal Best Box Product Count</label>
308
+ <frontend_type>text</frontend_type>
309
+ <sort_order>40</sort_order>
310
+ <show_in_default>1</show_in_default>
311
+ <show_in_website>1</show_in_website>
312
+ <show_in_store>1</show_in_store>
313
+ <comment>Number of items show in "Recommended for you" box on general page views. This number must be between 1 and 10.</comment>
314
+ <validate>validate-number validate-number-range number-range-1-10</validate>
315
+ <depends><best_box>1</best_box></depends>
316
+ </best_box_limit>
317
+ <best_box_columns translate="label">
318
+ <label>Personal Best Box Columns</label>
319
+ <frontend_type>text</frontend_type>
320
+ <sort_order>50</sort_order>
321
+ <show_in_default>1</show_in_default>
322
+ <show_in_website>1</show_in_website>
323
+ <show_in_store>1</show_in_store>
324
+ <comment>Columns count in "Recommended for you" box on general page views. This number must be between 1 and 6. It has no effect if box is in sidebar.</comment>
325
+ <validate>validate-number validate-number-range number-range-1-6</validate>
326
+ <depends>
327
+ <best_box>1</best_box>
328
+ <best_box_layout>content</best_box_layout>
329
+ </depends>
330
+ </best_box_columns>
331
+ <history_heading translate="label">
332
+ <label>History Box (PERSONAL_HISTORY)</label>
333
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
334
+ <sort_order>55</sort_order>
335
+ <show_in_default>1</show_in_default>
336
+ <show_in_website>1</show_in_website>
337
+ <show_in_store>1</show_in_store>
338
+ </history_heading>
339
+ <history_box translate="label">
340
+ <label>Enable History Box</label>
341
+ <frontend_type>select</frontend_type>
342
+ <source_model>adminhtml/system_config_source_yesno</source_model>
343
+ <sort_order>60</sort_order>
344
+ <show_in_default>1</show_in_default>
345
+ <show_in_website>1</show_in_website>
346
+ <show_in_store>1</show_in_store>
347
+ <comment>Enable "You viewed" box on general page views.</comment>
348
+ </history_box>
349
+ <history_box_layout translate="label">
350
+ <label>History Box Layout</label>
351
+ <frontend_type>select</frontend_type>
352
+ <source_model>me_gravity/system_config_source_layout_layout</source_model>
353
+ <sort_order>70</sort_order>
354
+ <show_in_default>1</show_in_default>
355
+ <show_in_website>1</show_in_website>
356
+ <show_in_store>1</show_in_store>
357
+ <comment>Select where "You viewed" box should be shown on general page views.</comment>
358
+ <depends><history_box>1</history_box></depends>
359
+ </history_box_layout>
360
+ <history_box_title translate="label">
361
+ <label>History Box Title</label>
362
+ <frontend_type>text</frontend_type>
363
+ <sort_order>80</sort_order>
364
+ <show_in_default>1</show_in_default>
365
+ <show_in_website>1</show_in_website>
366
+ <show_in_store>1</show_in_store>
367
+ <comment>"You viewed" box title on general page views.</comment>
368
+ <depends><history_box>1</history_box></depends>
369
+ </history_box_title>
370
+ <history_box_limit translate="label">
371
+ <label>History Box Product Count</label>
372
+ <frontend_type>text</frontend_type>
373
+ <sort_order>90</sort_order>
374
+ <show_in_default>1</show_in_default>
375
+ <show_in_website>1</show_in_website>
376
+ <show_in_store>1</show_in_store>
377
+ <comment>Number of items show in "You viewed" box on general page views. This number must be between 1 and 10.</comment>
378
+ <validate>validate-number validate-number-range number-range-1-10</validate>
379
+ <depends><history_box>1</history_box></depends>
380
+ </history_box_limit>
381
+ <history_box_columns translate="label">
382
+ <label>History Box Columns</label>
383
+ <frontend_type>text</frontend_type>
384
+ <sort_order>100</sort_order>
385
+ <show_in_default>1</show_in_default>
386
+ <show_in_website>1</show_in_website>
387
+ <show_in_store>1</show_in_store>
388
+ <comment>Columns count in "You viewed" box on general page views. This number must be between 1 and 6. It has no effect if box is in sidebar.</comment>
389
+ <validate>validate-number validate-number-range number-range-1-6</validate>
390
+ <depends>
391
+ <history_box>1</history_box>
392
+ <history_box_layout>content</history_box_layout>
393
+ </depends>
394
+ </history_box_columns>
395
+ <others_heading translate="label">
396
+ <label>Currently Viewed Box (CURRENTLY_VIEWED)</label>
397
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
398
+ <sort_order>105</sort_order>
399
+ <show_in_default>1</show_in_default>
400
+ <show_in_website>1</show_in_website>
401
+ <show_in_store>1</show_in_store>
402
+ </others_heading>
403
+ <others_box translate="label">
404
+ <label>Enable Currently Viewed Box</label>
405
+ <frontend_type>select</frontend_type>
406
+ <source_model>adminhtml/system_config_source_yesno</source_model>
407
+ <sort_order>110</sort_order>
408
+ <show_in_default>1</show_in_default>
409
+ <show_in_website>1</show_in_website>
410
+ <show_in_store>1</show_in_store>
411
+ <comment>Enable "Others are looking at right now" box on general page views.</comment>
412
+ </others_box>
413
+ <others_box_layout translate="label">
414
+ <label>Currently Viewed Box Layout</label>
415
+ <frontend_type>select</frontend_type>
416
+ <source_model>me_gravity/system_config_source_layout_layout</source_model>
417
+ <sort_order>120</sort_order>
418
+ <show_in_default>1</show_in_default>
419
+ <show_in_website>1</show_in_website>
420
+ <show_in_store>1</show_in_store>
421
+ <comment>Select where "Others are looking at right now" box should be shown on general page views.</comment>
422
+ <depends><others_box>1</others_box></depends>
423
+ </others_box_layout>
424
+ <others_box_title translate="label">
425
+ <label>Currently Viewed Box Title</label>
426
+ <frontend_type>text</frontend_type>
427
+ <sort_order>130</sort_order>
428
+ <show_in_default>1</show_in_default>
429
+ <show_in_website>1</show_in_website>
430
+ <show_in_store>1</show_in_store>
431
+ <comment>"Others are looking at right now" box title on general page views.</comment>
432
+ <depends><others_box>1</others_box></depends>
433
+ </others_box_title>
434
+ <others_box_limit translate="label">
435
+ <label>Currently Viewed Box Product Count</label>
436
+ <frontend_type>text</frontend_type>
437
+ <sort_order>140</sort_order>
438
+ <show_in_default>1</show_in_default>
439
+ <show_in_website>1</show_in_website>
440
+ <show_in_store>1</show_in_store>
441
+ <comment>Number of items show in "Others are looking at right now" box on general page views. This number must be between 1 and 10.</comment>
442
+ <validate>validate-number validate-number-range number-range-1-10</validate>
443
+ <depends><others_box>1</others_box></depends>
444
+ </others_box_limit>
445
+ <others_box_columns translate="label">
446
+ <label>Currently Viewed Box Columns</label>
447
+ <frontend_type>text</frontend_type>
448
+ <sort_order>150</sort_order>
449
+ <show_in_default>1</show_in_default>
450
+ <show_in_website>1</show_in_website>
451
+ <show_in_store>1</show_in_store>
452
+ <comment>Columns count in "Others are looking at right now" box on general page views. This number must be between 1 and 6. It has no effect if box is in sidebar.</comment>
453
+ <validate>validate-number validate-number-range number-range-1-6</validate>
454
+ <depends>
455
+ <others_box>1</others_box>
456
+ <others_box_layout>content</others_box_layout>
457
+ </depends>
458
+ </others_box_columns>
459
+ <popular_heading translate="label">
460
+ <label>Popular Box (POPULAR)</label>
461
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
462
+ <sort_order>155</sort_order>
463
+ <show_in_default>1</show_in_default>
464
+ <show_in_website>1</show_in_website>
465
+ <show_in_store>1</show_in_store>
466
+ </popular_heading>
467
+ <popular_box translate="label">
468
+ <label>Enable Popular Box</label>
469
+ <frontend_type>select</frontend_type>
470
+ <source_model>adminhtml/system_config_source_yesno</source_model>
471
+ <sort_order>160</sort_order>
472
+ <show_in_default>1</show_in_default>
473
+ <show_in_website>1</show_in_website>
474
+ <show_in_store>1</show_in_store>
475
+ <comment>Enable "Top products" box on general page views.</comment>
476
+ </popular_box>
477
+ <popular_box_layout translate="label">
478
+ <label>Popular Box Layout</label>
479
+ <frontend_type>select</frontend_type>
480
+ <source_model>me_gravity/system_config_source_layout_layout</source_model>
481
+ <sort_order>170</sort_order>
482
+ <show_in_default>1</show_in_default>
483
+ <show_in_website>1</show_in_website>
484
+ <show_in_store>1</show_in_store>
485
+ <comment>Select where "Top products" box should be shown on general page views.</comment>
486
+ <depends><popular_box>1</popular_box></depends>
487
+ </popular_box_layout>
488
+ <popular_box_title translate="label">
489
+ <label>Popular Box Title</label>
490
+ <frontend_type>text</frontend_type>
491
+ <sort_order>180</sort_order>
492
+ <show_in_default>1</show_in_default>
493
+ <show_in_website>1</show_in_website>
494
+ <show_in_store>1</show_in_store>
495
+ <comment>"Top products" box title on general page views.</comment>
496
+ <depends><popular_box>1</popular_box></depends>
497
+ </popular_box_title>
498
+ <popular_box_limit translate="label">
499
+ <label>Popular Box Product Count</label>
500
+ <frontend_type>text</frontend_type>
501
+ <sort_order>190</sort_order>
502
+ <show_in_default>1</show_in_default>
503
+ <show_in_website>1</show_in_website>
504
+ <show_in_store>1</show_in_store>
505
+ <comment>Number of items show in "Top products" box on general page views. This number must be between 1 and 10.</comment>
506
+ <validate>validate-number validate-number-range number-range-1-10</validate>
507
+ <depends><popular_box>1</popular_box></depends>
508
+ </popular_box_limit>
509
+ <popular_box_columns translate="label">
510
+ <label>Popular Box Columns</label>
511
+ <frontend_type>text</frontend_type>
512
+ <sort_order>200</sort_order>
513
+ <show_in_default>1</show_in_default>
514
+ <show_in_website>1</show_in_website>
515
+ <show_in_store>1</show_in_store>
516
+ <comment>Columns count in "Top products" box on general page views. This number must be between 1 and 6. It has no effect if box is in sidebar.</comment>
517
+ <validate>validate-number validate-number-range number-range-1-6</validate>
518
+ <depends>
519
+ <popular_box>1</popular_box>
520
+ <popular_box_layout>content</popular_box_layout>
521
+ </depends>
522
+ </popular_box_columns>
523
+ </fields>
524
+ </general_display>
525
+ <product_display translate="label">
526
+ <label>Product Page Display</label>
527
+ <frontend_type>text</frontend_type>
528
+ <sort_order>50</sort_order>
529
+ <show_in_default>1</show_in_default>
530
+ <show_in_website>1</show_in_website>
531
+ <show_in_store>1</show_in_store>
532
+ <fields>
533
+ <similar_heading translate="label">
534
+ <label>Similar Box (ITEM_PAGE_SIMILAR)</label>
535
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
536
+ <sort_order>5</sort_order>
537
+ <show_in_default>1</show_in_default>
538
+ <show_in_website>1</show_in_website>
539
+ <show_in_store>1</show_in_store>
540
+ </similar_heading>
541
+ <similar_box translate="label">
542
+ <label>Enable Similar Box</label>
543
+ <frontend_type>select</frontend_type>
544
+ <source_model>adminhtml/system_config_source_yesno</source_model>
545
+ <sort_order>10</sort_order>
546
+ <show_in_default>1</show_in_default>
547
+ <show_in_website>1</show_in_website>
548
+ <show_in_store>1</show_in_store>
549
+ <comment>Enable "You might also like" box on product page view.</comment>
550
+ </similar_box>
551
+ <similar_box_layout translate="label">
552
+ <label>Similar Box Layout</label>
553
+ <frontend_type>select</frontend_type>
554
+ <source_model>me_gravity/system_config_source_layout_layout</source_model>
555
+ <sort_order>20</sort_order>
556
+ <show_in_default>1</show_in_default>
557
+ <show_in_website>1</show_in_website>
558
+ <show_in_store>1</show_in_store>
559
+ <comment>Select where "You might also like" box should be shown on product page view.</comment>
560
+ <depends><similar_box>1</similar_box></depends>
561
+ </similar_box_layout>
562
+ <similar_box_title translate="label">
563
+ <label>Similar Box Title</label>
564
+ <frontend_type>text</frontend_type>
565
+ <sort_order>30</sort_order>
566
+ <show_in_default>1</show_in_default>
567
+ <show_in_website>1</show_in_website>
568
+ <show_in_store>1</show_in_store>
569
+ <comment>"You might also like" box title on product page view.</comment>
570
+ <depends><similar_box>1</similar_box></depends>
571
+ </similar_box_title>
572
+ <similar_box_limit translate="label">
573
+ <label>Similar Box Product Count</label>
574
+ <frontend_type>text</frontend_type>
575
+ <sort_order>40</sort_order>
576
+ <show_in_default>1</show_in_default>
577
+ <show_in_website>1</show_in_website>
578
+ <show_in_store>1</show_in_store>
579
+ <comment>Number of items show in "You might also like" box on product page view. This number must be between 1 and 10.</comment>
580
+ <validate>validate-number validate-number-range number-range-1-10</validate>
581
+ <depends><similar_box>1</similar_box></depends>
582
+ </similar_box_limit>
583
+ <similar_box_columns translate="label">
584
+ <label>Similar Box Columns</label>
585
+ <frontend_type>text</frontend_type>
586
+ <sort_order>50</sort_order>
587
+ <show_in_default>1</show_in_default>
588
+ <show_in_website>1</show_in_website>
589
+ <show_in_store>1</show_in_store>
590
+ <comment>Columns count in "You might also like" box on product page view. This number must be between 1 and 6. It has no effect if box is in sidebar.</comment>
591
+ <validate>validate-number validate-number-range number-range-1-6</validate>
592
+ <depends>
593
+ <similar_box>1</similar_box>
594
+ <similar_box_layout>content</similar_box_layout>
595
+ </depends>
596
+ </similar_box_columns>
597
+ <personal_heading translate="label">
598
+ <label>Personal Box (ITEM_PAGE_PERSONAL)</label>
599
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
600
+ <sort_order>55</sort_order>
601
+ <show_in_default>1</show_in_default>
602
+ <show_in_website>1</show_in_website>
603
+ <show_in_store>1</show_in_store>
604
+ </personal_heading>
605
+ <personal_box translate="label">
606
+ <label>Enable Personal Box</label>
607
+ <frontend_type>select</frontend_type>
608
+ <source_model>adminhtml/system_config_source_yesno</source_model>
609
+ <sort_order>60</sort_order>
610
+ <show_in_default>1</show_in_default>
611
+ <show_in_website>1</show_in_website>
612
+ <show_in_store>1</show_in_store>
613
+ <comment>Enable "Recommended for you" box on product page view.</comment>
614
+ </personal_box>
615
+ <personal_box_layout translate="label">
616
+ <label>Personal Box Layout</label>
617
+ <frontend_type>select</frontend_type>
618
+ <source_model>me_gravity/system_config_source_layout_layout</source_model>
619
+ <sort_order>70</sort_order>
620
+ <show_in_default>1</show_in_default>
621
+ <show_in_website>1</show_in_website>
622
+ <show_in_store>1</show_in_store>
623
+ <comment>Select where "Recommended for you" box should be shown on product page view.</comment>
624
+ <depends><personal_box>1</personal_box></depends>
625
+ </personal_box_layout>
626
+ <personal_box_title translate="label">
627
+ <label>Personal Box Title</label>
628
+ <frontend_type>text</frontend_type>
629
+ <sort_order>80</sort_order>
630
+ <show_in_default>1</show_in_default>
631
+ <show_in_website>1</show_in_website>
632
+ <show_in_store>1</show_in_store>
633
+ <comment>"Recommended for you" box title on product page view.</comment>
634
+ <depends><personal_box>1</personal_box></depends>
635
+ </personal_box_title>
636
+ <personal_box_limit translate="label">
637
+ <label>Personal Box Product Count</label>
638
+ <frontend_type>text</frontend_type>
639
+ <sort_order>90</sort_order>
640
+ <show_in_default>1</show_in_default>
641
+ <show_in_website>1</show_in_website>
642
+ <show_in_store>1</show_in_store>
643
+ <comment>Number of items show in "Recommended for you" box on product page view. This number must be between 1 and 10.</comment>
644
+ <validate>validate-number validate-number-range number-range-1-10</validate>
645
+ <depends><personal_box>1</personal_box></depends>
646
+ </personal_box_limit>
647
+ <personal_box_columns translate="label">
648
+ <label>Personal Box Columns</label>
649
+ <frontend_type>text</frontend_type>
650
+ <sort_order>100</sort_order>
651
+ <show_in_default>1</show_in_default>
652
+ <show_in_website>1</show_in_website>
653
+ <show_in_store>1</show_in_store>
654
+ <comment>Columns count in "Recommended for you" box on product page view. This number must be between 1 and 6. It has no effect if box is in sidebar.</comment>
655
+ <validate>validate-number validate-number-range number-range-1-6</validate>
656
+ <depends>
657
+ <personal_box>1</personal_box>
658
+ <personal_box_layout>content</personal_box_layout>
659
+ </depends>
660
+ </personal_box_columns>
661
+ <accessories_heading translate="label">
662
+ <label>Accessories Box (ITEM_PAGE_ACCESSORIES)</label>
663
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
664
+ <sort_order>105</sort_order>
665
+ <show_in_default>1</show_in_default>
666
+ <show_in_website>1</show_in_website>
667
+ <show_in_store>1</show_in_store>
668
+ </accessories_heading>
669
+ <accessories_box translate="label">
670
+ <label>Enable Accessories Box</label>
671
+ <frontend_type>select</frontend_type>
672
+ <source_model>adminhtml/system_config_source_yesno</source_model>
673
+ <sort_order>110</sort_order>
674
+ <show_in_default>1</show_in_default>
675
+ <show_in_website>1</show_in_website>
676
+ <show_in_store>1</show_in_store>
677
+ <comment>Enable "You might also need" box on product page view.</comment>
678
+ </accessories_box>
679
+ <accessories_box_layout translate="label">
680
+ <label>Accessories Box Layout</label>
681
+ <frontend_type>select</frontend_type>
682
+ <source_model>me_gravity/system_config_source_layout_layout</source_model>
683
+ <sort_order>120</sort_order>
684
+ <show_in_default>1</show_in_default>
685
+ <show_in_website>1</show_in_website>
686
+ <show_in_store>1</show_in_store>
687
+ <comment>Select where "You might also need" box should be shown on product page view.</comment>
688
+ <depends><accessories_box>1</accessories_box></depends>
689
+ </accessories_box_layout>
690
+ <accessories_box_title translate="label">
691
+ <label>Accessories Box Title</label>
692
+ <frontend_type>text</frontend_type>
693
+ <sort_order>130</sort_order>
694
+ <show_in_default>1</show_in_default>
695
+ <show_in_website>1</show_in_website>
696
+ <show_in_store>1</show_in_store>
697
+ <comment>"You might also need" box title on product page view.</comment>
698
+ <depends><accessories_box>1</accessories_box></depends>
699
+ </accessories_box_title>
700
+ <accessories_box_limit translate="label">
701
+ <label>Accessories Box Product Count</label>
702
+ <frontend_type>text</frontend_type>
703
+ <sort_order>140</sort_order>
704
+ <show_in_default>1</show_in_default>
705
+ <show_in_website>1</show_in_website>
706
+ <show_in_store>1</show_in_store>
707
+ <comment>Number of items show in "You might also need" box on product page view. This number must be between 1 and 10.</comment>
708
+ <validate>validate-number validate-number-range number-range-1-10</validate>
709
+ <depends><accessories_box>1</accessories_box></depends>
710
+ </accessories_box_limit>
711
+ <accessories_box_columns translate="label">
712
+ <label>Accessories Box Columns</label>
713
+ <frontend_type>text</frontend_type>
714
+ <sort_order>150</sort_order>
715
+ <show_in_default>1</show_in_default>
716
+ <show_in_website>1</show_in_website>
717
+ <show_in_store>1</show_in_store>
718
+ <comment>Columns count in "You might also need" box on product page view. This number must be between 1 and 6. It has no effect if box is in sidebar.</comment>
719
+ <validate>validate-number validate-number-range number-range-1-6</validate>
720
+ <depends>
721
+ <accessories_box>1</accessories_box>
722
+ <accessories_box_layout>content</accessories_box_layout>
723
+ </depends>
724
+ </accessories_box_columns>
725
+ </fields>
726
+ </product_display>
727
+ <category_display translate="label">
728
+ <label>Category Page Display</label>
729
+ <frontend_type>text</frontend_type>
730
+ <sort_order>60</sort_order>
731
+ <show_in_default>1</show_in_default>
732
+ <show_in_website>1</show_in_website>
733
+ <show_in_store>1</show_in_store>
734
+ <fields>
735
+ <personal_heading translate="label">
736
+ <label>Personal Box (CATEGORY_PAGE_PERSONAL)</label>
737
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
738
+ <sort_order>5</sort_order>
739
+ <show_in_default>1</show_in_default>
740
+ <show_in_website>1</show_in_website>
741
+ <show_in_store>1</show_in_store>
742
+ </personal_heading>
743
+ <personal_box translate="label">
744
+ <label>Enable Personal Box</label>
745
+ <frontend_type>select</frontend_type>
746
+ <source_model>adminhtml/system_config_source_yesno</source_model>
747
+ <sort_order>10</sort_order>
748
+ <show_in_default>1</show_in_default>
749
+ <show_in_website>1</show_in_website>
750
+ <show_in_store>1</show_in_store>
751
+ <comment>Enable "Recommended for you" box on category page view.</comment>
752
+ </personal_box>
753
+ <personal_box_layout translate="label">
754
+ <label>Personal Box Layout</label>
755
+ <frontend_type>select</frontend_type>
756
+ <source_model>me_gravity/system_config_source_layout_layout</source_model>
757
+ <sort_order>20</sort_order>
758
+ <show_in_default>1</show_in_default>
759
+ <show_in_website>1</show_in_website>
760
+ <show_in_store>1</show_in_store>
761
+ <comment>Select where "Recommended for you" box should be shown on category page view.</comment>
762
+ <depends><personal_box>1</personal_box></depends>
763
+ </personal_box_layout>
764
+ <personal_box_title translate="label">
765
+ <label>Personal Box Title</label>
766
+ <frontend_type>text</frontend_type>
767
+ <sort_order>30</sort_order>
768
+ <show_in_default>1</show_in_default>
769
+ <show_in_website>1</show_in_website>
770
+ <show_in_store>1</show_in_store>
771
+ <comment>"Recommended for you" box title on category page view.</comment>
772
+ <depends><personal_box>1</personal_box></depends>
773
+ </personal_box_title>
774
+ <personal_box_limit translate="label">
775
+ <label>Personal Box Product Count</label>
776
+ <frontend_type>text</frontend_type>
777
+ <sort_order>40</sort_order>
778
+ <show_in_default>1</show_in_default>
779
+ <show_in_website>1</show_in_website>
780
+ <show_in_store>1</show_in_store>
781
+ <comment>Number of items show in "Recommended for you" box on category page view. This number must be between 1 and 10.</comment>
782
+ <validate>validate-number validate-number-range number-range-1-10</validate>
783
+ <depends><personal_box>1</personal_box></depends>
784
+ </personal_box_limit>
785
+ <personal_box_columns translate="label">
786
+ <label>Personal Box Columns</label>
787
+ <frontend_type>text</frontend_type>
788
+ <sort_order>50</sort_order>
789
+ <show_in_default>1</show_in_default>
790
+ <show_in_website>1</show_in_website>
791
+ <show_in_store>1</show_in_store>
792
+ <comment>Columns count in "Recommended for you" box on category page view. This number must be between 1 and 6. It has no effect if box is in sidebar.</comment>
793
+ <validate>validate-number validate-number-range number-range-1-6</validate>
794
+ <depends>
795
+ <personal_box>1</personal_box>
796
+ <personal_box_layout>content</personal_box_layout>
797
+ </depends>
798
+ </personal_box_columns>
799
+ <top_heading translate="label">
800
+ <label>Top Box (CATEGORY_PAGE_POP)</label>
801
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
802
+ <sort_order>55</sort_order>
803
+ <show_in_default>1</show_in_default>
804
+ <show_in_website>1</show_in_website>
805
+ <show_in_store>1</show_in_store>
806
+ </top_heading>
807
+ <top_box translate="label">
808
+ <label>Enable Top Box</label>
809
+ <frontend_type>select</frontend_type>
810
+ <source_model>adminhtml/system_config_source_yesno</source_model>
811
+ <sort_order>60</sort_order>
812
+ <show_in_default>1</show_in_default>
813
+ <show_in_website>1</show_in_website>
814
+ <show_in_store>1</show_in_store>
815
+ <comment>Enable "Top products" box on category page view.</comment>
816
+ </top_box>
817
+ <top_box_layout translate="label">
818
+ <label>Top Box Layout</label>
819
+ <frontend_type>select</frontend_type>
820
+ <source_model>me_gravity/system_config_source_layout_layout</source_model>
821
+ <sort_order>70</sort_order>
822
+ <show_in_default>1</show_in_default>
823
+ <show_in_website>1</show_in_website>
824
+ <show_in_store>1</show_in_store>
825
+ <comment>Select where "Top products" box should be shown on category page view.</comment>
826
+ <depends><top_box>1</top_box></depends>
827
+ </top_box_layout>
828
+ <top_box_title translate="label">
829
+ <label>Top Box Title</label>
830
+ <frontend_type>text</frontend_type>
831
+ <sort_order>80</sort_order>
832
+ <show_in_default>1</show_in_default>
833
+ <show_in_website>1</show_in_website>
834
+ <show_in_store>1</show_in_store>
835
+ <comment>"Top products" box title on category page view.</comment>
836
+ <depends><top_box>1</top_box></depends>
837
+ </top_box_title>
838
+ <top_box_limit translate="label">
839
+ <label>Top Box Product Count</label>
840
+ <frontend_type>text</frontend_type>
841
+ <sort_order>90</sort_order>
842
+ <show_in_default>1</show_in_default>
843
+ <show_in_website>1</show_in_website>
844
+ <show_in_store>1</show_in_store>
845
+ <comment>Number of items show in "Top products" box on category page view. This number must be between 1 and 10.</comment>
846
+ <validate>validate-number validate-number-range number-range-1-10</validate>
847
+ <depends><top_box>1</top_box></depends>
848
+ </top_box_limit>
849
+ <top_box_columns translate="label">
850
+ <label>Top Box Columns</label>
851
+ <frontend_type>text</frontend_type>
852
+ <sort_order>100</sort_order>
853
+ <show_in_default>1</show_in_default>
854
+ <show_in_website>1</show_in_website>
855
+ <show_in_store>1</show_in_store>
856
+ <comment>Columns count in "Top products" box on category page view. This number must be between 1 and 6. It has no effect if box is in sidebar.</comment>
857
+ <validate>validate-number validate-number-range number-range-1-6</validate>
858
+ <depends>
859
+ <top_box>1</top_box>
860
+ <top_box_layout>content</top_box_layout>
861
+ </depends>
862
+ </top_box_columns>
863
+ </fields>
864
+ </category_display>
865
+ <search_display translate="label">
866
+ <label>Search Result Page Display</label>
867
+ <frontend_type>text</frontend_type>
868
+ <sort_order>70</sort_order>
869
+ <show_in_default>1</show_in_default>
870
+ <show_in_website>1</show_in_website>
871
+ <show_in_store>1</show_in_store>
872
+ <fields>
873
+ <search_heading translate="label">
874
+ <label>Recommendation Box (LISTING_PAGE)</label>
875
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
876
+ <sort_order>5</sort_order>
877
+ <show_in_default>1</show_in_default>
878
+ <show_in_website>1</show_in_website>
879
+ <show_in_store>1</show_in_store>
880
+ </search_heading>
881
+ <search_box translate="label">
882
+ <label>Enable Recommendation Box</label>
883
+ <frontend_type>select</frontend_type>
884
+ <source_model>adminhtml/system_config_source_yesno</source_model>
885
+ <sort_order>10</sort_order>
886
+ <show_in_default>1</show_in_default>
887
+ <show_in_website>1</show_in_website>
888
+ <show_in_store>1</show_in_store>
889
+ <comment>Enable "Recommended for you" box on search result page view.</comment>
890
+ </search_box>
891
+ <search_box_layout translate="label">
892
+ <label>Recommendation Box Layout</label>
893
+ <frontend_type>select</frontend_type>
894
+ <source_model>me_gravity/system_config_source_layout_layout</source_model>
895
+ <sort_order>20</sort_order>
896
+ <show_in_default>1</show_in_default>
897
+ <show_in_website>1</show_in_website>
898
+ <show_in_store>1</show_in_store>
899
+ <comment>Select where "Recommended for you" box should be shown on search result page view.</comment>
900
+ <depends><search_box>1</search_box></depends>
901
+ </search_box_layout>
902
+ <search_box_title translate="label">
903
+ <label>Recommendation Box Title</label>
904
+ <frontend_type>text</frontend_type>
905
+ <sort_order>30</sort_order>
906
+ <show_in_default>1</show_in_default>
907
+ <show_in_website>1</show_in_website>
908
+ <show_in_store>1</show_in_store>
909
+ <comment>"Recommended for you" box title on search result page view.</comment>
910
+ <depends><search_box>1</search_box></depends>
911
+ </search_box_title>
912
+ <search_box_limit translate="label">
913
+ <label>Recommendation Box Product Count</label>
914
+ <frontend_type>text</frontend_type>
915
+ <sort_order>40</sort_order>
916
+ <show_in_default>1</show_in_default>
917
+ <show_in_website>1</show_in_website>
918
+ <show_in_store>1</show_in_store>
919
+ <comment>Number of items show in "Recommended for you" box on search result page view. This number must be between 1 and 10.</comment>
920
+ <validate>validate-number validate-number-range number-range-1-10</validate>
921
+ <depends><search_box>1</search_box></depends>
922
+ </search_box_limit>
923
+ <search_box_columns translate="label">
924
+ <label>Recommendation Box Columns</label>
925
+ <frontend_type>text</frontend_type>
926
+ <sort_order>50</sort_order>
927
+ <show_in_default>1</show_in_default>
928
+ <show_in_website>1</show_in_website>
929
+ <show_in_store>1</show_in_store>
930
+ <comment>Columns count in "Recommended for you" box on search result page view. This number must be between 1 and 6. It has no effect if box is in sidebar.</comment>
931
+ <validate>validate-number validate-number-range number-range-1-6</validate>
932
+ <depends>
933
+ <search_box>1</search_box>
934
+ <search_box_layout>content</search_box_layout>
935
+ </depends>
936
+ </search_box_columns>
937
+ </fields>
938
+ </search_display>
939
+ <cart_display translate="label">
940
+ <label>Cart Page Display</label>
941
+ <frontend_type>text</frontend_type>
942
+ <sort_order>80</sort_order>
943
+ <show_in_default>1</show_in_default>
944
+ <show_in_website>1</show_in_website>
945
+ <show_in_store>1</show_in_store>
946
+ <fields>
947
+ <cart_heading translate="label">
948
+ <label>Cart Box (CART_PAGE)</label>
949
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
950
+ <sort_order>5</sort_order>
951
+ <show_in_default>1</show_in_default>
952
+ <show_in_website>1</show_in_website>
953
+ <show_in_store>1</show_in_store>
954
+ </cart_heading>
955
+ <cart_box translate="label">
956
+ <label>Enable Cart Box</label>
957
+ <frontend_type>select</frontend_type>
958
+ <source_model>adminhtml/system_config_source_yesno</source_model>
959
+ <sort_order>10</sort_order>
960
+ <show_in_default>1</show_in_default>
961
+ <show_in_website>1</show_in_website>
962
+ <show_in_store>1</show_in_store>
963
+ <comment>Enable "Others also bought" box on cart page view.</comment>
964
+ </cart_box>
965
+ <cart_box_layout translate="label">
966
+ <label>Cart Box Layout</label>
967
+ <frontend_type>select</frontend_type>
968
+ <source_model>me_gravity/system_config_source_layout_layout</source_model>
969
+ <sort_order>20</sort_order>
970
+ <show_in_default>1</show_in_default>
971
+ <show_in_website>1</show_in_website>
972
+ <show_in_store>1</show_in_store>
973
+ <comment>Select where "Others also bought" box should be shown on cart page view.</comment>
974
+ <depends><cart_box>1</cart_box></depends>
975
+ </cart_box_layout>
976
+ <cart_box_title translate="label">
977
+ <label>Cart Box Title</label>
978
+ <frontend_type>text</frontend_type>
979
+ <sort_order>30</sort_order>
980
+ <show_in_default>1</show_in_default>
981
+ <show_in_website>1</show_in_website>
982
+ <show_in_store>1</show_in_store>
983
+ <comment>"Others also bought" box title on cart page view.</comment>
984
+ <depends><cart_box>1</cart_box></depends>
985
+ </cart_box_title>
986
+ <cart_box_limit translate="label">
987
+ <label>Cart Box Product Count</label>
988
+ <frontend_type>text</frontend_type>
989
+ <sort_order>40</sort_order>
990
+ <show_in_default>1</show_in_default>
991
+ <show_in_website>1</show_in_website>
992
+ <show_in_store>1</show_in_store>
993
+ <comment>Number of items show in "Others also bought" box on cart page view. This number must be between 1 and 10.</comment>
994
+ <validate>validate-number validate-number-range number-range-1-10</validate>
995
+ <depends><cart_box>1</cart_box></depends>
996
+ </cart_box_limit>
997
+ <cart_box_columns translate="label">
998
+ <label>Cart Box Columns</label>
999
+ <frontend_type>text</frontend_type>
1000
+ <sort_order>50</sort_order>
1001
+ <show_in_default>1</show_in_default>
1002
+ <show_in_website>1</show_in_website>
1003
+ <show_in_store>1</show_in_store>
1004
+ <comment>Columns count in "Others also bought" box on cart page view. This number must be between 1 and 6. It has no effect if box is in sidebar.</comment>
1005
+ <validate>validate-number validate-number-range number-range-1-6</validate>
1006
+ <depends>
1007
+ <cart_box>1</cart_box>
1008
+ <cart_box_layout>content</cart_box_layout>
1009
+ </depends>
1010
+ </cart_box_columns>
1011
+ </fields>
1012
+ </cart_display>
1013
+ <sync translate="label">
1014
+ <label>Synchronization</label>
1015
+ <frontend_type>text</frontend_type>
1016
+ <sort_order>90</sort_order>
1017
+ <show_in_default>1</show_in_default>
1018
+ <show_in_website>1</show_in_website>
1019
+ <show_in_store>1</show_in_store>
1020
+ <fields>
1021
+ <customer_update translate="label">
1022
+ <label>Enable Gravity Customer Update</label>
1023
+ <frontend_type>select</frontend_type>
1024
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1025
+ <sort_order>10</sort_order>
1026
+ <show_in_default>1</show_in_default>
1027
+ <show_in_website>1</show_in_website>
1028
+ <show_in_store>1</show_in_store>
1029
+ <comment>If customer is saved in backend it will be updated in Gravity.</comment>
1030
+ </customer_update>
1031
+ <product_update translate="label">
1032
+ <label>Enable Gravity Product Update</label>
1033
+ <frontend_type>select</frontend_type>
1034
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1035
+ <sort_order>20</sort_order>
1036
+ <show_in_default>1</show_in_default>
1037
+ <show_in_website>1</show_in_website>
1038
+ <show_in_store>1</show_in_store>
1039
+ <comment>If product is saved in backend it will be updated in Gravity.</comment>
1040
+ </product_update>
1041
+ <customer_registration translate="label">
1042
+ <label>Enable Gravity Customer Registration</label>
1043
+ <frontend_type>select</frontend_type>
1044
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1045
+ <sort_order>30</sort_order>
1046
+ <show_in_default>1</show_in_default>
1047
+ <show_in_website>1</show_in_website>
1048
+ <show_in_store>1</show_in_store>
1049
+ <comment>If customer is registered on frontend it will be added in Gravity.</comment>
1050
+ </customer_registration>
1051
+ </fields>
1052
+ </sync>
1053
+ <debug translate="label">
1054
+ <label>Debug</label>
1055
+ <frontend_type>text</frontend_type>
1056
+ <sort_order>100</sort_order>
1057
+ <show_in_default>1</show_in_default>
1058
+ <show_in_website>1</show_in_website>
1059
+ <show_in_store>1</show_in_store>
1060
+ <fields>
1061
+ <log translate="label">
1062
+ <label>Enable Debug</label>
1063
+ <frontend_type>select</frontend_type>
1064
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1065
+ <sort_order>10</sort_order>
1066
+ <show_in_default>1</show_in_default>
1067
+ <show_in_website>1</show_in_website>
1068
+ <show_in_store>1</show_in_store>
1069
+ <comment>Enable debug. In this case all transactions will be logged in /var/gravity.log.</comment>
1070
+ </log>
1071
+ </fields>
1072
+ </debug>
1073
+ </groups>
1074
+ </gravity>
1075
+ </sections>
1076
+ </config>
app/code/community/Me/Gravity/etc/widget.xml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Me
5
+ * @package Me_Gravity
6
+ * @author Attila Sági <sagi.attila@magevolve.com>
7
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
8
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
9
+ * @link http://magevolve.com
10
+ */
11
+ -->
12
+ <widgets>
13
+ <me_gravity type="me_gravity/widget_boxes_widget" translate="name description" module="me_gravity">
14
+ <name>Gravity Box Widget</name>
15
+ <description>Gravity recommendation products grid widget</description>
16
+ <parameters>
17
+ <event_type translate="label description">
18
+ <required>1</required>
19
+ <visible>1</visible>
20
+ <label>Recommendation Type</label>
21
+ <type>select</type>
22
+ <value>personal_best</value>
23
+ <values>
24
+ <default translate="label">
25
+ <value>personal_best</value>
26
+ <label>Recommended for you</label>
27
+ </default>
28
+ <personal translate="label">
29
+ <value>personal_history</value>
30
+ <label>You viewed</label>
31
+ </personal>
32
+ <currently translate="label">
33
+ <value>currently_viewed</value>
34
+ <label>Others are looking at right now</label>
35
+ </currently>
36
+ <popular translate="label">
37
+ <value>popular</value>
38
+ <label>Top products</label>
39
+ </popular>
40
+ </values>
41
+ <description>Type of Recommendation Box</description>
42
+ </event_type>
43
+ <template_type translate="label">
44
+ <visible>1</visible>
45
+ <label>Use Garvity Template</label>
46
+ <type>select</type>
47
+ <value>0</value>
48
+ <source_model>adminhtml/system_config_source_yesno</source_model>
49
+ <description>If YES all boxes will use Gravity template.</description>
50
+ </template_type>
51
+ <box_title translate="label">
52
+ <required>1</required>
53
+ <visible>1</visible>
54
+ <value>Recommended Item(s)</value>
55
+ <label>Box Title</label>
56
+ <type>text</type>
57
+ <description>Title of Recommendation Box</description>
58
+ </box_title>
59
+ <box_limit translate="label">
60
+ <required>1</required>
61
+ <visible>1</visible>
62
+ <value>5</value>
63
+ <label>Number of Products to Display</label>
64
+ <type>text</type>
65
+ <description>Number of items show in Recommendation Box</description>
66
+ <validate>validate-number validate-number-range number-range-1-10</validate>
67
+ </box_limit>
68
+ <box_columns translate="label">
69
+ <required>1</required>
70
+ <visible>1</visible>
71
+ <value>4</value>
72
+ <label>Columns</label>
73
+ <type>text</type>
74
+ <description>Columns count in Recommendation Box</description>
75
+ <validate>validate-number validate-number-range number-range-1-6</validate>
76
+ <depends><template_type><value>0</value></template_type></depends>
77
+ </box_columns>
78
+ <template>
79
+ <required>1</required>
80
+ <visible>0</visible>
81
+ <value>me/gravity/widget/boxes/widget.phtml</value>
82
+ </template>
83
+ </parameters>
84
+ </me_gravity>
85
+ </widgets>
app/design/adminhtml/default/default/template/me/gravity/system/config/form/test.phtml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Adminhtml_System_Config_Form_Test
4
+ *
5
+ * @category Me
6
+ * @package Me_Salesautopilot
7
+ * @author Sági Attila <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Adminhtml_System_Config_Form_Test
16
+ */
17
+ ?>
18
+ <script type="text/javascript">
19
+ //<![CDATA[
20
+ function check() {
21
+ new Ajax.Request('<?php echo $this->getAjaxTestUrl() ?>', {
22
+ method: 'get',
23
+ type: 'json',
24
+ onSuccess: function (transport) {
25
+ var result = transport.responseText.evalJSON();
26
+ if (result.success) {
27
+ alert(result.message);
28
+ } else {
29
+ alert(result.message);
30
+ window.location.reload();
31
+ }
32
+ }
33
+ });
34
+ }
35
+ //]]>
36
+ </script>
37
+
38
+ <?php echo $this->getButtonHtml() ?>
app/design/frontend/base/default/layout/me/gravity.xml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Me
5
+ * @package Me_Gravity
6
+ * @author Attila Sági <sagi.attila@magevolve.com>
7
+ * @copyright 2014 Magevolve Ltd. (http://magevolve.com)
8
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
9
+ * @link http://magevolve.com
10
+ */
11
+ -->
12
+ <layout version="0.1.0">
13
+ <default>
14
+ <reference name="head">
15
+ <reference name="head">
16
+ <action method="addCss" ifconfig="gravity/config/enabled"><stylesheet>css/me/gravity/gravity.css</stylesheet></action>
17
+ <block type="me_gravity/page_js_gravity" name="me.gravity.head.js" template="me/gravity/page/js/gravity.phtml"/>
18
+ </reference>
19
+ </reference>
20
+ <reference name="before_body_end">
21
+ <block type="me_gravity/page_js_gravity" name="me.gravity.before.body.end.js" template="me/gravity/page/js/body-end.phtml" />
22
+ </reference>
23
+ </default>
24
+
25
+ <catalog_product_view>
26
+ <reference name="before_body_end">
27
+ <block type="me_gravity/catalog_product_view_js_gravity" name="me.gravity.product.push.js" template="me/gravity/catalog/product/view/js/gravity.phtml" />
28
+ </reference>
29
+ </catalog_product_view>
30
+
31
+ <catalogsearch_result_index>
32
+ <reference name="before_body_end">
33
+ <block type="me_gravity/catalogsearch_js_gravity" name="me.gravity.catalogsearch.push.js" template="me/gravity/catalogsearch/js/gravity.phtml"/>
34
+ </reference>
35
+ </catalogsearch_result_index>
36
+
37
+ <catalogsearch_advanced_result>
38
+ <reference name="before_body_end">
39
+ <block type="me_gravity/catalogsearch_advanced_js_gravity" name="me.gravity.catalogsearch.advanced.push.js" template="me/gravity/catalogsearch/advanced/js/gravity.phtml"/>
40
+ </reference>
41
+ </catalogsearch_advanced_result>
42
+
43
+ </layout>
app/design/frontend/base/default/template/me/gravity/catalog/category/boxes/default.phtml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Recommendation
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Recommendation
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
21
+ <div class="block-title">
22
+ <?php if($title = $this->getRecommendationTitle()) : ?>
23
+ <strong><span><?php echo $title ?></span></strong>
24
+ <?php else : ?>
25
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="block-content"><?php echo $gravityHelper->__('Recommendations will be displayed here') ?></div>
29
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
30
+ <ul class="recItems products-grid gravity-<?php echo $this->getBoxClass() ?>-grid" class="block-content" style="background: none;">
31
+ {for p in products}
32
+ <li class="item" style="min-height: 200px;">
33
+ <a class="product-image" href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">
34
+ <img width="90" src='${p.ImageUrl}' />
35
+ </a>
36
+ <div class="recItemTitle product-name">
37
+ <a class="recItemTitle product-name" href="${p.Url}" onmousedown="_gravity.push({type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a>
38
+ </div>
39
+ <div class="clearer"></div>
40
+ </li>
41
+ {/for}
42
+ </ul>
43
+ <div class="clearer"></div>
44
+ </div>
45
+ </div>
46
+ <script type="text/javascript">
47
+ //<![CDATA[
48
+ _gravity.push({
49
+ type: "recommendation",
50
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
51
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
52
+ <?php if($filters = $this->getFilters()) : ?>
53
+ <?php foreach($filters as $attributeCode => $value) : ?>
54
+ <?php echo $attributeCode ?>: "<?php echo $value ?>",
55
+ <?php endforeach; ?>
56
+ <?php endif; ?>
57
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
58
+ templating: {
59
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
60
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
61
+ }
62
+ });
63
+ //]]>
64
+ </script>
65
+ <?php else : ?>
66
+ <?php $items = $this->getProductCollection(); ?>
67
+ <?php if (!is_null($items) && $items->count()) : ?>
68
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
69
+ <div class="block-title">
70
+ <?php if($title = $this->getRecommendationTitle()) : ?>
71
+ <strong><span><?php echo $title ?></span></strong>
72
+ <?php else : ?>
73
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
74
+ <?php endif; ?>
75
+ </div>
76
+ <div class="block-content">
77
+ <?php $_collectionSize = $items->count(); ?>
78
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
79
+ <?php $i = 0; foreach ($items as $_product): ?>
80
+ <?php if ($i++%$_columnCount==0): ?>
81
+ <ul class="products-grid gravity-<?php echo $this->getBoxClass() ?>-grid" style="background: none;">
82
+ <?php endif ?>
83
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
84
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
85
+ <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->stripTags($_product->getName(), null, true) ?></a></h3>
86
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
87
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
88
+ </li>
89
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
90
+ </ul>
91
+ <?php endif; ?>
92
+ <?php endforeach; ?>
93
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
94
+ </div>
95
+ </div>
96
+ <?php endif; ?>
97
+ <?php endif; ?>
app/design/frontend/base/default/template/me/gravity/catalog/category/boxes/sidebar.phtml ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Recommendation
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Recommendation
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
21
+ <div class="block-title">
22
+ <?php if($title = $this->getRecommendationTitle()) : ?>
23
+ <strong><span><?php echo $title ?></span></strong>
24
+ <?php else : ?>
25
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="block-content"></div>
29
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
30
+ <ol class="recItems mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
31
+ {for p in products}
32
+ <li class="item">
33
+ <div class="product">
34
+ <a href="${p.Url}" title="${p.title}" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});"><img src="${p.ImageUrl}" width="50" alt=">${p.title}" /></a>
35
+ <div class="product-details">
36
+ <p class="recItemTitle product-name"><a href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a></p>
37
+ </div>
38
+ </div>
39
+ <div class="clearer"></div>
40
+ </li>
41
+ {/for}
42
+ </ol>
43
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
44
+ </div>
45
+ </div>
46
+ <script type="text/javascript">
47
+ //<![CDATA[
48
+ _gravity.push({
49
+ type: "recommendation",
50
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
51
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
52
+ <?php if($filters = $this->getFilters()) : ?>
53
+ <?php foreach($filters as $attributeCode => $value) : ?>
54
+ <?php echo $attributeCode ?>: "<?php echo $value ?>",
55
+ <?php endforeach; ?>
56
+ <?php endif; ?>
57
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
58
+ templating: {
59
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
60
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
61
+ }
62
+ });
63
+ //]]>
64
+ </script>
65
+ <?php else : ?>
66
+ <?php $items = $this->getProductCollection(); ?>
67
+ <?php if (!is_null($items) && $items->count()) : ?>
68
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
69
+ <div class="block-title">
70
+ <?php if($title = $this->getRecommendationTitle()) : ?>
71
+ <strong><span><?php echo $title ?></span></strong>
72
+ <?php else : ?>
73
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
74
+ <?php endif; ?>
75
+ </div>
76
+ <div class="block-content">
77
+ <?php $_collectionSize = $items->count(); ?>
78
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
79
+ <?php $i = 0; foreach ($items as $_product): ?>
80
+ <ol class="mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
81
+ <li class="item">
82
+ <div class="product">
83
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_product->getName()) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(50) ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($_product->getName()) ?>" /></a>
84
+ <div class="product-details">
85
+ <p class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->escapeHtml($_product->getName()) ?></a></p>
86
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
87
+ </div>
88
+ </div>
89
+ </li>
90
+ </ol>
91
+ <?php endforeach; ?>
92
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
93
+ </div>
94
+ </div>
95
+ <?php endif; ?>
96
+ <?php endif; ?>
app/design/frontend/base/default/template/me/gravity/catalog/product/view/boxes/default.phtml ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Recommendation
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Recommendation
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
21
+ <div class="block-title">
22
+ <?php if($title = $this->getRecommendationTitle()) : ?>
23
+ <strong><span><?php echo $title ?></span></strong>
24
+ <?php else : ?>
25
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div id="target-<?php echo $this->getBoxClass() ?>"><?php echo $gravityHelper->__('Recommendations will be displayed here') ?></div>
29
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
30
+ <ul class="recItems products-grid gravity-<?php echo $this->getBoxClass() ?>-grid" class="block-content" style="background: none;">
31
+ {for p in products}
32
+ <li class="item" style="min-height: 200px;">
33
+ <a class="product-image" href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">
34
+ <img width="90" src='${p.ImageUrl}' />
35
+ </a>
36
+ <div class="recItemTitle product-name">
37
+ <a class="recItemTitle product-name" href="${p.Url}" onmousedown="_gravity.push({type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a>
38
+ </div>
39
+ <div class="clearer"></div>
40
+ </li>
41
+ {/for}
42
+ </ul>
43
+ <div class="clearer"></div>
44
+ </div>
45
+ </div>
46
+ <script type="text/javascript">
47
+ //<![CDATA[
48
+ _gravity.push({
49
+ type: "recommendation",
50
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
51
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
52
+ <?php if($productId = $this->getProduct()->getId()) : ?>
53
+ currentItemId: "ItemID_<?php echo $productId ?>",
54
+ <?php endif; ?>
55
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
56
+ templating: {
57
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
58
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
59
+ }
60
+ });
61
+ //]]>
62
+ </script>
63
+ <?php else : ?>
64
+ <?php $items = $this->getProductCollection(); ?>
65
+ <?php if (!is_null($items) && $items->count()) : ?>
66
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
67
+ <div class="block-title">
68
+ <?php if($title = $this->getRecommendationTitle()) : ?>
69
+ <strong><span><?php echo $title ?></span></strong>
70
+ <?php else : ?>
71
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
72
+ <?php endif; ?>
73
+ </div>
74
+ <div class="block-content">
75
+ <?php $_collectionSize = $items->count(); ?>
76
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
77
+ <?php $i = 0; foreach ($items as $_product): ?>
78
+ <?php if ($i++%$_columnCount==0): ?>
79
+ <ul class="products-grid gravity-<?php echo $this->getBoxClass() ?>-grid" style="background: none;">
80
+ <?php endif ?>
81
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
82
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
83
+ <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->stripTags($_product->getName(), null, true) ?></a></h3>
84
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
85
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
86
+ </li>
87
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
88
+ </ul>
89
+ <?php endif; ?>
90
+ <?php endforeach; ?>
91
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
92
+ </div>
93
+ </div>
94
+ <?php endif; ?>
95
+ <?php endif; ?>
app/design/frontend/base/default/template/me/gravity/catalog/product/view/boxes/sidebar.phtml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Catalog_Product_View_Recommendation
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Catalog_Product_View_Recommendation
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
21
+ <div class="block-title">
22
+ <?php if($title = $this->getRecommendationTitle()) : ?>
23
+ <strong><span><?php echo $title ?></span></strong>
24
+ <?php else : ?>
25
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="block-content"></div>
29
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
30
+ <ol class="recItems mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
31
+ {for p in products}
32
+ <li class="item">
33
+ <div class="product">
34
+ <a href="${p.Url}" title="${p.title}" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});"><img src="${p.ImageUrl}" width="50" alt=">${p.title}" /></a>
35
+ <div class="product-details">
36
+ <p class="recItemTitle product-name"><a href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a></p>
37
+ </div>
38
+ </div>
39
+ <div class="clearer"></div>
40
+ </li>
41
+ {/for}
42
+ </ol>
43
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
44
+ </div>
45
+ </div>
46
+ <script type="text/javascript">
47
+ //<![CDATA[
48
+ _gravity.push({
49
+ type: "recommendation",
50
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
51
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
52
+ <?php if($productId = $this->getProduct()->getId()) : ?>
53
+ currentItemId: "ItemID_<?php echo $productId ?>",
54
+ <?php endif; ?>
55
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
56
+ templating: {
57
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
58
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
59
+ }
60
+ });
61
+ //]]>
62
+ </script>
63
+ <?php else : ?>
64
+ <?php $items = $this->getProductCollection(); ?>
65
+ <?php if (!is_null($items) && $items->count()) : ?>
66
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
67
+ <div class="block-title">
68
+ <?php if($title = $this->getRecommendationTitle()) : ?>
69
+ <strong><span><?php echo $title ?></span></strong>
70
+ <?php else : ?>
71
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
72
+ <?php endif; ?>
73
+ </div>
74
+ <div class="block-content">
75
+ <?php $_collectionSize = $items->count(); ?>
76
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
77
+ <?php $i = 0; foreach ($items as $_product): ?>
78
+ <ol class="mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
79
+ <li class="item">
80
+ <div class="product">
81
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_product->getName()) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(50) ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($_product->getName()) ?>" /></a>
82
+ <div class="product-details">
83
+ <p class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->escapeHtml($_product->getName()) ?></a></p>
84
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
85
+ </div>
86
+ </div>
87
+ </li>
88
+ </ol>
89
+ <?php endforeach; ?>
90
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
91
+ </div>
92
+ </div>
93
+ <?php endif; ?>
94
+ <?php endif; ?>
app/design/frontend/base/default/template/me/gravity/catalog/product/view/js/gravity.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Catalog_Product_View_Js_Gravity
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2014 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * Gravity push script
16
+ *
17
+ * @see Me_Gravity_Block_Catalog_Product_View_Js_Gravity
18
+ */
19
+ ?>
20
+ <?php if ($this->isEnabled()) : ?>
21
+ <script type="text/javascript">
22
+ //<![CDATA[
23
+ _gravity = _gravity || [];
24
+ _gravity.push({
25
+ type: "set",
26
+ //mode: "PROD",
27
+ userId: "<?php echo $this->getCustomerId() ?>"
28
+ });
29
+
30
+ _gravity.push({
31
+ type: "event",
32
+ eventType: "VIEW",
33
+ itemId: "<?php echo $this->getProduct()->getId() ?>",
34
+ <?php if($categoryId = $this->getGravityCategoryId()) : ?>
35
+ categoryId: "<?php echo $categoryId ?>",
36
+ <?php endif; ?>
37
+ });
38
+ //]]>
39
+ </script>
40
+ <?php endif; ?>
app/design/frontend/base/default/template/me/gravity/catalogsearch/advanced/js/gravity.phtml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Catalogsearch_Advanced_Js_Gravity
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2014 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * Gravity push script
16
+ *
17
+ * @see Me_Gravity_Block_Catalogsearch_Advanced_Js_Gravity
18
+ */
19
+ ?>
20
+ <?php if ($this->isEnabled()) : ?>
21
+ <?php $searchCriterias = $this->getSearchCriterias(); ?>
22
+ <?php if($searchCriterias) : ?>
23
+ <script type="text/javascript">
24
+ //<![CDATA[
25
+ _gravity = _gravity || [];
26
+ _gravity.push({
27
+ type: "set",
28
+ userId: "<?php echo $this->getCustomerId() ?>"
29
+ });
30
+
31
+ _gravity.push({
32
+ type: "event",
33
+ eventType: "SEARCH",
34
+ <?php foreach ($searchCriterias as $criteria): ?>
35
+ <?php if(strtolower($criteria['name']) == 'price') : ?>
36
+ <?php $prices = explode(' - ', $criteria['value']); ?>
37
+ <?php if(isset($prices[0])) : ?>
38
+ minPrice: "<?php echo $prices[0] ?>",
39
+ <?php endif; ?>
40
+ <?php if(isset($prices[1])) : ?>
41
+ maxPrice: "<?php echo $prices[1] ?>",
42
+ <?php endif; ?>
43
+ <?php else : ?>
44
+ <?php echo $this->escapeHtml(strtolower($criteria['name'])); ?>:"<?php echo $this->escapeHtml(strtolower($criteria['value'])); ?>",
45
+ <?php endif; ?>
46
+ <?php endforeach; ?>
47
+ });
48
+ //]]>
49
+ </script>
50
+ <?php endif; ?>
51
+ <?php endif; ?>
app/design/frontend/base/default/template/me/gravity/catalogsearch/boxes/default.phtml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Checkout_Cart_Boxes_Cart
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Checkout_Cart_Boxes_Cart
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
21
+ <div class="block-title">
22
+ <?php if($title = $this->getRecommendationTitle()) : ?>
23
+ <strong><span><?php echo $title ?></span></strong>
24
+ <?php else : ?>
25
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="block-content"><?php echo $gravityHelper->__('Recommendations will be displayed here') ?></div>
29
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
30
+ <ul class="recItems products-grid gravity-<?php echo $this->getBoxClass() ?>-grid" class="block-content" style="background: none;">
31
+ {for p in products}
32
+ <li class="item" style="min-height: 200px;">
33
+ <a class="product-image" href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">
34
+ <img width="90" src='${p.ImageUrl}' />
35
+ </a>
36
+ <div class="recItemTitle product-name">
37
+ <a class="recItemTitle product-name" href="${p.Url}" onmousedown="_gravity.push({type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a>
38
+ </div>
39
+ <div class="clearer"></div>
40
+ </li>
41
+ {/for}
42
+ </ul>
43
+ <div class="clearer"></div>
44
+ </div>
45
+ </div>
46
+ <script type="text/javascript">
47
+ //<![CDATA[
48
+ _gravity.push({
49
+ type: "recommendation",
50
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
51
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
52
+ <?php if($searchKeywords = $this->getSearchKeywords()) : ?>
53
+ <?php foreach($searchKeywords as $attributeCode => $value) : ?>
54
+ <?php echo $attributeCode ?>: "<?php echo $value ?>",
55
+ <?php endforeach; ?>
56
+ <?php endif; ?>
57
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
58
+ templating: {
59
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
60
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
61
+ }
62
+ });
63
+ //]]>
64
+ </script>
65
+ <?php else : ?>
66
+ <?php $items = $this->getProductCollection(); ?>
67
+ <?php if (!is_null($items) && $items->count()) : ?>
68
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
69
+ <div class="block-title">
70
+ <?php if($title = $this->getRecommendationTitle()) : ?>
71
+ <strong><span><?php echo $title ?></span></strong>
72
+ <?php else : ?>
73
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
74
+ <?php endif; ?>
75
+ </div>
76
+ <div class="block-content">
77
+ <?php $_collectionSize = $items->count(); ?>
78
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
79
+ <?php $i = 0; foreach ($items as $_product): ?>
80
+ <?php if ($i++%$_columnCount==0): ?>
81
+ <ul class="products-grid gravity-<?php echo $this->getBoxClass() ?>-grid" style="background: none;">
82
+ <?php endif ?>
83
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
84
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
85
+ <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->stripTags($_product->getName(), null, true) ?></a></h3>
86
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
87
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
88
+ </li>
89
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
90
+ </ul>
91
+ <?php endif; ?>
92
+ <?php endforeach; ?>
93
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
94
+ </div>
95
+ </div>
96
+ <?php endif; ?>
97
+ <?php endif; ?>
app/design/frontend/base/default/template/me/gravity/catalogsearch/boxes/sidebar.phtml ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Checkout_Cart_Boxes_Cart
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Checkout_Cart_Boxes_Cart
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
21
+ <div class="block-title">
22
+ <?php if($title = $this->getRecommendationTitle()) : ?>
23
+ <strong><span><?php echo $title ?></span></strong>
24
+ <?php else : ?>
25
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="block-content"></div>
29
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
30
+ <ol class="recItems mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
31
+ {for p in products}
32
+ <li class="item">
33
+ <div class="product">
34
+ <a href="${p.Url}" title="${p.title}" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});"><img src="${p.ImageUrl}" width="50" alt=">${p.title}" /></a>
35
+ <div class="product-details">
36
+ <p class="recItemTitle product-name"><a href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a></p>
37
+ </div>
38
+ </div>
39
+ <div class="clearer"></div>
40
+ </li>
41
+ {/for}
42
+ </ol>
43
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
44
+ </div>
45
+ </div>
46
+ <script type="text/javascript">
47
+ //<![CDATA[
48
+ _gravity.push({
49
+ type: "recommendation",
50
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
51
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
52
+ <?php if($searchKeywords = $this->getSearchKeywords()) : ?>
53
+ <?php foreach($searchKeywords as $attributeCode => $value) : ?>
54
+ <?php echo $attributeCode ?>: "<?php echo $value ?>",
55
+ <?php endforeach; ?>
56
+ <?php endif; ?>
57
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
58
+ templating: {
59
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
60
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
61
+ }
62
+ });
63
+ //]]>
64
+ </script>
65
+ <?php else : ?>
66
+ <?php $items = $this->getProductCollection(); ?>
67
+ <?php if (!is_null($items) && $items->count()) : ?>
68
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
69
+ <div class="block-title">
70
+ <?php if($title = $this->getRecommendationTitle()) : ?>
71
+ <strong><span><?php echo $title ?></span></strong>
72
+ <?php else : ?>
73
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
74
+ <?php endif; ?>
75
+ </div>
76
+ <div class="block-content">
77
+ <?php $_collectionSize = $items->count(); ?>
78
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
79
+ <?php $i = 0; foreach ($items as $_product): ?>
80
+ <ol class="mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
81
+ <li class="item">
82
+ <div class="product">
83
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_product->getName()) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(50) ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($_product->getName()) ?>" /></a>
84
+ <div class="product-details">
85
+ <p class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->escapeHtml($_product->getName()) ?></a></p>
86
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
87
+ </div>
88
+ </div>
89
+ </li>
90
+ </ol>
91
+ <?php endforeach; ?>
92
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
93
+ </div>
94
+ </div>
95
+ <?php endif; ?>
96
+ <?php endif; ?>
app/design/frontend/base/default/template/me/gravity/catalogsearch/js/gravity.phtml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Catalogsearch_Js_Gravity
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2014 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * Gravity push script
16
+ *
17
+ * @see Me_Gravity_Block_Catalogsearch_Js_Gravity
18
+ */
19
+ ?>
20
+ <?php if ($this->isEnabled()) : ?>
21
+ <script type="text/javascript">
22
+ //<![CDATA[
23
+ _gravity = _gravity || [];
24
+ _gravity.push({
25
+ type: "set",
26
+ userId: "<?php echo $this->getCustomerId() ?>"
27
+ });
28
+
29
+ _gravity.push({
30
+ type: "event",
31
+ eventType: "SEARCH",
32
+ searchKeyword: "<?php echo $this->getSearchKeyword() ?>"
33
+ });
34
+ //]]>
35
+ </script>
36
+ <?php endif; ?>
app/design/frontend/base/default/template/me/gravity/checkout/cart/boxes/default.phtml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Checkout_Cart_Boxes_Cart
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Checkout_Cart_Boxes_Cart
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
21
+ <div class="block-title">
22
+ <?php if($title = $this->getRecommendationTitle()) : ?>
23
+ <strong><span><?php echo $title ?></span></strong>
24
+ <?php else : ?>
25
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="block-content"><?php echo $gravityHelper->__('Recommendations will be displayed here') ?></div>
29
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
30
+ <ul class="recItems products-grid gravity-<?php echo $this->getBoxClass() ?>-grid" class="block-content" style="background: none;">
31
+ {for p in products}
32
+ <li class="item" style="min-height: 200px;">
33
+ <a class="product-image" href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">
34
+ <img width="90" src='${p.ImageUrl}' />
35
+ </a>
36
+ <div class="recItemTitle product-name">
37
+ <a class="recItemTitle product-name" href="${p.Url}" onmousedown="_gravity.push({type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a>
38
+ </div>
39
+ <div class="clearer"></div>
40
+ </li>
41
+ {/for}
42
+ </ul>
43
+ <div class="clearer"></div>
44
+ </div>
45
+ </div>
46
+ <script type="text/javascript">
47
+ //<![CDATA[
48
+ _gravity.push({
49
+ type: "recommendation",
50
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
51
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
52
+ <?php if($itemIds = $this->getCartItems()) : ?>
53
+ <?php foreach($itemIds as $itemId) : ?>
54
+ cartItemId: "<?php echo $itemId ?>",
55
+ <?php endforeach; ?>
56
+ <?php endif; ?>
57
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
58
+ templating: {
59
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
60
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
61
+ }
62
+ });
63
+ //]]>
64
+ </script>
65
+ <?php else : ?>
66
+ <?php $items = $this->getProductCollection(); ?>
67
+ <?php if (!is_null($items) && $items->count()) : ?>
68
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
69
+ <div class="block-title">
70
+ <?php if($title = $this->getRecommendationTitle()) : ?>
71
+ <strong><span><?php echo $title ?></span></strong>
72
+ <?php else : ?>
73
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
74
+ <?php endif; ?>
75
+ </div>
76
+ <div class="block-content">
77
+ <?php $_collectionSize = $items->count(); ?>
78
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
79
+ <?php $i = 0; foreach ($items as $_product): ?>
80
+ <?php if ($i++%$_columnCount==0): ?>
81
+ <ul class="products-grid gravity-<?php echo $this->getBoxClass() ?>-grid" style="background: none;">
82
+ <?php endif ?>
83
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
84
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
85
+ <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->stripTags($_product->getName(), null, true) ?></a></h3>
86
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
87
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
88
+ </li>
89
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
90
+ </ul>
91
+ <?php endif; ?>
92
+ <?php endforeach; ?>
93
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
94
+ </div>
95
+ </div>
96
+ <?php endif; ?>
97
+ <?php endif; ?>
app/design/frontend/base/default/template/me/gravity/checkout/cart/boxes/sidebar.phtml ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Checkout_Cart_Boxes_Cart
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Checkout_Cart_Boxes_Cart
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
21
+ <div class="block-title">
22
+ <?php if($title = $this->getRecommendationTitle()) : ?>
23
+ <strong><span><?php echo $title ?></span></strong>
24
+ <?php else : ?>
25
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="block-content"></div>
29
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
30
+ <ol class="recItems mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
31
+ {for p in products}
32
+ <li class="item">
33
+ <div class="product">
34
+ <a href="${p.Url}" title="${p.title}" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});"><img src="${p.ImageUrl}" width="50" alt=">${p.title}" /></a>
35
+ <div class="product-details">
36
+ <p class="recItemTitle product-name"><a href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a></p>
37
+ </div>
38
+ </div>
39
+ <div class="clearer"></div>
40
+ </li>
41
+ {/for}
42
+ </ol>
43
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
44
+ </div>
45
+ </div>
46
+ <script type="text/javascript">
47
+ //<![CDATA[
48
+ _gravity.push({
49
+ type: "recommendation",
50
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
51
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
52
+ <?php if($itemIds = $this->getCartItems()) : ?>
53
+ <?php foreach($itemIds as $itemId) : ?>
54
+ cartItemId: "<?php echo $itemId ?>",
55
+ <?php endforeach; ?>
56
+ <?php endif; ?>
57
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
58
+ templating: {
59
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
60
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
61
+ }
62
+ });
63
+ //]]>
64
+ </script>
65
+ <?php else : ?>
66
+ <?php $items = $this->getProductCollection(); ?>
67
+ <?php if (!is_null($items) && $items->count()) : ?>
68
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
69
+ <div class="block-title">
70
+ <?php if($title = $this->getRecommendationTitle()) : ?>
71
+ <strong><span><?php echo $title ?></span></strong>
72
+ <?php else : ?>
73
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
74
+ <?php endif; ?>
75
+ </div>
76
+ <div class="block-content">
77
+ <?php $_collectionSize = $items->count(); ?>
78
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
79
+ <?php $i = 0; foreach ($items as $_product): ?>
80
+ <ol class="mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
81
+ <li class="item">
82
+ <div class="product">
83
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_product->getName()) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(50) ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($_product->getName()) ?>" /></a>
84
+ <div class="product-details">
85
+ <p class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->escapeHtml($_product->getName()) ?></a></p>
86
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
87
+ </div>
88
+ </div>
89
+ </li>
90
+ </ol>
91
+ <?php endforeach; ?>
92
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
93
+ </div>
94
+ </div>
95
+ <?php endif; ?>
96
+ <?php endif; ?>
app/design/frontend/base/default/template/me/gravity/general/boxes/default.phtml ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Recommendation
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Recommendation
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
21
+ <div class="block-title">
22
+ <?php if($title = $this->getRecommendationTitle()) : ?>
23
+ <strong><span><?php echo $title ?></span></strong>
24
+ <?php else : ?>
25
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="block-content"><?php echo $gravityHelper->__('Recommendations will be displayed here') ?></div>
29
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
30
+ <ul class="recItems products-grid gravity-<?php echo $this->getBoxClass() ?>-grid" style="background: none;">
31
+ {for p in products}
32
+ <li class="item" style="min-height: 200px;">
33
+ <a class="product-image" href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">
34
+ <img width="90" src='${p.ImageUrl}' />
35
+ </a>
36
+ <div class="recItemTitle product-name">
37
+ <a class="recItemTitle product-name" href="${p.Url}" onmousedown="_gravity.push({type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a>
38
+ </div>
39
+ <div class="clearer"></div>
40
+ </li>
41
+ {/for}
42
+ </ul>
43
+ <div class="clearer"></div>
44
+ </div>
45
+ </div>
46
+ <script type="text/javascript">
47
+ //<![CDATA[
48
+ _gravity.push({
49
+ type: "recommendation",
50
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
51
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
52
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
53
+ templating: {
54
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
55
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
56
+ }
57
+ });
58
+ //]]>
59
+ </script>
60
+ <?php else : ?>
61
+ <?php $items = $this->getProductCollection(); ?>
62
+ <?php if (!is_null($items) && $items->count()) : ?>
63
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
64
+ <div class="block-title">
65
+ <?php if($title = $this->getRecommendationTitle()) : ?>
66
+ <strong><span><?php echo $title ?></span></strong>
67
+ <?php else : ?>
68
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
69
+ <?php endif; ?>
70
+ </div>
71
+ <div class="block-content">
72
+ <?php $_collectionSize = $items->count(); ?>
73
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
74
+ <?php $i = 0; foreach ($items as $_product): ?>
75
+ <?php if ($i++%$_columnCount==0): ?>
76
+ <ul class="products-grid gravity-<?php echo $this->getBoxClass() ?>-grid" style="background: none;">
77
+ <?php endif ?>
78
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
79
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
80
+ <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->stripTags($_product->getName(), null, true) ?></a></h3>
81
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
82
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
83
+ </li>
84
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
85
+ </ul>
86
+ <?php endif; ?>
87
+ <?php endforeach; ?>
88
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
89
+ </div>
90
+ </div>
91
+ <?php endif; ?>
92
+ <?php endif; ?>
app/design/frontend/base/default/template/me/gravity/general/boxes/sidebar.phtml ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Recommendation
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Recommendation
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
21
+ <div class="block-title">
22
+ <?php if($title = $this->getRecommendationTitle()) : ?>
23
+ <strong><span><?php echo $title ?></span></strong>
24
+ <?php else : ?>
25
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="block-content"></div>
29
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
30
+ <ol class="recItems mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
31
+ {for p in products}
32
+ <li class="item">
33
+ <div class="product">
34
+ <a href="${p.Url}" title="${p.title}" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});"><img src="${p.ImageUrl}" width="50" alt=">${p.title}" /></a>
35
+ <div class="product-details">
36
+ <p class="recItemTitle product-name"><a href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a></p>
37
+ </div>
38
+ </div>
39
+ <div class="clearer"></div>
40
+ </li>
41
+ {/for}
42
+ </ol>
43
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
44
+ </div>
45
+ </div>
46
+ <script type="text/javascript">
47
+ //<![CDATA[
48
+ _gravity.push({
49
+ type: "recommendation",
50
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
51
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
52
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
53
+ templating: {
54
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
55
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
56
+ }
57
+ });
58
+ //]]>
59
+ </script>
60
+ <?php else : ?>
61
+ <?php $items = $this->getProductCollection(); ?>
62
+ <?php if (!is_null($items) && $items->count()) : ?>
63
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
64
+ <div class="block-title">
65
+ <?php if($title = $this->getRecommendationTitle()) : ?>
66
+ <strong><span><?php echo $title ?></span></strong>
67
+ <?php else : ?>
68
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
69
+ <?php endif; ?>
70
+ </div>
71
+ <div class="block-content">
72
+ <?php $_collectionSize = $items->count(); ?>
73
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
74
+ <?php $i = 0; foreach ($items as $_product): ?>
75
+ <ol class="mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
76
+ <li class="item">
77
+ <div class="product">
78
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_product->getName()) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(50) ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($_product->getName()) ?>" /></a>
79
+ <div class="product-details">
80
+ <p class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->escapeHtml($_product->getName()) ?></a></p>
81
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
82
+ </div>
83
+ </div>
84
+ </li>
85
+ </ol>
86
+ <?php endforeach; ?>
87
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
88
+ </div>
89
+ </div>
90
+ <?php endif; ?>
91
+ <?php endif; ?>
app/design/frontend/base/default/template/me/gravity/page/js/body-end.phtml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Js_Gravity
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2014 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * Gravity initialization script
16
+ *
17
+ * @see Me_Gravity_Block_Page_Js_Gravity
18
+ */
19
+ ?>
20
+ <?php if($this->isEnabled() && $this->getGravityCustomerId() && $customerId = $this->getCustomerId()) : ?>
21
+ <script type="text/javascript">
22
+ //<![CDATA[
23
+ _gravity = _gravity || [];
24
+ _gravity.push({
25
+ type: "set",
26
+ //mode: "DEVELOP",
27
+ userId: "<?php echo $customerId ?>"
28
+ });
29
+ //]]>
30
+ </script>
31
+ <?php endif; ?>
app/design/frontend/base/default/template/me/gravity/page/js/gravity.phtml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Js_Gravity
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2014 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * Gravity initialization script
16
+ *
17
+ * @see Me_Gravity_Block_Page_Js_Gravity
18
+ */
19
+ ?>
20
+ <?php if($this->isEnabled() && $this->getGravityCustomerId()) : ?>
21
+ <script type="text/javascript">
22
+ //<![CDATA[
23
+ var _gravity = _gravity || [];
24
+ (function() {
25
+ var gr = document.createElement("script");
26
+ gr.type = "text/javascript";
27
+ gr.async = !0;
28
+ //gr.src = document.location.protocol + "//saas.gravityrd.com/js/CUSTOMERID/gr_reco4-min.js";
29
+ gr.src = "http://<?php echo $this->getGravityCustomerId() ?>-bud.gravityrd-services.com/js/<?php echo $this->getGravityCustomerId() ?>/gr_reco4-min.js";
30
+ var s = document.getElementsByTagName("script")[0];
31
+ s.parentNode.insertBefore(gr, s);
32
+ })();
33
+ //]]>
34
+ </script>
35
+ <?php endif; ?>
app/design/frontend/base/default/template/me/gravity/widget/boxes/widget.phtml ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Widget_Boxes_Widget
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Widget_Boxes_Widget
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($this->getTemplateType()) : ?>
20
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
21
+ <div class="block-title">
22
+ <?php if($title = $this->getRecommendationTitle()) : ?>
23
+ <strong><span><?php echo $title ?></span></strong>
24
+ <?php else : ?>
25
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="block-content"><?php echo $gravityHelper->__('Recommendations will be displayed here') ?></div>
29
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
30
+ <ul class="recItems products-grid gravity-<?php echo $this->getBoxClass() ?>-grid" style="background: none;">
31
+ {for p in products}
32
+ <li class="item" style="min-height: 200px;">
33
+ <a class="product-image" href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">
34
+ <img width="90" src='${p.ImageUrl}' />
35
+ </a>
36
+ <div class="recItemTitle product-name">
37
+ <a class="recItemTitle product-name" href="${p.Url}" onmousedown="_gravity.push({type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a>
38
+ </div>
39
+ <div class="clearer"></div>
40
+ </li>
41
+ {/for}
42
+ </ul>
43
+ <div class="clearer"></div>
44
+ </div>
45
+ </div>
46
+ <script type="text/javascript">
47
+ //<![CDATA[
48
+ _gravity.push({
49
+ type: "recommendation",
50
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
51
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
52
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
53
+ templating: {
54
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
55
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
56
+ }
57
+ });
58
+ //]]>
59
+ </script>
60
+ <?php else : ?>
61
+ <?php $items = $this->getProductCollection(); ?>
62
+ <?php if (!is_null($items) && $items->count()) : ?>
63
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
64
+ <div class="block-title">
65
+ <?php if($title = $this->getRecommendationTitle()) : ?>
66
+ <strong><span><?php echo $title ?></span></strong>
67
+ <?php else : ?>
68
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
69
+ <?php endif; ?>
70
+ </div>
71
+ <div class="block-content">
72
+ <?php $_collectionSize = $items->count(); ?>
73
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
74
+ <?php $i = 0; foreach ($items as $_product): ?>
75
+ <?php if ($i++%$_columnCount==0): ?>
76
+ <ul class="products-grid gravity-<?php echo $this->getBoxClass() ?>-grid" style="background: none;">
77
+ <?php endif ?>
78
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
79
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(135); ?>" width="135" height="135" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
80
+ <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->stripTags($_product->getName(), null, true) ?></a></h3>
81
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
82
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
83
+ </li>
84
+ <?php if ($i%$_columnCount==0 || $i==$_collectionSize): ?>
85
+ </ul>
86
+ <?php endif; ?>
87
+ <?php endforeach; ?>
88
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
89
+ </div>
90
+ </div>
91
+ <?php endif; ?>
92
+ <?php endif; ?>
app/design/frontend/rwd/default/template/me/gravity/catalog/category/boxes/default.phtml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Recommendation
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Recommendation
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <?php $_columnCount = 5; ?>
21
+ <div class="box box-<?php echo $this->getBoxClass() ?>">
22
+ <div class="box-head">
23
+ <?php if($title = $this->getRecommendationTitle()) : ?>
24
+ <h3><?php echo $title ?></h3>
25
+ <?php else : ?>
26
+ <h3><?php echo $gravityHelper->__('Recommended Item(s)') ?></h3>
27
+ <?php endif; ?>
28
+ </div>
29
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="box-content"><?php echo $gravityHelper->__('Recommendations will be displayed here') ?></div>
30
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
31
+ <ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col gravity-<?php echo $this->getBoxClass() ?>-grid">
32
+ {for p in products}
33
+ <li class="item" style="min-height: 200px;">
34
+ <a class="product-image" href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">
35
+ <img id="product-collection-image-${p.itemid}'}" src='${p.ImageUrl}' />
36
+ </a>
37
+ <div class="recItemTitle product-name">
38
+ <a class="recItemTitle product-name" href="${p.Url}" onmousedown="_gravity.push({type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a>
39
+ </div>
40
+ </li>
41
+ {/for}
42
+ </ul>
43
+ </div>
44
+ </div>
45
+ <script type="text/javascript">
46
+ //<![CDATA[
47
+ _gravity.push({
48
+ type: "recommendation",
49
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
50
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
51
+ <?php if($filters = $this->getFilters()) : ?>
52
+ <?php foreach($filters as $attributeCode => $value) : ?>
53
+ <?php echo $attributeCode ?>: "<?php echo $value ?>",
54
+ <?php endforeach; ?>
55
+ <?php endif; ?>
56
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
57
+ templating: {
58
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
59
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
60
+ }
61
+ });
62
+ //]]>
63
+ </script>
64
+ <?php else : ?>
65
+ <?php $items = $this->getProductCollection(); ?>
66
+ <?php if (!is_null($items) && $items->count()) : ?>
67
+ <div class="box box-<?php echo $this->getBoxClass() ?>">
68
+ <div class="box-head">
69
+ <?php if($title = $this->getRecommendationTitle()) : ?>
70
+ <h3><?php echo $title ?></h3>
71
+ <?php else : ?>
72
+ <h3><?php echo $gravityHelper->__('Recommended Item(s)') ?></h3>
73
+ <?php endif; ?>
74
+ </div>
75
+ <div class="box-content">
76
+ <?php $_collectionSize = $items->count(); ?>
77
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
78
+ <ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col gravity-<?php echo $this->getBoxClass() ?>-grid">
79
+ <?php $i = 0; foreach ($items as $_product): ?>
80
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
81
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});">
82
+ <?php $_imgSize = 210; ?>
83
+ <img id="product-collection-image-<?php echo $_product->getId(); ?>"
84
+ src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imgSize); ?>"
85
+ alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
86
+ </a>
87
+ <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->stripTags($_product->getName(), null, true) ?></a></h3>
88
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
89
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
90
+ </li>
91
+ <?php endforeach; ?>
92
+ </ul>
93
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
94
+ </div>
95
+ </div>
96
+ <?php endif; ?>
97
+ <?php endif; ?>
app/design/frontend/rwd/default/template/me/gravity/catalog/category/boxes/sidebar.phtml ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Recommendation
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Recommendation
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
21
+ <div class="block-title">
22
+ <?php if($title = $this->getRecommendationTitle()) : ?>
23
+ <strong><span><?php echo $title ?></span></strong>
24
+ <?php else : ?>
25
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="block-content"></div>
29
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
30
+ <ol class="recItems mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
31
+ {for p in products}
32
+ <li class="item">
33
+ <div class="product">
34
+ <a href="${p.Url}" title="${p.title}" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});"><img src="${p.ImageUrl}" width="50" alt=">${p.title}" /></a>
35
+ <div class="product-details">
36
+ <p class="recItemTitle product-name"><a href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a></p>
37
+ </div>
38
+ </div>
39
+ <div class="clearer"></div>
40
+ </li>
41
+ {/for}
42
+ </ol>
43
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
44
+ </div>
45
+ </div>
46
+ <script type="text/javascript">
47
+ //<![CDATA[
48
+ _gravity.push({
49
+ type: "recommendation",
50
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
51
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
52
+ <?php if($filters = $this->getFilters()) : ?>
53
+ <?php foreach($filters as $attributeCode => $value) : ?>
54
+ <?php echo $attributeCode ?>: "<?php echo $value ?>",
55
+ <?php endforeach; ?>
56
+ <?php endif; ?>
57
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
58
+ templating: {
59
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
60
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
61
+ }
62
+ });
63
+ //]]>
64
+ </script>
65
+ <?php else : ?>
66
+ <?php $items = $this->getProductCollection(); ?>
67
+ <?php if (!is_null($items) && $items->count()) : ?>
68
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
69
+ <div class="block-title">
70
+ <?php if($title = $this->getRecommendationTitle()) : ?>
71
+ <strong><span><?php echo $title ?></span></strong>
72
+ <?php else : ?>
73
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
74
+ <?php endif; ?>
75
+ </div>
76
+ <div class="block-content">
77
+ <?php $_collectionSize = $items->count(); ?>
78
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
79
+ <?php $i = 0; foreach ($items as $_product): ?>
80
+ <ol class="mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
81
+ <li class="item">
82
+ <div class="product">
83
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_product->getName()) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(50) ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($_product->getName()) ?>" /></a>
84
+ <div class="product-details">
85
+ <p class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->escapeHtml($_product->getName()) ?></a></p>
86
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
87
+ </div>
88
+ </div>
89
+ </li>
90
+ </ol>
91
+ <?php endforeach; ?>
92
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
93
+ </div>
94
+ </div>
95
+ <?php endif; ?>
96
+ <?php endif; ?>
app/design/frontend/rwd/default/template/me/gravity/catalog/product/view/boxes/default.phtml ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Recommendation
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Recommendation
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <?php $_columnCount = 5; ?>
21
+ <div class="box box-<?php echo $this->getBoxClass() ?>">
22
+ <div class="box-head">
23
+ <?php if($title = $this->getRecommendationTitle()) : ?>
24
+ <h3><?php echo $title ?></h3>
25
+ <?php else : ?>
26
+ <h3><?php echo $gravityHelper->__('Recommended Item(s)') ?></h3>
27
+ <?php endif; ?>
28
+ </div>
29
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="box-content"><?php echo $gravityHelper->__('Recommendations will be displayed here') ?></div>
30
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
31
+ <ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col gravity-<?php echo $this->getBoxClass() ?>-grid">
32
+ {for p in products}
33
+ <li class="item" style="min-height: 200px;">
34
+ <a class="product-image" href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">
35
+ <img id="product-collection-image-${p.itemid}'}" src='${p.ImageUrl}' />
36
+ </a>
37
+ <div class="recItemTitle product-name">
38
+ <a class="recItemTitle product-name" href="${p.Url}" onmousedown="_gravity.push({type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a>
39
+ </div>
40
+ </li>
41
+ {/for}
42
+ </ul>
43
+ </div>
44
+ </div>
45
+ <script type="text/javascript">
46
+ //<![CDATA[
47
+ _gravity.push({
48
+ type: "recommendation",
49
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
50
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
51
+ <?php if($productId = $this->getProduct()->getId()) : ?>
52
+ currentItemId: "ItemID_<?php echo $productId ?>",
53
+ <?php endif; ?>
54
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
55
+ templating: {
56
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
57
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
58
+ }
59
+ });
60
+ //]]>
61
+ </script>
62
+ <?php else : ?>
63
+ <?php $items = $this->getProductCollection(); ?>
64
+ <?php if (!is_null($items) && $items->count()) : ?>
65
+ <div class="box box-<?php echo $this->getBoxClass() ?>">
66
+ <div class="box-head">
67
+ <?php if($title = $this->getRecommendationTitle()) : ?>
68
+ <h3><?php echo $title ?></h3>
69
+ <?php else : ?>
70
+ <h3><?php echo $gravityHelper->__('Recommended Item(s)') ?></h3>
71
+ <?php endif; ?>
72
+ </div>
73
+ <div class="box-content">
74
+ <?php $_collectionSize = $items->count(); ?>
75
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
76
+ <ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col gravity-<?php echo $this->getBoxClass() ?>-grid">
77
+ <?php $i = 0; foreach ($items as $_product): ?>
78
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
79
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});">
80
+ <?php $_imgSize = 210; ?>
81
+ <img id="product-collection-image-<?php echo $_product->getId(); ?>"
82
+ src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imgSize); ?>"
83
+ alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
84
+ </a>
85
+ <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->stripTags($_product->getName(), null, true) ?></a></h3>
86
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
87
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
88
+ </li>
89
+ <?php endforeach; ?>
90
+ </ul>
91
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
92
+ </div>
93
+ </div>
94
+ <?php endif; ?>
95
+ <?php endif; ?>
app/design/frontend/rwd/default/template/me/gravity/catalog/product/view/boxes/sidebar.phtml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Recommendation
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Recommendation
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
21
+ <div class="block-title">
22
+ <?php if($title = $this->getRecommendationTitle()) : ?>
23
+ <strong><span><?php echo $title ?></span></strong>
24
+ <?php else : ?>
25
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="block-content"></div>
29
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
30
+ <ol class="recItems mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
31
+ {for p in products}
32
+ <li class="item">
33
+ <div class="product">
34
+ <a href="${p.Url}" title="${p.title}" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});"><img src="${p.ImageUrl}" width="50" alt=">${p.title}" /></a>
35
+ <div class="product-details">
36
+ <p class="recItemTitle product-name"><a href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a></p>
37
+ </div>
38
+ </div>
39
+ <div class="clearer"></div>
40
+ </li>
41
+ {/for}
42
+ </ol>
43
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
44
+ </div>
45
+ </div>
46
+ <script type="text/javascript">
47
+ //<![CDATA[
48
+ _gravity.push({
49
+ type: "recommendation",
50
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
51
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
52
+ <?php if($productId = $this->getProduct()->getId()) : ?>
53
+ currentItemId: "ItemID_<?php echo $productId ?>",
54
+ <?php endif; ?>
55
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
56
+ templating: {
57
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
58
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
59
+ }
60
+ });
61
+ //]]>
62
+ </script>
63
+ <?php else : ?>
64
+ <?php $items = $this->getProductCollection(); ?>
65
+ <?php if (!is_null($items) && $items->count()) : ?>
66
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
67
+ <div class="block-title">
68
+ <?php if($title = $this->getRecommendationTitle()) : ?>
69
+ <strong><span><?php echo $title ?></span></strong>
70
+ <?php else : ?>
71
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
72
+ <?php endif; ?>
73
+ </div>
74
+ <div class="block-content">
75
+ <?php $_collectionSize = $items->count(); ?>
76
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
77
+ <?php $i = 0; foreach ($items as $_product): ?>
78
+ <ol class="mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
79
+ <li class="item">
80
+ <div class="product">
81
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_product->getName()) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(50) ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($_product->getName()) ?>" /></a>
82
+ <div class="product-details">
83
+ <p class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->escapeHtml($_product->getName()) ?></a></p>
84
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
85
+ </div>
86
+ </div>
87
+ </li>
88
+ </ol>
89
+ <?php endforeach; ?>
90
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
91
+ </div>
92
+ </div>
93
+ <?php endif; ?>
94
+ <?php endif; ?>
app/design/frontend/rwd/default/template/me/gravity/catalogsearch/boxes/default.phtml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Recommendation
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Recommendation
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <?php $_columnCount = 5; ?>
21
+ <div class="box box-<?php echo $this->getBoxClass() ?>">
22
+ <div class="box-head">
23
+ <?php if($title = $this->getRecommendationTitle()) : ?>
24
+ <h3><?php echo $title ?></h3>
25
+ <?php else : ?>
26
+ <h3><?php echo $gravityHelper->__('Recommended Item(s)') ?></h3>
27
+ <?php endif; ?>
28
+ </div>
29
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="box-content"><?php echo $gravityHelper->__('Recommendations will be displayed here') ?></div>
30
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
31
+ <ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col gravity-<?php echo $this->getBoxClass() ?>-grid">
32
+ {for p in products}
33
+ <li class="item" style="min-height: 200px;">
34
+ <a class="product-image" href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">
35
+ <img id="product-collection-image-${p.itemid}'}" src='${p.ImageUrl}' />
36
+ </a>
37
+ <div class="recItemTitle product-name">
38
+ <a class="recItemTitle product-name" href="${p.Url}" onmousedown="_gravity.push({type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a>
39
+ </div>
40
+ </li>
41
+ {/for}
42
+ </ul>
43
+ </div>
44
+ </div>
45
+ <script type="text/javascript">
46
+ //<![CDATA[
47
+ _gravity.push({
48
+ type: "recommendation",
49
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
50
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
51
+ <?php if($searchKeywords = $this->getSearchKeywords()) : ?>
52
+ <?php foreach($searchKeywords as $attributeCode => $value) : ?>
53
+ <?php echo $attributeCode ?>: "<?php echo $value ?>",
54
+ <?php endforeach; ?>
55
+ <?php endif; ?>
56
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
57
+ templating: {
58
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
59
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
60
+ }
61
+ });
62
+ //]]>
63
+ </script>
64
+ <?php else : ?>
65
+ <?php $items = $this->getProductCollection(); ?>
66
+ <?php if (!is_null($items) && $items->count()) : ?>
67
+ <div class="box box-<?php echo $this->getBoxClass() ?>">
68
+ <div class="box-head">
69
+ <?php if($title = $this->getRecommendationTitle()) : ?>
70
+ <h3><?php echo $title ?></h3>
71
+ <?php else : ?>
72
+ <h3><?php echo $gravityHelper->__('Recommended Item(s)') ?></h3>
73
+ <?php endif; ?>
74
+ </div>
75
+ <div class="box-content">
76
+ <?php $_collectionSize = $items->count(); ?>
77
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
78
+ <ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col gravity-<?php echo $this->getBoxClass() ?>-grid">
79
+ <?php $i = 0; foreach ($items as $_product): ?>
80
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
81
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});">
82
+ <?php $_imgSize = 210; ?>
83
+ <img id="product-collection-image-<?php echo $_product->getId(); ?>"
84
+ src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imgSize); ?>"
85
+ alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
86
+ </a>
87
+ <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->stripTags($_product->getName(), null, true) ?></a></h3>
88
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
89
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
90
+ </li>
91
+ <?php endforeach; ?>
92
+ </ul>
93
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
94
+ </div>
95
+ </div>
96
+ <?php endif; ?>
97
+ <?php endif; ?>
app/design/frontend/rwd/default/template/me/gravity/catalogsearch/boxes/sidebar.phtml ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Recommendation
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Recommendation
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
21
+ <div class="block-title">
22
+ <?php if($title = $this->getRecommendationTitle()) : ?>
23
+ <strong><span><?php echo $title ?></span></strong>
24
+ <?php else : ?>
25
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="block-content"></div>
29
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
30
+ <ol class="recItems mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
31
+ {for p in products}
32
+ <li class="item">
33
+ <div class="product">
34
+ <a href="${p.Url}" title="${p.title}" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});"><img src="${p.ImageUrl}" width="50" alt=">${p.title}" /></a>
35
+ <div class="product-details">
36
+ <p class="recItemTitle product-name"><a href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a></p>
37
+ </div>
38
+ </div>
39
+ <div class="clearer"></div>
40
+ </li>
41
+ {/for}
42
+ </ol>
43
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
44
+ </div>
45
+ </div>
46
+ <script type="text/javascript">
47
+ //<![CDATA[
48
+ _gravity.push({
49
+ type: "recommendation",
50
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
51
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
52
+ <?php if($searchKeywords = $this->getSearchKeywords()) : ?>
53
+ <?php foreach($searchKeywords as $attributeCode => $value) : ?>
54
+ <?php echo $attributeCode ?>: "<?php echo $value ?>",
55
+ <?php endforeach; ?>
56
+ <?php endif; ?>
57
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
58
+ templating: {
59
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
60
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
61
+ }
62
+ });
63
+ //]]>
64
+ </script>
65
+ <?php else : ?>
66
+ <?php $items = $this->getProductCollection(); ?>
67
+ <?php if (!is_null($items) && $items->count()) : ?>
68
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
69
+ <div class="block-title">
70
+ <?php if($title = $this->getRecommendationTitle()) : ?>
71
+ <strong><span><?php echo $title ?></span></strong>
72
+ <?php else : ?>
73
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
74
+ <?php endif; ?>
75
+ </div>
76
+ <div class="block-content">
77
+ <?php $_collectionSize = $items->count(); ?>
78
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
79
+ <?php $i = 0; foreach ($items as $_product): ?>
80
+ <ol class="mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
81
+ <li class="item">
82
+ <div class="product">
83
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_product->getName()) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(50) ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($_product->getName()) ?>" /></a>
84
+ <div class="product-details">
85
+ <p class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->escapeHtml($_product->getName()) ?></a></p>
86
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
87
+ </div>
88
+ </div>
89
+ </li>
90
+ </ol>
91
+ <?php endforeach; ?>
92
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
93
+ </div>
94
+ </div>
95
+ <?php endif; ?>
96
+ <?php endif; ?>
app/design/frontend/rwd/default/template/me/gravity/checkout/cart/boxes/default.phtml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Recommendation
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Recommendation
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <?php $_columnCount = 5; ?>
21
+ <div class="box box-<?php echo $this->getBoxClass() ?>">
22
+ <div class="box-head">
23
+ <?php if($title = $this->getRecommendationTitle()) : ?>
24
+ <h3><?php echo $title ?></h3>
25
+ <?php else : ?>
26
+ <h3><?php echo $gravityHelper->__('Recommended Item(s)') ?></h3>
27
+ <?php endif; ?>
28
+ </div>
29
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="box-content"><?php echo $gravityHelper->__('Recommendations will be displayed here') ?></div>
30
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
31
+ <ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col gravity-<?php echo $this->getBoxClass() ?>-grid">
32
+ {for p in products}
33
+ <li class="item" style="min-height: 200px;">
34
+ <a class="product-image" href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">
35
+ <img id="product-collection-image-${p.itemid}'}" src='${p.ImageUrl}' />
36
+ </a>
37
+ <div class="recItemTitle product-name">
38
+ <a class="recItemTitle product-name" href="${p.Url}" onmousedown="_gravity.push({type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a>
39
+ </div>
40
+ </li>
41
+ {/for}
42
+ </ul>
43
+ </div>
44
+ </div>
45
+ <script type="text/javascript">
46
+ //<![CDATA[
47
+ _gravity.push({
48
+ type: "recommendation",
49
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
50
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
51
+ <?php if($itemIds = $this->getCartItems()) : ?>
52
+ <?php foreach($itemIds as $itemId) : ?>
53
+ cartItemId: "<?php echo $itemId ?>",
54
+ <?php endforeach; ?>
55
+ <?php endif; ?>
56
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
57
+ templating: {
58
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
59
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
60
+ }
61
+ });
62
+ //]]>
63
+ </script>
64
+ <?php else : ?>
65
+ <?php $items = $this->getProductCollection(); ?>
66
+ <?php if (!is_null($items) && $items->count()) : ?>
67
+ <div class="box box-<?php echo $this->getBoxClass() ?>">
68
+ <div class="box-head">
69
+ <?php if($title = $this->getRecommendationTitle()) : ?>
70
+ <h3><?php echo $title ?></h3>
71
+ <?php else : ?>
72
+ <h3><?php echo $gravityHelper->__('Recommended Item(s)') ?></h3>
73
+ <?php endif; ?>
74
+ </div>
75
+ <div class="box-content">
76
+ <?php $_collectionSize = $items->count(); ?>
77
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
78
+ <ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col gravity-<?php echo $this->getBoxClass() ?>-grid">
79
+ <?php $i = 0; foreach ($items as $_product): ?>
80
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
81
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});">
82
+ <?php $_imgSize = 210; ?>
83
+ <img id="product-collection-image-<?php echo $_product->getId(); ?>"
84
+ src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imgSize); ?>"
85
+ alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
86
+ </a>
87
+ <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->stripTags($_product->getName(), null, true) ?></a></h3>
88
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
89
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
90
+ </li>
91
+ <?php endforeach; ?>
92
+ </ul>
93
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
94
+ </div>
95
+ </div>
96
+ <?php endif; ?>
97
+ <?php endif; ?>
app/design/frontend/rwd/default/template/me/gravity/checkout/cart/boxes/sidebar.phtml ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Recommendation
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Recommendation
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
21
+ <div class="block-title">
22
+ <?php if($title = $this->getRecommendationTitle()) : ?>
23
+ <strong><span><?php echo $title ?></span></strong>
24
+ <?php else : ?>
25
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="block-content"></div>
29
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
30
+ <ol class="recItems mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
31
+ {for p in products}
32
+ <li class="item">
33
+ <div class="product">
34
+ <a href="${p.Url}" title="${p.title}" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});"><img src="${p.ImageUrl}" width="50" alt=">${p.title}" /></a>
35
+ <div class="product-details">
36
+ <p class="recItemTitle product-name"><a href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a></p>
37
+ </div>
38
+ </div>
39
+ <div class="clearer"></div>
40
+ </li>
41
+ {/for}
42
+ </ol>
43
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
44
+ </div>
45
+ </div>
46
+ <script type="text/javascript">
47
+ //<![CDATA[
48
+ _gravity.push({
49
+ type: "recommendation",
50
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
51
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
52
+ <?php if($itemIds = $this->getCartItems()) : ?>
53
+ <?php foreach($itemIds as $itemId) : ?>
54
+ cartItemId: "<?php echo $itemId ?>",
55
+ <?php endforeach; ?>
56
+ <?php endif; ?>
57
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
58
+ templating: {
59
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
60
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
61
+ }
62
+ });
63
+ //]]>
64
+ </script>
65
+ <?php else : ?>
66
+ <?php $items = $this->getProductCollection(); ?>
67
+ <?php if (!is_null($items) && $items->count()) : ?>
68
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
69
+ <div class="block-title">
70
+ <?php if($title = $this->getRecommendationTitle()) : ?>
71
+ <strong><span><?php echo $title ?></span></strong>
72
+ <?php else : ?>
73
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
74
+ <?php endif; ?>
75
+ </div>
76
+ <div class="block-content">
77
+ <?php $_collectionSize = $items->count(); ?>
78
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
79
+ <?php $i = 0; foreach ($items as $_product): ?>
80
+ <ol class="mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
81
+ <li class="item">
82
+ <div class="product">
83
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_product->getName()) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(50) ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($_product->getName()) ?>" /></a>
84
+ <div class="product-details">
85
+ <p class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->escapeHtml($_product->getName()) ?></a></p>
86
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
87
+ </div>
88
+ </div>
89
+ </li>
90
+ </ol>
91
+ <?php endforeach; ?>
92
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
93
+ </div>
94
+ </div>
95
+ <?php endif; ?>
96
+ <?php endif; ?>
app/design/frontend/rwd/default/template/me/gravity/general/boxes/default.phtml ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Recommendation
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Recommendation
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <?php $_columnCount = 5; ?>
21
+ <div class="box box-<?php echo $this->getBoxClass() ?>">
22
+ <div class="box-head">
23
+ <?php if($title = $this->getRecommendationTitle()) : ?>
24
+ <h3><?php echo $title ?></h3>
25
+ <?php else : ?>
26
+ <h3><?php echo $gravityHelper->__('Recommended Item(s)') ?></h3>
27
+ <?php endif; ?>
28
+ </div>
29
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="box-content"><?php echo $gravityHelper->__('Recommendations will be displayed here') ?></div>
30
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
31
+ <ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col gravity-<?php echo $this->getBoxClass() ?>-grid">
32
+ {for p in products}
33
+ <li class="item" style="min-height: 200px;">
34
+ <a class="product-image" href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">
35
+ <img id="product-collection-image-${p.itemid}" src='${p.ImageUrl}' />
36
+ </a>
37
+ <div class="recItemTitle product-name">
38
+ <a class="recItemTitle product-name" href="${p.Url}" onmousedown="_gravity.push({type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a>
39
+ </div>
40
+ </li>
41
+ {/for}
42
+ </ul>
43
+ </div>
44
+ </div>
45
+ <script type="text/javascript">
46
+ //<![CDATA[
47
+ _gravity.push({
48
+ type: "recommendation",
49
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
50
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
51
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
52
+ templating: {
53
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
54
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
55
+ }
56
+ });
57
+ //]]>
58
+ </script>
59
+ <?php else : ?>
60
+ <?php $items = $this->getProductCollection(); ?>
61
+ <?php if (!is_null($items) && $items->count()) : ?>
62
+ <div class="box box-<?php echo $this->getBoxClass() ?>">
63
+ <div class="box-head">
64
+ <?php if($title = $this->getRecommendationTitle()) : ?>
65
+ <h3><?php echo $title ?></h3>
66
+ <?php else : ?>
67
+ <h3><?php echo $gravityHelper->__('Recommended Item(s)') ?></h3>
68
+ <?php endif; ?>
69
+ </div>
70
+ <div class="box-content">
71
+ <?php $_collectionSize = $items->count(); ?>
72
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
73
+ <ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col gravity-<?php echo $this->getBoxClass() ?>-grid">
74
+ <?php $i = 0; foreach ($items as $_product): ?>
75
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
76
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});">
77
+ <?php $_imgSize = 210; ?>
78
+ <img id="product-collection-image-<?php echo $_product->getId(); ?>"
79
+ src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imgSize); ?>"
80
+ alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
81
+ </a>
82
+ <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->stripTags($_product->getName(), null, true) ?></a></h3>
83
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
84
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
85
+ </li>
86
+ <?php endforeach; ?>
87
+ </ul>
88
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
89
+ </div>
90
+ </div>
91
+ <?php endif; ?>
92
+ <?php endif; ?>
app/design/frontend/rwd/default/template/me/gravity/general/boxes/sidebar.phtml ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Recommendation
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Recommendation
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($gravityHelper->useGravityTemplate()) : ?>
20
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
21
+ <div class="block-title">
22
+ <?php if($title = $this->getRecommendationTitle()) : ?>
23
+ <strong><span><?php echo $title ?></span></strong>
24
+ <?php else : ?>
25
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
26
+ <?php endif; ?>
27
+ </div>
28
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="block-content"></div>
29
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
30
+ <ol class="recItems mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
31
+ {for p in products}
32
+ <li class="item">
33
+ <div class="product">
34
+ <a href="${p.Url}" title="${p.title}" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});"><img src="${p.ImageUrl}" width="50" alt=">${p.title}" /></a>
35
+ <div class="product-details">
36
+ <p class="recItemTitle product-name"><a href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a></p>
37
+ </div>
38
+ </div>
39
+ <div class="clearer"></div>
40
+ </li>
41
+ {/for}
42
+ </ol>
43
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
44
+ </div>
45
+ </div>
46
+ <script type="text/javascript">
47
+ //<![CDATA[
48
+ _gravity.push({
49
+ type: "recommendation",
50
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
51
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
52
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
53
+ templating: {
54
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
55
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
56
+ }
57
+ });
58
+ //]]>
59
+ </script>
60
+ <?php else : ?>
61
+ <?php $items = $this->getProductCollection(); ?>
62
+ <?php if (!is_null($items) && $items->count()) : ?>
63
+ <div class="block block-<?php echo $this->getBoxClass() ?>">
64
+ <div class="block-title">
65
+ <?php if($title = $this->getRecommendationTitle()) : ?>
66
+ <strong><span><?php echo $title ?></span></strong>
67
+ <?php else : ?>
68
+ <strong><span><?php echo $gravityHelper->__('Recommended Item(s)') ?></span></strong>
69
+ <?php endif; ?>
70
+ </div>
71
+ <div class="block-content">
72
+ <?php $_collectionSize = $items->count(); ?>
73
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
74
+ <?php $i = 0; foreach ($items as $_product): ?>
75
+ <ol class="mini-products-list" id="block-<?php echo $this->getBoxClass() ?>">
76
+ <li class="item">
77
+ <div class="product">
78
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_product->getName()) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail')->resize(50) ?>" width="50" height="50" alt="<?php echo $this->escapeHtml($_product->getName()) ?>" /></a>
79
+ <div class="product-details">
80
+ <p class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->escapeHtml($_product->getName()) ?></a></p>
81
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
82
+ </div>
83
+ </div>
84
+ </li>
85
+ </ol>
86
+ <?php endforeach; ?>
87
+ <script type="text/javascript">decorateList('block-<?php echo $this->getBoxClass() ?>', 'none-recursive')</script>
88
+ </div>
89
+ </div>
90
+ <?php endif; ?>
91
+ <?php endif; ?>
app/design/frontend/rwd/default/template/me/gravity/widget/boxes/widget.phtml ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Me_Gravity_Block_Widget_Boxes_Widget
4
+ *
5
+ * @category Me
6
+ * @package Me_Gravity
7
+ * @author Attila Sági <sagi.attila@magevolve.com>
8
+ * @copyright 2015 Magevolve Ltd. (http://magevolve.com)
9
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
10
+ * @link http://magevolve.com
11
+ */
12
+ ?>
13
+ <?php
14
+ /**
15
+ * @see Me_Gravity_Block_Widget_Boxes_Widget
16
+ */
17
+ ?>
18
+ <?php $gravityHelper = $this->getGravityHelper(); ?>
19
+ <?php if ($this->getTemplateType()) : ?>
20
+ <?php $_columnCount = 5; ?>
21
+ <div class="widget widget-<?php echo $this->getBoxClass() ?>">
22
+ <div class="widget-title">
23
+ <?php if($title = $this->getRecommendationTitle()) : ?>
24
+ <h2><?php echo $title ?></h2>
25
+ <?php else : ?>
26
+ <h2><?php echo $gravityHelper->__('Recommended Item(s)') ?></h2>
27
+ <?php endif; ?>
28
+ </div>
29
+ <div id="target-<?php echo $this->getBoxClass() ?>" class="widget-products"><?php echo $gravityHelper->__('Recommendations will be displayed here') ?></div>
30
+ <div id="template-<?php echo $this->getBoxClass() ?>" style="display: none;">
31
+ <ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col-widget gravity-<?php echo $this->getBoxClass() ?>-grid">
32
+ {for p in products}
33
+ <li class="item" style="min-height: 210px;">
34
+ <a class="product-image" href="${p.Url}" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">
35
+ <img id="product-collection-image-${p.itemid}" src='${p.ImageUrl}' style="width: 210px;" />
36
+ </a>
37
+ <div class="product-info">
38
+ <h3 class="product-name recItemTitle">
39
+ <a class="product-name" href="${p.Url}" onmousedown="_gravity.push({type: 'event', eventType: 'REC_CLICK', itemId: '${p.itemid}'});">${p.title}</a>
40
+ </h3>
41
+ </div>
42
+ </li>
43
+ {/for}
44
+ </ul>
45
+ </div>
46
+ </div>
47
+ <script type="text/javascript">
48
+ //<![CDATA[
49
+ _gravity.push({
50
+ type: "recommendation",
51
+ scenarioId: "<?php echo $this->getRecommendationType() ?>",
52
+ numberLimit: <?php echo $this->getRecommendationLimit() ?>,
53
+ resultNames: ["itemId", "title", "Url", "ImageUrl"],
54
+ templating: {
55
+ targetElementId: "target-<?php echo $this->getBoxClass() ?>",
56
+ templateElementId: "template-<?php echo $this->getBoxClass() ?>"
57
+ }
58
+ });
59
+ //]]>
60
+ </script>
61
+ <?php else : ?>
62
+ <?php $items = $this->getProductCollection(); ?>
63
+ <?php if (!is_null($items) && $items->count()) : ?>
64
+ <div class="box box-<?php echo $this->getBoxClass() ?>">
65
+ <div class="box-head">
66
+ <?php if($title = $this->getRecommendationTitle()) : ?>
67
+ <h3><?php echo $title ?></h3>
68
+ <?php else : ?>
69
+ <h3><?php echo $gravityHelper->__('Recommended Item(s)') ?></h3>
70
+ <?php endif; ?>
71
+ </div>
72
+ <div class="box-content">
73
+ <?php $_collectionSize = $items->count(); ?>
74
+ <?php $_columnCount = $this->getBoxColumnCount(); ?>
75
+ <ul class="products-grid products-grid--max-<?php echo $_columnCount; ?>-col gravity-<?php echo $this->getBoxClass() ?>-grid">
76
+ <?php $i = 0; foreach ($items as $_product): ?>
77
+ <li class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
78
+ <a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" class="product-image" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});">
79
+ <?php $_imgSize = 210; ?>
80
+ <img id="product-collection-image-<?php echo $_product->getId(); ?>"
81
+ src="<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize($_imgSize); ?>"
82
+ alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" />
83
+ </a>
84
+ <h3 class="product-name"><a href="<?php echo $_product->getProductUrl() ?>" title="<?php echo $this->stripTags($_product->getName(), null, true) ?>" onmousedown="_gravity.push({ type: 'event', eventType: 'REC_CLICK', recId: '<?php echo $this->getRecommendationId() ?>', itemId: '<?php echo $_product->getId() ?>'});"><?php echo $this->stripTags($_product->getName(), null, true) ?></a></h3>
85
+ <?php echo $this->getPriceHtml($_product, true, '-' . $this->getBoxClass()) ?>
86
+ <?php echo $this->getReviewsSummaryHtml($_product) ?>
87
+ </li>
88
+ <?php endforeach; ?>
89
+ </ul>
90
+ <script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
91
+ </div>
92
+ </div>
93
+ <?php endif; ?>
94
+ <?php endif; ?>
app/etc/modules/Me_Gravity.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @category Me
5
+ * @package Me_Gravity
6
+ * @author Attila Sági <sagi.attila@magevolve.com>
7
+ * @copyright 2014 Magevolve Ltd. (http://magevolve.com)
8
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
9
+ * @link http://magevolve.com
10
+ */
11
+ -->
12
+ <config>
13
+ <modules>
14
+ <Me_Gravity>
15
+ <active>true</active>
16
+ <codePool>community</codePool>
17
+ <depends>
18
+ <Mage_Core />
19
+ <Mage_Adminhtml />
20
+ <Mage_Catalog />
21
+ <Mage_Customer />
22
+ <Mage_Sales />
23
+ <Mage_Sales />
24
+ </depends>
25
+ </Me_Gravity>
26
+ </modules>
27
+ </config>
app/locale/en_US/Me_Gravity.csv ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Description here...","Description here..."
2
+ "Gravity Reco","Gravity Reco"
3
+ "Settings","Settings"
4
+ "Enable Extension","Enable Extension"
5
+ "Yes","Yes"
6
+ "No","No"
7
+ "Enable extension.","Enable extension."
8
+ "Enable Preview Mode","Enable Preview Mode"
9
+ "Enabled Preview mode. In this case recommendation boxes are only visible if there is a special ?gr_reco_test=true parameter in the url. E.g.: http://example.com/example-product.html?gr_reco_test=true","Enabled Preview mode. In this case recommendation boxes are only visible if there is a special ?gr_reco_test=true parameter in the url. E.g.: http://example.com/example-product.html?gr_reco_test=true"
10
+ "API Username","API Username"
11
+ "API user name in Gravity system.","API user name in Gravity system."
12
+ "API Password","API Password"
13
+ "API password in Gravity system.","API password in Gravity system."
14
+ "API URL","API URL"
15
+ "API communication URL.","API communication URL."
16
+ "Test Connection","Test Connection"
17
+ "Press button to test connection.","Press button to test connection."
18
+ "Use Garvity Template","Use Garvity Template"
19
+ "General display setting. If YES all boxes will use Gravity template.","General display setting. If YES all boxes will use Gravity template."
20
+ "Export Products","Export Products"
21
+ "Catalog Export File Path","Catalog Export File Path"
22
+ "Path where catalog export file will be saved. Example: ""gravity_reco/"" (path must be writeable)","Path where catalog export file will be saved. Example: ""gravity_reco/"" (path must be writeable)"
23
+ "Enable All Products Export","Enable All Products Export"
24
+ "Enable all products to export. Otherwise please select NO and set the maximum number. Note: there can be performance impact during this operation.","Enable all products to export. Otherwise please select NO and set the maximum number. Note: there can be performance impact during this operation."
25
+ "Maximum Products Export","Maximum Products Export"
26
+ "The maximum number of products to be exported. This number must be between 1 and 1000.","The maximum number of products to be exported. This number must be between 1 and 1000."
27
+ "Additional Attributes","Additional Attributes"
28
+ "Select additional attributes for catalog export.","Select additional attributes for catalog export."
29
+ "Only Salable","Only Salable"
30
+ "In this case only those products will be exported which quantity higher than zero(is in stock). If your store doesn't use stock management choose YES.","In this case only those products will be exported which quantity higher than zero(is in stock). If your store doesn't use stock management choose YES."
31
+ "Enable Scheduled Export","Enable Scheduled Export"
32
+ "Enable scheduled export job bby cron. Note: you must configure your server to run cron jobs.","Enable scheduled export job bby cron. Note: you must configure your server to run cron jobs."
33
+ "Start Time","Start Time"
34
+ "Daily start time for automatic catalog export via cron job.","Daily start time for automatic catalog export via cron job."
35
+ "Export Product Catalog","Export Product Catalog"
36
+ "Export Products","Export Products"
37
+ "This will export product catalog and save in xml file. Note: there can be performance impact during this operation.","This will export product catalog and save in xml file. Note: there can be performance impact during this operation."
38
+ "Enable All Customers Export","Enable All Customers Export"
39
+ "Enable all customer to export. Otherwise please select NO and set the maximum number. Note: there can be performance impact during this operation.","Enable all customer to export. Otherwise please select NO and set the maximum number. Note: there can be performance impact during this operation."
40
+ "Select additional attributes for customer export.","Select additional attributes for customer export."
41
+ "Export Customers","Export Customers"
42
+ "This will export customers. Note: there can be performance impact during this operation.","This will export customers. Note: there can be performance impact during this operation."
43
+ "General Pages Display","General Pages Display"
44
+ "Enabled Pages","Enabled Pages"
45
+ "Pages on general layout recommendation boxes enabled.","Pages on general layout recommendation boxes enabled."
46
+ "Personal Best Box","Personal Best Box"
47
+ "Enable Personal Best Box","Enable Personal Best Box"
48
+ "Enable ""Recommended for you"" box on general page views.","Enable ""Recommended for you"" box on general page views."
49
+ "Personal Best Box Layout","Personal Best Box Layout"
50
+ "Select where ""Recommended for you"" box should be shown on general page views.","Select where ""Recommended for you"" box should be shown on general page views."
51
+ "Personal Best Box Title","Personal Best Box Title"
52
+ """Recommended for you"" box title on general page views.","""Recommended for you"" box title on general page views."
53
+ "Personal Best Box Product Count","Personal Best Box Product Count"
54
+ "Number of items show in ""Recommended for you"" box on general page views. This number must be between 1 and 10.","Number of items show in ""Recommended for you"" box on general page views. This number must be between 1 and 10."
55
+ "History Box","History Box"
56
+ "Enable History Box","Enable History Box"
57
+ "Enable ""You viewed"" box on general page views.","Enable ""You viewed"" box on general page views."
58
+ "History Box Layout","History Box Layout"
59
+ "Select where ""You viewed"" box should be shown on general page views.","Select where ""You viewed"" box should be shown on general page views."
60
+ "History Box Title","History Box Title"
61
+ """You viewed"" box title on general page views.","""You viewed"" box title on general page views."
62
+ "History Box Product Count","History Box Product Count"
63
+ "Number of items show in ""You viewed"" box on general page views. This number must be between 1 and 10.","Number of items show in ""You viewed"" box on general page views. This number must be between 1 and 10."
64
+ "Currently Viewed Box","Currently Viewed Box"
65
+ "Enable Currently Viewed Box","Enable Currently Viewed Box"
66
+ "Enable ""Others are looking at right now"" box on general page views.","Enable ""Others are looking at right now"" box on general page views."
67
+ "Currently Viewed Box Layout","Currently Viewed Box Layout"
68
+ "Select where ""Others are looking at right now"" box should be shown on general page views.","Select where ""Others are looking at right now"" box should be shown on general page views."
69
+ "Currently Viewed Box Title","Currently Viewed Box Title"
70
+ """Others are looking at right now"" box title on general page views.","""Others are looking at right now"" box title on general page views."
71
+ "Currently Viewed Box Product Count","Currently Viewed Box Product Count"
72
+ "Number of items show in ""Others are looking at right now"" box on general page views. This number must be between 1 and 10.","Number of items show in ""Others are looking at right now"" box on general page views. This number must be between 1 and 10."
73
+ "Popular Box","Popular Box"
74
+ "Enable Popular Box","Enable Popular Box"
75
+ "Enable ""Top Products"" box on general page views.","Enable ""Top Products"" box on general page views."
76
+ "Popular Box Layout","Popular Box Layout"
77
+ "Select where ""Top Products"" box should be shown on general page views.","Select where ""Top Products"" box should be shown on general page views."
78
+ "Popular Box Title","Popular Box Title"
79
+ """Top Products"" box title on general page views.","""Top Products"" box title on general page views."
80
+ "Popular Box Product Count","Popular Box Product Count"
81
+ "Number of items show in ""Top Products"" box on general page views. This number must be between 1 and 10.","Number of items show in ""Top Products"" box on general page views. This number must be between 1 and 10."
82
+ "Product Page Display","Product Page Display"
83
+ "Similar Box","Similar Box"
84
+ "Enable Similar Box","Enable Similar Box"
85
+ "Enable ""You might also like"" box on product page views.","Enable ""You might also like"" box on product page views."
86
+ "Similar Box Layout","Similar Box Layout"
87
+ "Select where ""You might also like"" box should be shown on product page views.","Select where ""You might also like"" box should be shown on product page views."
88
+ "Similar Box Title","Similar Box Title"
89
+ """You might also like"" box title on product page views.","""You might also like"" box title on product page views."
90
+ "Similar Box Product Count","Similar Box Product Count"
91
+ "Number of items show in ""You might also like"" box on product page views. This number must be between 1 and 10.","Number of items show in ""You might also like"" box on product page views. This number must be between 1 and 10."
92
+ "Personal Box","Personal Box"
93
+ "Enable Personal Box","Enable Personal Box"
94
+ "Enable ""Recommended for you"" box on product page views.","Enable ""Recommended for you"" box on product page views."
95
+ "Personal Box Layout","Personal Box Layout"
96
+ "Select where ""Recommended for you"" box should be shown on product page views.","Select where ""Recommended for you"" box should be shown on product page views."
97
+ "Personal Box Title","Personal Box Title"
98
+ """Recommended for you"" box title on product page views.","""Recommended for you"" box title on product page views."
99
+ "Personal Box Product Count","Personal Box Product Count"
100
+ "Number of items show in ""Recommended for you"" box on product page views. This number must be between 1 and 10.","Number of items show in ""Recommended for you"" box on product page views. This number must be between 1 and 10."
101
+ "Accessories Box","Accessories Box"
102
+ "Enable Accessories Box","Enable Accessories Box"
103
+ "Enable ""You might also need"" box on product page views.","Enable ""You might also need"" box on product page views."
104
+ "Accessories Box Layout","Accessories Box Layout"
105
+ "Select where ""You might also need"" box should be shown on product page views.","Select where ""You might also need"" box should be shown on product page views."
106
+ "Accessories Box Title","Accessories Box Title"
107
+ """You might also need"" box title on product page views.","""You might also need"" box title on product page views."
108
+ "Accessories Box Product Count","Accessories Box Product Count"
109
+ "Number of items show in ""You might also need"" box on product page views. This number must be between 1 and 10.","Number of items show in ""You might also need"" box on product page views. This number must be between 1 and 10."
110
+ "Category Page Display","Category Page Display"
111
+ "Personal Box","Personal Box"
112
+ "Enable Personal Box","Enable Personal Box"
113
+ "Enable ""Recommended for you"" box on category page views.","Enable ""Recommended for you"" box on category page views."
114
+ "Personal Box Layout","Personal Box Layout"
115
+ "Select where ""Recommended for you"" box should be shown on category page views.","Select where ""Recommended for you"" box should be shown on category page views."
116
+ "Personal Box Title","Personal Box Title"
117
+ """Recommended for you"" box title on category page views.","""Recommended for you"" box title on category page views."
118
+ "Personal Box Product Count","Personal Box Product Count"
119
+ "Number of items show in ""Recommended for you"" box on category page views. This number must be between 1 and 10.","Number of items show in ""Recommended for you"" box on category page views. This number must be between 1 and 10."
120
+ "Top Box","Top Box"
121
+ "Enable Top Box","Enable Top Box"
122
+ "Enable ""Top Products"" box on category page views.","Enable ""Top Products"" box on category page views."
123
+ "Top Box Layout","Top Box Layout"
124
+ "Select where ""Top Products"" box should be shown on category page views.","Select where ""Top Products"" box should be shown on category page views."
125
+ "Top Box Title","Top Box Title"
126
+ """Top Products"" box title on category page views.","""Top Products"" box title on category page views."
127
+ "Top Box Product Count","Top Box Product Count"
128
+ "Number of items show in ""Top Products"" box on category page views. This number must be between 1 and 10.","Number of items show in ""Top Products"" box on category page views. This number must be between 1 and 10."
129
+ "Search Result Page Display","Search Result Page Display"
130
+ "Recommendation Box","Recommendation Box"
131
+ "Enable Recommendation Box","Enable Recommendation Box"
132
+ "Enable ""Recommended for you"" box on search result page views.","Enable ""Recommended for you"" box on search result page views."
133
+ "Recommendation Box Layout","Recommendation Box Layout"
134
+ "Select where ""Recommended for you"" box should be shown on search result page views.","Select where ""Recommended for you"" box should be shown on search result page views."
135
+ "Recommendation Box Title","Recommendation Box Title"
136
+ """Recommended for you"" box title on search result page views.","""Recommended for you"" box title on search result page views."
137
+ "Recommendation Box Product Count","Recommendation Box Product Count"
138
+ "Number of items show in ""Recommended for you"" box on search result page views. This number must be between 1 and 10.","Number of items show in ""Recommended for you"" box on search result page views. This number must be between 1 and 10."
139
+ "Cart Page Display","Cart Page Display"
140
+ "Cart Box","Cart Box"
141
+ "Enable Cart Box","Enable Cart Box"
142
+ "Enable ""Others also bought"" box on cart page views.","Enable ""Others also bought"" box on cart page views."
143
+ "Cart Box Layout","Cart Box Layout"
144
+ "Select where ""Others also bought"" box should be shown on cart page views.","Select where ""Others also bought"" box should be shown on cart page views."
145
+ "Cart Box Title","Cart Box Title"
146
+ """Others also bought"" box title on cart page views.","""Others also bought"" box title on cart page views."
147
+ "Cart Box Product Count","Cart Box Product Count"
148
+ "Number of items show in ""Others also bought"" box on cart page views. This number must be between 1 and 10.","Number of items show in ""Others also bought"" box on cart page views. This number must be between 1 and 10."
149
+ "Synchronization","Synchronization"
150
+ "Enable Gravity Customer Update","Enable Gravity Customer Update"
151
+ "If customer is saved in backend it will be updated in Gravity.","If customer is saved in backend it will be updated in Gravity."
152
+ "Enable Gravity Product Update","Enable Gravity Product Update"
153
+ "If product is saved in backend it will be updated in Gravity.","If product is saved in backend it will be updated in Gravity."
154
+ "Enable Gravity Customer Registration","Enable Gravity Customer Registration"
155
+ "If customer is registered on frontend it will be added in Gravity.","If customer is registered on frontend it will be added in Gravity."
156
+ "Debug","Debug"
157
+ "Enable debug. In this case all transactions will be logged in /var/gravity.log.","Enable debug. In this case all transactions will be logged in /var/gravity.log."
158
+ "Left Sidebar","Left Sidebar"
159
+ "Bottom of Content","Bottom of Content"
160
+ "Right Sidebar","Right Sidebar"
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Me_Gravity</name>
4
+ <version>1.0.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.gravityrd.com/">Gravity R&amp;D, Ltd.</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The Gravity Recommendation extension provides an interface between Magento web shop and Gravity Recommendation service. The communication based on PHP or Javascript API providing by Gravity service. </summary>
10
+ <description>The Gravity Recommendation extension provides an interface between Magento web shop and Gravity Recommendation service. The communication based on PHP or Javascript API providing by Gravity service. The extension responsible for displaying recommendation boxes with products using Magento templates or Gravity based templates. The boxes contains the web shop products offered by the other side, and also sends information for Gravity service to provided proper analysis of users behaviors. It also able to export products catalog and customers for Gravity service using the extension configuration panel, or run daily scheduled export by cron job.</description>
11
+ <notes>Version number: 1.0.0.0&#xD;
12
+ Stability: Stable&#xD;
13
+ Compatibility: CE 1.6.x, 1.7.x, 1.8.x, 1.9.x </notes>
14
+ <authors><author><name>Gravity Recommendations</name><user>gravity_rd</user><email>web-integration@gravityrd.com</email></author></authors>
15
+ <date>2015-03-18</date>
16
+ <time>18:29:28</time>
17
+ <contents><target name="mageetc"><dir name="modules"><file name="Me_Gravity.xml" hash="a385bf72a5c2f0f040d2bb0850ca0b7c"/></dir></target><target name="magecommunity"><dir name="Me"><dir name="Gravity"><dir name="Block"><file name="Abstract.php" hash="586409500493a209ba021f8d471c793c"/><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Form"><file name="Catalog.php" hash="6adcc355986762d7cc19f854c5fdd067"/><file name="Customer.php" hash="50336da73ad37e3895f82980387f6970"/><file name="Test.php" hash="07d7fce9dd15eb623918d6f01505cc32"/></dir></dir></dir></dir><dir name="Catalog"><dir name="Category"><dir name="Boxes"><file name="Category.php" hash="0e9338d55a16ddde3ae30d14695e799d"/><file name="Personal.php" hash="7ac0315f48df1a3262fc06f33d46228a"/><file name="Top.php" hash="1e44870ec677da107bed26542233ab6b"/></dir></dir><dir name="Product"><dir name="View"><dir name="Boxes"><file name="Accessories.php" hash="f118fa14b7c457985c1e9b6b96f08f2e"/><file name="Personal.php" hash="1f2af5e09efad11f36c5a08de3861aee"/><file name="Product.php" hash="f7e66be937ec442e47c7dd4d3024d7df"/><file name="Similar.php" hash="47011f4c56d0bd7d9de7e159f9aeb9bb"/></dir><dir name="Js"><file name="Gravity.php" hash="f3d150d7d6ff93507a5ebc77cf0690cb"/></dir></dir></dir></dir><dir name="Catalogsearch"><dir name="Advanced"><dir name="Js"><file name="Gravity.php" hash="55765708d00aec635e92075f8e36da04"/></dir></dir><dir name="Boxes"><file name="Result.php" hash="1c59e5b53cbef273f6cb7cd3448aa45b"/></dir><dir name="Js"><file name="Gravity.php" hash="6e16a09ec3d26793db8ca216cf349a71"/></dir></dir><dir name="Checkout"><dir name="Cart"><dir name="Boxes"><file name="Cart.php" hash="b720e576c5123f9d52ee98807cb7ac36"/></dir></dir></dir><dir name="General"><dir name="Boxes"><file name="Best.php" hash="079eabb3dbfb2167eb9b0f9497fc37b0"/><file name="History.php" hash="85e0c22619328f8d0f03dfbcb5111709"/><file name="Others.php" hash="02c2cb071acbf74ce31a545c32c69f06"/><file name="Popular.php" hash="15ceca807386ffc3c384e393e4af7244"/></dir></dir><dir name="Page"><dir name="Js"><file name="Gravity.php" hash="26944607e33371fb1f56fca8e3d41aa3"/></dir></dir><file name="Recommendation.php" hash="50dae6d63ba61f0dfd2361eda3802a65"/><dir name="Widget"><dir name="Boxes"><file name="Widget.php" hash="17560f25437bf04f2f8069b1aeee010e"/></dir></dir></dir><dir name="Helper"><file name="Boxes.php" hash="e321d569b2d6e6ff64e2ae33180b7509"/><file name="Data.php" hash="6e583dd37cadba6c986ad08dda77ae34"/></dir><dir name="Model"><dir name="Client"><file name="GravityClient.php" hash="0294939e272568ffd118db005d15563d"/></dir><file name="Customers.php" hash="7399f7fb93965a3c67f5e2c941209ffe"/><dir name="Export"><file name="Abstract.php" hash="6e3ca7274117aa652aba036e4ae31f94"/><dir name="Catalog"><file name="Product.php" hash="6d7f73b7983b65614ef29d5efb9437ff"/></dir><dir name="Customer"><file name="Customer.php" hash="d3577acc08cd3004ccfb865232eebb9c"/></dir></dir><dir name="Method"><file name="Abstract.php" hash="c907e89db6238c5001cf653b31afa56e"/><file name="Request.php" hash="329365be220707c44ccd71e5b41bdf0e"/></dir><file name="Observer.php" hash="5eb36cdd6eedd3096f636362b8bd8ccb"/><file name="Products.php" hash="c33dde68c3fd6ddfe882c7c8b1c7c80d"/><dir name="System"><dir name="Config"><dir name="Backend"><dir name="Catalog"><file name="Cron.php" hash="395fbd5f3d41223a336057b5bba6f4cc"/></dir></dir><dir name="Source"><dir name="Catalog"><file name="Attributes.php" hash="72df90bea6566c5e843c2301ba4dd6e1"/></dir><dir name="Customer"><file name="Attributes.php" hash="1e940ae61c568d83bc541b0fb8e87de1"/></dir><dir name="Layout"><file name="Layout.php" hash="18ab5c014f802bea1f6a841d062439ac"/><file name="Pages.php" hash="5e443f0c91329db385bc3d3b4e945c22"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="GravityController.php" hash="2cf4ec00578e6c9968df13f65fdbbd84"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="91c9644e779d2dcbfced9869d5b7dd95"/><file name="config.xml" hash="b116604db1e638dad801d9d8479b0d91"/><file name="system.xml" hash="cf35a07de1996cb2fdd575f55e554935"/><file name="widget.xml" hash="9662aa456d8dcf6b38503944427c247e"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="me"><dir name="gravity"><dir name="catalog"><dir name="category"><dir name="boxes"><file name="default.phtml" hash="eda2c9883b7546a65bb085cbc9851447"/><file name="sidebar.phtml" hash="ad1ef8ff38a567d613d6df2fe1e61351"/></dir></dir><dir name="product"><dir name="view"><dir name="boxes"><file name="default.phtml" hash="45f1a4e14c8973b5338db866af836a2c"/><file name="sidebar.phtml" hash="63cfb176b76f272dfe3fd0fc18497d02"/></dir><dir name="js"><file name="gravity.phtml" hash="0b1a275b2cf0bc1b2cbee01f598d8d8e"/></dir></dir></dir></dir><dir name="catalogsearch"><dir name="advanced"><dir name="js"><file name="gravity.phtml" hash="4d83e2b1c0f9afec8f854f38d624c047"/></dir></dir><dir name="boxes"><file name="default.phtml" hash="42f09523625f41fae85fff9d09a4e9a5"/><file name="sidebar.phtml" hash="dbbbf928f09e0a7127e8a105bffe95bd"/></dir><dir name="js"><file name="gravity.phtml" hash="807b3df54dc86d0dbf79514d343f9c76"/></dir></dir><dir name="checkout"><dir name="cart"><dir name="boxes"><file name="default.phtml" hash="b5c21bd7143599bcb0bc07c9de0da2f5"/><file name="sidebar.phtml" hash="65cce0eecb91c75ab13c73670cc54253"/></dir></dir></dir><dir name="general"><dir name="boxes"><file name="default.phtml" hash="5b6c62685bfaf9cb3cb5ee3bdb269cdc"/><file name="sidebar.phtml" hash="19d65f6dee86527c22653000d2c4a441"/></dir></dir><dir name="page"><dir name="js"><file name="body-end.phtml" hash="5b642b64e8bb15d8bfe23b13400a7e63"/><file name="gravity.phtml" hash="c8aed3ec9f69f27d968658663edb057b"/></dir></dir><dir name="widget"><dir name="boxes"><file name="widget.phtml" hash="101ad504c26e31f7c0de32ff7b013bab"/></dir></dir></dir></dir></dir><dir name="layout"><dir name="me"><file name="gravity.xml" hash="47f5ea1f53290cfd3f6a48bd2c64a7fc"/></dir></dir></dir></dir><dir name="rwd"><dir name="default"><dir name="template"><dir name="me"><dir name="gravity"><dir name="catalog"><dir name="category"><dir name="boxes"><file name="default.phtml" hash="b3bd837ffb622c8c7163a4e3993104ca"/><file name="sidebar.phtml" hash="6bf41ed9c9bcd53432096c406453a462"/></dir></dir><dir name="product"><dir name="view"><dir name="boxes"><file name="default.phtml" hash="a49be0589c25ee62e72c1aeda6006c74"/><file name="sidebar.phtml" hash="b665b51090c6ec95af587cce0143d7e9"/></dir></dir></dir></dir><dir name="catalogsearch"><dir name="boxes"><file name="default.phtml" hash="8e83769eec038539c52247dcfd382c9f"/><file name="sidebar.phtml" hash="467a06716cf0cef4b3cf46e4feda77d2"/></dir></dir><dir name="checkout"><dir name="cart"><dir name="boxes"><file name="default.phtml" hash="f85c6f7aeb721e342e4da691849ef9c3"/><file name="sidebar.phtml" hash="265075974a3c2e16f37f42675fd689c7"/></dir></dir></dir><dir name="general"><dir name="boxes"><file name="default.phtml" hash="e9294af9142139744e9f9dcf69e73c62"/><file name="sidebar.phtml" hash="19d65f6dee86527c22653000d2c4a441"/></dir></dir><dir name="widget"><dir name="boxes"><file name="widget.phtml" hash="14606716bc55ce6e1223f53b2eb4ab43"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="me"><dir name="gravity"><dir name="system"><dir name="config"><dir name="form"><file name="test.phtml" hash="d9d972a23b04a34ab5f4d70a732d65b3"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="me"><dir name="gravity"><file name="gravity.css" hash="c2c4c7d30bced9a311c98032e38e0e11"/></dir></dir></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Me_Gravity.csv" hash="cf7233d08a92c8891d62c60b000953c4"/></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.3.0</min><max>5.6.4</max></php></required></dependencies>
20
+ </package>
skin/frontend/base/default/css/me/gravity/gravity.css ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--
2
+ /**
3
+ * @category Me
4
+ * @package Me_Gravity
5
+ * @author Attila Sági <sagi.attila@magevolve.com>
6
+ * @copyright 2014 Magevolve Ltd. (http://magevolve.com)
7
+ * @license http://magevolve.com/terms-and-conditions Magevolve Ltd. License
8
+ * @link http://magevolve.com
9
+ */
10
+ -->
11
+ .std .gravity-widget-grid {margin: 0 auto !important; list-style: outside none none !important; padding-left: 0 !important;}