SimpleRelevance_Integration - Version 0.0.5

Version Notes

-- version 0.0.5
Automatic Customer and Product submission

-- version 0.0.4
Bug fixes, new data on product import, debug facility

-- version 0.0.1
First release

Download this release

Release Info

Developer Magento Core Team
Extension SimpleRelevance_Integration
Version 0.0.5
Comparing to
See all releases


Code changes from version 0.0.4 to 0.0.5

app/code/community/SimpleRelevance/Integration/Helper/Data.php CHANGED
@@ -45,4 +45,41 @@ class SimpleRelevance_Integration_Helper_Data extends Mage_Core_Helper_Abstract
45
  {
46
  return (bool)((int)$this->config('active') === 1);
47
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
45
  {
46
  return (bool)((int)$this->config('active') === 1);
47
  }
48
+
49
+ /**
50
+ * Return produt dict params to send to the API
51
+ *
52
+ * @param Mage_Catalog_Model_Product
53
+ * @return array
54
+ */
55
+ public function getProductDict(Mage_Catalog_Model_Product $product)
56
+ {
57
+ $smallImageUrl = '';
58
+ if($product->getSmallImage()){
59
+ try{
60
+ $smallImageUrl = Mage::helper('catalog/image')->init($product, 'small_image')->resize(75);
61
+ }catch(Exception $e){
62
+ Mage::logException($e);
63
+ }
64
+ }
65
+ $baseImageUrl = '';
66
+ if($product->getImage()){
67
+ try{
68
+ $baseImageUrl = Mage::helper('catalog/image')->init($product, 'image');
69
+ }catch(Exception $e){
70
+ Mage::logException($e);
71
+ }
72
+ }
73
+
74
+ $dict = array(
75
+ 'item_url' => $product->getUrlPath(),
76
+ 'price' => $product->getPrice(),
77
+ 'sku' => $product->getSku(),
78
+ 'category_ids' => $product->getCategoryIds(),
79
+ 'image_url_small' => (string)$smallImageUrl,
80
+ 'image_url' => (string)$baseImageUrl,
81
+ 'description' => $product->getDescription(),
82
+ );
83
+ return $dict;
84
+ }
85
  }
app/code/community/SimpleRelevance/Integration/Model/Observer.php CHANGED
@@ -64,7 +64,7 @@ class SimpleRelevance_Integration_Model_Observer
64
  * Send new order to SimpleRelevance API
65
  *
66
  * @param Varien_Event_Observer $observer
67
- * @return
68
  */
69
  public function pushPurchase(Varien_Event_Observer $observer)
70
  {
@@ -93,7 +93,65 @@ class SimpleRelevance_Integration_Model_Observer
93
  }
94
 
95
  return $this;
96
-
97
  }
98
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
99
  }
64
  * Send new order to SimpleRelevance API
65
  *
66
  * @param Varien_Event_Observer $observer
67
+ * @return void
68
  */
69
  public function pushPurchase(Varien_Event_Observer $observer)
70
  {
93
  }
94
 
95
  return $this;
 
96
  }
97
 
98
+ /**
99
+ * Automatically send customer when creating one.
100
+ *
101
+ * @param Varien_Event_Observer $observer
102
+ * @return void
103
+ */
104
+ public function pushCustomer(Varien_Event_Observer $observer)
105
+ {
106
+ if( !Mage::helper('simple_relevance')->enabled() ){
107
+ return $this;
108
+ }
109
+
110
+ $customer = $observer->getEvent()->getCustomer();
111
+
112
+ if($customer->isObjectNew()){
113
+ $api = Mage::getModel('simple_relevance/api', Mage::helper('simple_relevance')->config('apikey'));
114
+
115
+ $api->async = 1;
116
+
117
+ $customerData = array(
118
+ 'email' => $customer->getEmail(),
119
+ 'user_id' => $customer->getId(),
120
+ );
121
+ $api->postUsers($customerData);
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Automatically send Catalog-Product when creating one.
127
+ *
128
+ * @param Varien_Event_Observer $observer
129
+ * @return void
130
+ */
131
+ public function pushItem(Varien_Event_Observer $observer)
132
+ {
133
+ if( !Mage::helper('simple_relevance')->enabled() ){
134
+ return $this;
135
+ }
136
+
137
+ $product = $observer->getEvent()->getProduct();
138
+
139
+ if($product->isObjectNew()){
140
+ $api = Mage::getModel('simple_relevance/api', Mage::helper('simple_relevance')->config('apikey'));
141
+
142
+ $api->async = 1;
143
+
144
+ $dict = Mage::helper('simple_relevance')->getProductDict($product);
145
+
146
+ $data = array(
147
+ 'item_name' => $product->getName(),
148
+ 'item_id' => $product->getId(),
149
+ 'data_dict' => $dict,
150
+ );
151
+
152
+ $api->postItems($data);
153
+ }
154
+
155
+ }
156
+
157
  }
app/code/community/SimpleRelevance/Integration/controllers/Adminhtml/ExportController.php CHANGED
@@ -66,32 +66,8 @@ class SimpleRelevance_Integration_Adminhtml_ExportController extends Mage_Adminh
66
  foreach ($products as $productId) {
67
  $product = Mage::getModel('catalog/product')->load($productId);
68
 
69
- $smallImageUrl = '';
70
- if($product->getSmallImage()){
71
- try{
72
- $smallImageUrl = Mage::helper('catalog/image')->init($product, 'small_image')->resize(75);
73
- }catch(Exception $e){
74
- Mage::logException($e);
75
- }
76
- }
77
- $baseImageUrl = '';
78
- if($product->getImage()){
79
- try{
80
- $baseImageUrl = Mage::helper('catalog/image')->init($product, 'image');
81
- }catch(Exception $e){
82
- Mage::logException($e);
83
- }
84
- }
85
 
86
- $dict = array(
87
- 'item_url' => $product->getUrlPath(),
88
- 'price' => $product->getPrice(),
89
- 'sku' => $product->getSku(),
90
- 'category_ids' => $product->getCategoryIds(),
91
- 'image_url_small' => (string)$smallImageUrl,
92
- 'image_url' => (string)$baseImageUrl,
93
- 'description' => $product->getDescription(),
94
- );
95
  $data = array(
96
  'item_name' => $product->getName(),
97
  'item_id' => $product->getId(),
66
  foreach ($products as $productId) {
67
  $product = Mage::getModel('catalog/product')->load($productId);
68
 
69
+ $dict = Mage::helper('simple_relevance')->getProductDict($product);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
 
 
 
 
 
 
 
 
 
 
71
  $data = array(
72
  'item_name' => $product->getName(),
73
  'item_id' => $product->getId(),
app/code/community/SimpleRelevance/Integration/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <SimpleRelevance_Integration>
5
- <version>0.0.4</version>
6
  </SimpleRelevance_Integration>
7
  </modules>
8
  <global>
@@ -21,6 +21,24 @@
21
  <class>SimpleRelevance_Integration_Helper</class>
22
  </simple_relevance>
23
  </helpers>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  </global>
25
  <frontend>
26
  <translate>
2
  <config>
3
  <modules>
4
  <SimpleRelevance_Integration>
5
+ <version>0.0.5</version>
6
  </SimpleRelevance_Integration>
7
  </modules>
8
  <global>
21
  <class>SimpleRelevance_Integration_Helper</class>
22
  </simple_relevance>
23
  </helpers>
24
+ <events>
25
+ <customer_save_after>
26
+ <observers>
27
+ <simplerelevance_push_customer>
28
+ <class>simple_relevance/observer</class>
29
+ <method>pushCustomer</method>
30
+ </simplerelevance_push_customer>
31
+ </observers>
32
+ </customer_save_after>
33
+ <catalog_product_save_after>
34
+ <observers>
35
+ <simplerelevance_push_item>
36
+ <class>simple_relevance/observer</class>
37
+ <method>pushItem</method>
38
+ </simplerelevance_push_item>
39
+ </observers>
40
+ </catalog_product_save_after>
41
+ </events>
42
  </global>
43
  <frontend>
44
  <translate>
package.xml CHANGED
@@ -1,22 +1,25 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>SimpleRelevance_Integration</name>
4
- <version>0.0.4</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>SimpleRelevance integration module</summary>
10
  <description>Featuring customers, products and orders.</description>
11
- <notes>-- version 0.0.4
 
 
 
12
  Bug fixes, new data on product import, debug facility
13
 
14
  -- version 0.0.1
15
  First release</notes>
16
  <authors><author><name>SimpleRelevance DEV team</name><user>auto-converted</user><email>info@simplerelevance.com</email></author></authors>
17
- <date>2012-04-09</date>
18
- <time>12:08:16</time>
19
- <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="simple_relevance.xml" hash="f0d73f30b7aeff70f63b295327ac906c"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="simple_relevance"><dir name="images"><file name="box-tab.png" hash="208977131fcbe078f10af53295ac686c"/><file name="simplerelevance-header.png" hash="c25099645618a32b8fdb8d4d7786cf2c"/></dir><file name="css.css" hash="c354dd9c0e48bdb99089b1756058efc1"/><file name="js.js" hash="5831e6e503ebd86f93e07230b56a6d2f"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="SimpleRelevance_Integration.csv" hash="05e3ba1c882990c307dbe510bc0bea36"/></dir></target><target name="mageetc"><dir name="modules"><file name="SimpleRelevance_Integration.xml" hash="6ad0b704a9e62de159f09babfe2482d5"/></dir></target><target name="magecommunity"><dir name="SimpleRelevance"><dir name="Integration"><dir name="controllers"><dir name="Adminhtml"><file name="ExportController.php" hash="d85775935a57432a0e673626a629f6b4"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="18e9829f6252920f6bf01a5340377b3a"/><file name="config.xml" hash="63cad149856139d78344ce39ef0e6f3c"/><file name="system.xml" hash="638f6aac1d2d19b8b9d9ca4fed0065f5"/></dir><dir name="Helper"><file name="Data.php" hash="9c0aaa6454c1e3d72b0b88e6933ed500"/></dir><dir name="Model"><file name="Api.php" hash="3598b602c1adf8f425a57836a743e44f"/><file name="Observer.php" hash="191abba7ea01505797b61b0f3bd8ab24"/><file name="Purchase.php" hash="f073c1b379a0946a96ee5fcbfda6cc47"/></dir></dir></dir></target></contents>
20
  <compatible/>
21
  <dependencies/>
22
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>SimpleRelevance_Integration</name>
4
+ <version>0.0.5</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>SimpleRelevance integration module</summary>
10
  <description>Featuring customers, products and orders.</description>
11
+ <notes>-- version 0.0.5
12
+ Automatic Customer and Product submission
13
+
14
+ -- version 0.0.4
15
  Bug fixes, new data on product import, debug facility
16
 
17
  -- version 0.0.1
18
  First release</notes>
19
  <authors><author><name>SimpleRelevance DEV team</name><user>auto-converted</user><email>info@simplerelevance.com</email></author></authors>
20
+ <date>2012-04-11</date>
21
+ <time>12:55:16</time>
22
+ <contents><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="simple_relevance.xml" hash="f0d73f30b7aeff70f63b295327ac906c"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="simple_relevance"><dir name="images"><file name="box-tab.png" hash="208977131fcbe078f10af53295ac686c"/><file name="simplerelevance-header.png" hash="c25099645618a32b8fdb8d4d7786cf2c"/></dir><file name="css.css" hash="c354dd9c0e48bdb99089b1756058efc1"/><file name="js.js" hash="5831e6e503ebd86f93e07230b56a6d2f"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="SimpleRelevance_Integration.csv" hash="05e3ba1c882990c307dbe510bc0bea36"/></dir></target><target name="mageetc"><dir name="modules"><file name="SimpleRelevance_Integration.xml" hash="6ad0b704a9e62de159f09babfe2482d5"/></dir></target><target name="magecommunity"><dir name="SimpleRelevance"><dir name="Integration"><dir name="controllers"><dir name="Adminhtml"><file name="ExportController.php" hash="840104daa154dab436ab043f8ea217af"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="18e9829f6252920f6bf01a5340377b3a"/><file name="config.xml" hash="a06dac4d32e5f010a0ec749484d7ffb9"/><file name="system.xml" hash="638f6aac1d2d19b8b9d9ca4fed0065f5"/></dir><dir name="Helper"><file name="Data.php" hash="7d3955676a03b690a81c4aa98df25514"/></dir><dir name="Model"><file name="Api.php" hash="3598b602c1adf8f425a57836a743e44f"/><file name="Observer.php" hash="3b037003b20423c6dd6a66fdf9b1b1f9"/><file name="Purchase.php" hash="f073c1b379a0946a96ee5fcbfda6cc47"/></dir></dir></dir></target></contents>
23
  <compatible/>
24
  <dependencies/>
25
  </package>