epoqRS - Version 0.9.9

Version Notes

First stable release.
Will be updated to Version 1.0.0 as soon as documentation is available.

Download this release

Release Info

Developer Magento Core Team
Extension epoqRS
Version 0.9.9
Comparing to
See all releases


Version 0.9.9

Files changed (32) hide show
  1. app/code/community/Flagbit/EpoqInterface/Block/Abstract.php +206 -0
  2. app/code/community/Flagbit/EpoqInterface/Block/Export/Productlist.php +225 -0
  3. app/code/community/Flagbit/EpoqInterface/Block/Head.php +28 -0
  4. app/code/community/Flagbit/EpoqInterface/Block/Recommentation/Abstract.php +133 -0
  5. app/code/community/Flagbit/EpoqInterface/Block/Recommentation/Cart.php +37 -0
  6. app/code/community/Flagbit/EpoqInterface/Block/Recommentation/Product.php +37 -0
  7. app/code/community/Flagbit/EpoqInterface/Block/Recommentation/User.php +37 -0
  8. app/code/community/Flagbit/EpoqInterface/Block/System/Config/Form/Field/Version.php +116 -0
  9. app/code/community/Flagbit/EpoqInterface/Block/Track/Cart.php +104 -0
  10. app/code/community/Flagbit/EpoqInterface/Block/Track/Product.php +77 -0
  11. app/code/community/Flagbit/EpoqInterface/Helper/Data.php +21 -0
  12. app/code/community/Flagbit/EpoqInterface/Model/Abstract.php +191 -0
  13. app/code/community/Flagbit/EpoqInterface/Model/Customer/Profiles.php +66 -0
  14. app/code/community/Flagbit/EpoqInterface/Model/Observer.php +91 -0
  15. app/code/community/Flagbit/EpoqInterface/Model/Recommendation/Abstract.php +124 -0
  16. app/code/community/Flagbit/EpoqInterface/Model/Recommendation/Cart.php +65 -0
  17. app/code/community/Flagbit/EpoqInterface/Model/Recommendation/Product.php +44 -0
  18. app/code/community/Flagbit/EpoqInterface/Model/Recommendation/User.php +24 -0
  19. app/code/community/Flagbit/EpoqInterface/Model/Session.php +25 -0
  20. app/code/community/Flagbit/EpoqInterface/Model/System/Config/Source/Attemps.php +30 -0
  21. app/code/community/Flagbit/EpoqInterface/Model/System/Config/Source/Idletime.php +32 -0
  22. app/code/community/Flagbit/EpoqInterface/Model/System/Config/Source/Timeout.php +34 -0
  23. app/code/community/Flagbit/EpoqInterface/controllers/IndexController.php +124 -0
  24. app/code/community/Flagbit/EpoqInterface/etc/config.xml +179 -0
  25. app/code/community/Flagbit/EpoqInterface/etc/system.xml +200 -0
  26. app/design/frontend/default/default/layout/epoqinterface.xml +66 -0
  27. app/design/frontend/default/default/template/epoqinterface/recommendation/cart.phtml +44 -0
  28. app/design/frontend/default/default/template/epoqinterface/recommendation/product.phtml +44 -0
  29. app/design/frontend/default/default/template/epoqinterface/recommendation/user.phtml +45 -0
  30. app/etc/modules/Flagbit_EpoqInterface.xml +26 -0
  31. app/locale/de_DE/Flagbit_EpoqInterface.csv +22 -0
  32. package.xml +23 -0
app/code/community/Flagbit/EpoqInterface/Block/Abstract.php ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Abstract.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Block_Abstract extends Mage_Core_Block_Abstract
19
+ {
20
+
21
+ const XML_TENANT_ID_PATH = 'epoqinterface/config/tenant_id';
22
+ protected $_lastRecommentationId = null;
23
+
24
+
25
+ protected function arrayToString($array, $prefix = null){
26
+
27
+ $output = array();
28
+ foreach($array as $key => $value){
29
+ if(is_array($value)){
30
+ $output = array_merge($output, $this->arrayToString($value, $key));
31
+ }else{
32
+ $output[] = " ".($prefix ? $prefix."['".$key."']" : $key)." = '".addslashes($value)."';";
33
+ }
34
+ }
35
+ return $prefix === null ? implode("\n", $output) : $output;
36
+ }
37
+
38
+ protected function getParamsArray(){
39
+
40
+ $variables = array(
41
+ 'epoq_tenantId' => Mage::getStoreConfig(self::XML_TENANT_ID_PATH),
42
+ 'epoq_sessionId' => Mage::getSingleton('core/session')->getSessionId(),
43
+ );
44
+
45
+ if($customerId = Mage::getSingleton('customer/session')->getId()){
46
+ $variables['epoq_customerId'] = $customerId;
47
+ }
48
+
49
+ if($this->_lastRecommentationId !== null){
50
+ $variables['epoq_recommendationId'] = $this->_lastRecommentationId;
51
+ }
52
+
53
+ return $variables;
54
+ }
55
+
56
+ protected function getJavascriptOutput($content, $function){
57
+
58
+ $output = "<script type=\"text/javascript\">\n";
59
+ $output .= $content."\n";
60
+ $output .= "epoq_".$function."();\n";
61
+ $output .= "</script>\n";
62
+
63
+ return $output;
64
+ }
65
+
66
+ /**
67
+ * get Session
68
+ *
69
+ * @return Flagbit_EpoqInterface_Model_Session
70
+ */
71
+ protected function getSession(){
72
+
73
+ return Mage::getSingleton('epoqinterface/session');
74
+ }
75
+
76
+ /**
77
+ * get final Product Price
78
+ *
79
+ * @param Mage_Catalog_Model_Product $product
80
+ * @return float
81
+ */
82
+ protected function getProductPrice(Mage_Catalog_Model_Product $product){
83
+
84
+ if(version_compare(Mage::getVersion(), '1.3.2', '>=')){
85
+
86
+ $_taxHelper = $this->helper('tax');
87
+ $_simplePricesTax = ($_taxHelper->displayPriceIncludingTax() || $_taxHelper->displayBothPrices());
88
+ $_minimalPriceValue = $product->getMinimalPrice();
89
+ return $_taxHelper->getPrice($product, $_minimalPriceValue, $_simplePricesTax);
90
+
91
+ }
92
+
93
+ return $product->getFinalPrice();
94
+ }
95
+
96
+ protected function getProductAttributes(){
97
+
98
+ $_attributes = array();
99
+
100
+ if($_additional = $this->getAdditionalData()){
101
+
102
+ foreach ($_additional as $_data){
103
+
104
+ $_attributes[$this->__($_data['code'])] = $this->helper('catalog/output')->productAttribute($this->getProduct(), $_data['value'], $_data['code']);
105
+ }
106
+ }
107
+ return $_attributes;
108
+ }
109
+
110
+ /**
111
+ * $excludeAttr is optional array of attribute codes to
112
+ * exclude them from additional data array
113
+ *
114
+ * @param array $excludeAttr
115
+ * @return array
116
+ */
117
+ public function getAdditionalData(array $excludeAttr = array())
118
+ {
119
+ $data = array();
120
+ $product = $this->getProduct();
121
+ $attributes = $product->getAttributes();
122
+ foreach ($attributes as $attribute) {
123
+ // if ($attribute->getIsVisibleOnFront() && $attribute->getIsUserDefined() && !in_array($attribute->getAttributeCode(), $excludeAttr)) {
124
+ if ($attribute->getIsVisibleOnFront() && !in_array($attribute->getAttributeCode(), $excludeAttr)) {
125
+
126
+ $value = $attribute->getFrontend()->getValue($product);
127
+
128
+ // TODO this is temporary skipping eco taxes
129
+ if (is_string($value)) {
130
+ if (strlen($value) && $product->hasData($attribute->getAttributeCode())) {
131
+ if ($attribute->getFrontendInput() == 'price') {
132
+ $value = Mage::app()->getStore()->convertPrice($value,true);
133
+ } elseif (!$attribute->getIsHtmlAllowedOnFront()) {
134
+ $value = $this->htmlEscape($value);
135
+ }
136
+ if(in_array($attribute->getAttributeCode(), array('in_depth'))){
137
+ continue;
138
+ }
139
+
140
+ $data[$attribute->getAttributeCode()] = array(
141
+ // 'label' => $attribute->getFrontend()->getLabel(),
142
+ 'value' => $value,
143
+ 'code' => $attribute->getAttributeCode()
144
+ );
145
+ }
146
+ }
147
+ }
148
+ }
149
+ return $data;
150
+ }
151
+
152
+ protected function getCategoryPath($refresh = false)
153
+ {
154
+ if (!$this->_categoryPath or $refresh == true) {
155
+
156
+ $path = array();
157
+ if ($this->getCategory()) {
158
+ $pathInStore = $this->getCategory()->getPathInStore();
159
+ $pathIds = array_reverse(explode(',', $pathInStore));
160
+
161
+ $categories = Mage::getResourceModel('catalog/category_collection')
162
+ ->setStore(Mage::app()->getStore())
163
+ ->addAttributeToSelect('name')
164
+ ->addAttributeToSelect('url_key')
165
+ ->addFieldToFilter('entity_id', array('in'=>$pathIds))
166
+ ->load()
167
+ ->getItems();
168
+
169
+ // add category path breadcrumb
170
+ foreach ($pathIds as $categoryId) {
171
+ if (isset($categories[$categoryId]) && $categories[$categoryId]->getName()) {
172
+ $categories[$categoryId]->setStoreId(Mage::app()->getStore()->getId());
173
+ $path[] = $categories[$categoryId]->getName();
174
+ }
175
+ }
176
+ }
177
+
178
+
179
+ $this->_categoryPath = $path;
180
+ }
181
+ return $this->_categoryPath;
182
+ }
183
+
184
+
185
+ /**
186
+ * get current Product
187
+ *
188
+ * @return Mage_Catalog_Model_Product
189
+ */
190
+ public function getProduct()
191
+ {
192
+ return Mage::registry('current_product');
193
+ }
194
+
195
+
196
+ /**
197
+ * get current Category
198
+ *
199
+ * @return unknown
200
+ */
201
+ public function getCategory()
202
+ {
203
+ return Mage::registry('current_category');
204
+ }
205
+
206
+ }
app/code/community/Flagbit/EpoqInterface/Block/Export/Productlist.php ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Productlist.php 6 2009-07-03 13:40:19Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Block_Export_Productlist extends Flagbit_EpoqInterface_Block_Abstract
19
+ {
20
+
21
+ /**
22
+ * Class Constuctor
23
+ * Cache Settings
24
+ */
25
+ public function __construct(){
26
+
27
+ // set Cache to one Hour
28
+ $this->setCacheLifetime(3600);
29
+ $this->setCacheKey($this->getNameInLayout().Mage::app()->getStore()->getId());
30
+ parent::__construct();
31
+ }
32
+
33
+ /**
34
+ * generates the Output
35
+ *
36
+ * @return string
37
+ */
38
+ protected function _toHtml()
39
+ {
40
+ // create XML Object
41
+ $xmlObj = new DOMDocument("1.0", "UTF-8");
42
+ $xmlObj->formatOutput = true;
43
+
44
+ // add RSS Element and Namespace
45
+ $elemRss = $xmlObj->createElement( 'rss' );
46
+ $elemRss->setAttribute ( 'version' , '2.0' );
47
+ $elemRss->setAttribute ( 'xmlns:g' , 'http://base.google.com/ns/1.0' );
48
+ $elemRss->setAttribute ( 'xmlns:e' , 'http://base.google.com/cns/1.0' );
49
+ $elemRss->setAttribute ( 'xmlns:c' , 'http://base.google.com/cns/1.0' );
50
+ $xmlObj->appendChild( $elemRss );
51
+
52
+ // add Channel Element
53
+ $elemChannel = $xmlObj->createElement( 'channel' );
54
+ $elemRss->appendChild( $elemChannel );
55
+
56
+ // get Products
57
+ $product = Mage::getModel('catalog/product');
58
+ $products = $product->getCollection()
59
+ ->addStoreFilter()
60
+ ->addAttributeToSort('news_from_date','desc')
61
+ ->addAttributeToSelect(array('name', 'short_description', 'price', 'image'), 'inner');
62
+ //->addAttributeToSelect(array('special_price', 'special_from_date', 'special_to_date'), 'left');
63
+
64
+ Mage::getSingleton('catalog/product_status')->addVisibleFilterToCollection($products);
65
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($products);
66
+
67
+ /*
68
+ using resource iterator to load the data one by one
69
+ instead of loading all at the same time. loading all data at the same time can cause the big memory allocation.
70
+ */
71
+ Mage::getSingleton('core/resource_iterator')
72
+ ->walk($products->getSelect(), array(array($this, 'addNewItemXmlCallback')), array('xmlObj'=> $xmlObj, 'product'=>$product));
73
+
74
+ return $xmlObj->saveXML();
75
+ }
76
+
77
+
78
+ /**
79
+ * Product iterator callback function
80
+ * add detailinformations to products
81
+ *
82
+ * @param array $args
83
+ */
84
+ public function addNewItemXmlCallback($args)
85
+ {
86
+ $product = $args['product'];
87
+ $this->setData('product', $product);
88
+
89
+ /*@var $product Mage_Catalog_Model_Product */
90
+ $product->setData($args['row']);
91
+ $product->load($product->getId());
92
+ $product->loadParentProductIds();
93
+ $parentProduct = $product->getParentProductIds();
94
+
95
+ // get Productcategory
96
+ $category = $product->getCategoryCollection()->load()->getFirstItem();
97
+ $this->setData('category', $category);
98
+
99
+ /*@var $xmlObj DOMDocument*/
100
+ $xmlObj = $args['xmlObj'];
101
+
102
+ // create Item xml Element
103
+ $elemItem = $xmlObj->createElement('item');
104
+
105
+ $data = array(
106
+ 'title' => $product->getName(),
107
+ 'link' => $product->getProductUrl(),
108
+
109
+ // g Namespace
110
+ 'g:id' => $product->getId(),
111
+ 'description' => $product->getShortDescription(),
112
+ 'g:price' => $this->getProductPrice($product),
113
+ 'g:image_link' => (string) $this->helper('catalog/image')->init($product, 'image'),
114
+ 'g:product_type'=> implode('>', $this->getCategoryPath(true)),
115
+ 'g:brand' => $this->getProduct()->getManufacturer(),
116
+
117
+ // e Namespace
118
+ 'e:locakey' => substr(Mage::getSingleton('core/locale')->getLocale(), 0, 2),
119
+
120
+ );
121
+
122
+ // set Product variant
123
+ if(isset($parentProduct[0])){
124
+ $data['e:variant_of'] = $parentProduct[0];
125
+ }
126
+
127
+ // add Product Attributes
128
+ $attributes = $this->getProductAttributes();
129
+ foreach($attributes as $key => $value){
130
+ $data['c:'.$key] = $value;
131
+ }
132
+
133
+ // translate array to XML
134
+ $this->dataToXml($data, 'data', $elemItem, $xmlObj);
135
+
136
+ // add Product to Channel Element
137
+ /*@var $elemChannel DOMNodeList */
138
+ $elemChannel = $xmlObj->getElementsByTagName('channel');
139
+ $elemChannel->item(0)->appendChild( $elemItem );
140
+
141
+ }
142
+
143
+ /**
144
+ * get current Product
145
+ *
146
+ * @return Mage_Catalog_Model_Product
147
+ */
148
+ public function getProduct()
149
+ {
150
+ return $this->getData('product');
151
+ }
152
+
153
+
154
+ /**
155
+ * get current Category
156
+ *
157
+ * @return unknown
158
+ */
159
+ public function getCategory()
160
+ {
161
+ return $this->getData('category');
162
+ }
163
+
164
+
165
+ /**
166
+ * The main function for converting to an XML document.
167
+ * Pass in a multi dimensional array and this recrusively loops through and builds up an XML document.
168
+ *
169
+ * @param array $data
170
+ * @param string $rootNodeName - what you want the root node to be - defaultsto data.
171
+ * @param DomElement $elem - should only be used recursively
172
+ * @param DOMDocument $xml - should only be used recursively
173
+ * @return object DOMDocument
174
+ */
175
+ protected function dataToXml($data, $rootNodeName = 'data', $elem=null, $xml=null)
176
+ {
177
+
178
+ if ($xml === null)
179
+ {
180
+ $xml = new DOMDocument("1.0", "UTF-8");
181
+ $xml->formatOutput = true;
182
+ $elem = $xml->createElement( $rootNodeName );
183
+ $xml->appendChild( $elem );
184
+ }
185
+
186
+ // loop through the data passed in.
187
+ foreach($data as $key => $value)
188
+ {
189
+ // no numeric keys in our xml please!
190
+ if (is_numeric($key))
191
+ {
192
+ // make string key...
193
+ $key = "node_". (string) $key;
194
+ }
195
+
196
+ // replace anything not alpha numeric
197
+ $key = preg_replace('/[^a-z0-9\_\:]/i', '', $key);
198
+
199
+ // if there is another array found recrusively call this function
200
+ if (is_array($value))
201
+ {
202
+ $subelem = $xml->createElement( $key );
203
+ $elem->appendChild( $subelem);
204
+
205
+ // recrusive call.
206
+ $this->DataToXml($value, $rootNodeName, $subelem, $xml);
207
+ }
208
+ else
209
+ {
210
+ $subelem = $xml->createElement( $key );
211
+ $subelem->appendChild(
212
+ strstr($value, array('<', '>', '&'))
213
+ ? $xml->createCDATASection( $value )
214
+ : $xml->createTextNode( $value )
215
+ );
216
+ $elem->appendChild( $subelem );
217
+
218
+ }
219
+ }
220
+
221
+ // pass back as DOMDocument object
222
+ return $xml;
223
+ }
224
+
225
+ }
app/code/community/Flagbit/EpoqInterface/Block/Head.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Head.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Block_Head extends Mage_Core_Block_Abstract
19
+ {
20
+ protected function _toHtml()
21
+ {
22
+ if (!$this->_beforeToHtml()) {
23
+ return '';
24
+ }
25
+
26
+ return '<script type="text/javascript" src="http://rs.epoq.de/web-api/epoq.js"></script>';
27
+ }
28
+ }
app/code/community/Flagbit/EpoqInterface/Block/Recommentation/Abstract.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Abstract.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Block_Recommentation_Abstract extends Mage_Catalog_Block_Product_Abstract
19
+ {
20
+ protected $_columnCount = 4;
21
+
22
+ protected $_items;
23
+
24
+ protected $_itemCollection;
25
+
26
+ protected $_itemLimits = array();
27
+
28
+ protected function _prepareData()
29
+ {
30
+
31
+ $this->_itemCollection = Mage::getSingleton($this->_collectionModel)->getCollection()
32
+ ->addStoreFilter();
33
+
34
+ Mage::getResourceSingleton('checkout/cart')->addExcludeProductFilter($this->_itemCollection,
35
+ Mage::getSingleton('checkout/session')->getQuoteId()
36
+ );
37
+ $this->_addProductAttributesAndPrices($this->_itemCollection);
38
+
39
+ Mage::getSingleton('catalog/product_visibility')->addVisibleInCatalogFilterToCollection($this->_itemCollection);
40
+
41
+ if ($this->getItemLimit('upsell') > 0) {
42
+ $this->_itemCollection->setPageSize($this->getItemLimit('upsell'));
43
+ }
44
+
45
+ $this->_itemCollection->load();
46
+
47
+ foreach ($this->_itemCollection as $product) {
48
+ $product->setDoNotUseCategoryId(true);
49
+ }
50
+
51
+ return $this;
52
+ }
53
+
54
+ protected function _beforeToHtml()
55
+ {
56
+ $this->_prepareData();
57
+ return parent::_beforeToHtml();
58
+ }
59
+
60
+ public function getItemCollection()
61
+ {
62
+ return $this->_itemCollection;
63
+ }
64
+
65
+ public function getItems()
66
+ {
67
+ if (is_null($this->_items)) {
68
+ $this->_items = $this->getItemCollection()->getItems();
69
+ }
70
+ return $this->_items;
71
+ }
72
+
73
+ public function getRowCount()
74
+ {
75
+ return ceil(count($this->getItemCollection()->getItems())/$this->getColumnCount());
76
+ }
77
+
78
+ public function setColumnCount($columns)
79
+ {
80
+ if (intval($columns) > 0) {
81
+ $this->_columnCount = intval($columns);
82
+ }
83
+ return $this;
84
+ }
85
+
86
+ public function getColumnCount()
87
+ {
88
+ return $this->_columnCount;
89
+ }
90
+
91
+ public function resetItemsIterator()
92
+ {
93
+ $this->getItems();
94
+ reset($this->_items);
95
+ }
96
+
97
+ public function getIterableItem()
98
+ {
99
+ $item = current($this->_items);
100
+ next($this->_items);
101
+ return $item;
102
+ }
103
+
104
+ /**
105
+ * Set how many items we need to show in upsell block
106
+ * Notice: this parametr will be also applied
107
+ *
108
+ * @param string $type
109
+ * @param int $limit
110
+ * @return Mage_Catalog_Block_Product_List_Upsell
111
+ */
112
+ public function setItemLimit($type, $limit)
113
+ {
114
+ if (intval($limit) > 0) {
115
+ $this->_itemLimits[$type] = intval($limit);
116
+ }
117
+ return $this;
118
+ }
119
+
120
+ public function getItemLimit($type = '')
121
+ {
122
+ if ($type == '') {
123
+ return $this->_itemLimits;
124
+ }
125
+ if (isset($this->_itemLimits[$type])) {
126
+ return $this->_itemLimits[$type];
127
+ }
128
+ else {
129
+ return 0;
130
+ }
131
+ }
132
+
133
+ }
app/code/community/Flagbit/EpoqInterface/Block/Recommentation/Cart.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Cart.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Block_Recommentation_Cart extends Flagbit_EpoqInterface_Block_Recommentation_Abstract
19
+ {
20
+
21
+ protected $_collectionModel = 'epoqinterface/recommendation_cart';
22
+ const XML_STATUS_PATH = 'epoqinterface/display_recommendation/cart';
23
+
24
+ /**
25
+ * Render block HTML
26
+ *
27
+ * @return string
28
+ */
29
+ protected function _toHtml()
30
+ {
31
+ if(!Mage::getStoreConfig(self::XML_STATUS_PATH)){
32
+ return '';
33
+ }
34
+
35
+ return parent::_toHtml();
36
+ }
37
+ }
app/code/community/Flagbit/EpoqInterface/Block/Recommentation/Product.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Product.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Block_Recommentation_Product extends Flagbit_EpoqInterface_Block_Recommentation_Abstract
19
+ {
20
+
21
+ protected $_collectionModel = 'epoqinterface/recommendation_product';
22
+ const XML_STATUS_PATH = 'epoqinterface/display_recommendation/product';
23
+
24
+ /**
25
+ * Render block HTML
26
+ *
27
+ * @return string
28
+ */
29
+ protected function _toHtml()
30
+ {
31
+ if(!Mage::getStoreConfig(self::XML_STATUS_PATH)){
32
+ return '';
33
+ }
34
+
35
+ return parent::_toHtml();
36
+ }
37
+ }
app/code/community/Flagbit/EpoqInterface/Block/Recommentation/User.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: User.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Block_Recommentation_User extends Flagbit_EpoqInterface_Block_Recommentation_Abstract
19
+ {
20
+
21
+ protected $_collectionModel = 'epoqinterface/recommendation_user';
22
+ const XML_STATUS_PATH = 'epoqinterface/display_recommendation/user';
23
+
24
+ /**
25
+ * Render block HTML
26
+ *
27
+ * @return string
28
+ */
29
+ protected function _toHtml()
30
+ {
31
+ if(!Mage::getStoreConfig(self::XML_STATUS_PATH)){
32
+ return '';
33
+ }
34
+
35
+ return parent::_toHtml();
36
+ }
37
+ }
app/code/community/Flagbit/EpoqInterface/Block/System/Config/Form/Field/Version.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Cart.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+
19
+ class Flagbit_EpoqInterface_Block_System_Config_Form_Field_Version extends Mage_Adminhtml_Block_System_Config_Form_Field
20
+ {
21
+
22
+ protected $versionUrl = 'http://epoq.flagbit.de/';
23
+
24
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
25
+ {
26
+
27
+ $version = (string) Mage::getConfig()->getModuleConfig('Flagbit_EpoqInterface')->version;
28
+ $curVersion = $this->getCurrentVersion($version);
29
+
30
+ $notice = '';
31
+ $icon = '';
32
+ if($curVersion !== null){
33
+
34
+ if(version_compare($version, $curVersion, '>=')){
35
+ $icon = '<img src="'.$this->getSkinUrl('images/fam_bullet_success.gif').'" style="float: left; margin-right: 3px;"/>';
36
+ $notice = $this->__('up to date');
37
+
38
+ }elseif(version_compare($version, $curVersion, '<')){
39
+ $icon = '<img src="'.$this->getSkinUrl('images/error_msg_icon.gif').'" style="float: left; margin-right: 3px;"/>';
40
+ $notice = $this->__('new Version %s ready for Download', $curVersion);
41
+ }
42
+ }
43
+
44
+ return $icon.$version. ($notice ? ' <strong>('.$notice.')</strong>' : '');
45
+ }
46
+
47
+
48
+ /**
49
+ * Retrieve Last update time
50
+ *
51
+ * @return int
52
+ */
53
+ public function getLastUpdate()
54
+ {
55
+ return Mage::app()->loadCache('epoqinterface_version_lastcheck');
56
+ }
57
+
58
+ /**
59
+ * Set last update time (now)
60
+ *
61
+ * @return Flagbit_EpoqInterface_Block_System_Config_Form_Field_Version
62
+ */
63
+ public function setLastUpdate()
64
+ {
65
+ Mage::app()->saveCache(time(), 'epoqinterface_version_lastcheck');
66
+ return $this;
67
+ }
68
+
69
+ /**
70
+ * Retrieve current Version
71
+ *
72
+ * @return int
73
+ */
74
+ public function getCurrentVersion($version = '')
75
+ {
76
+ $currentVersion = Mage::app()->loadCache('epoqinterface_version_current');
77
+
78
+ if($this->getLastUpdate() + (60 * 60 * 24) < time() or !$currentVersion){
79
+
80
+ try{
81
+
82
+ $client = new Zend_Http_Client;
83
+ $result = $client->setUri($this->versionUrl)
84
+ ->setMethod(Zend_Http_Client::POST)
85
+ ->setConfig(
86
+ array(
87
+ 'timeout' => 1
88
+ )
89
+ )
90
+ ->setParameterPost(
91
+ array(
92
+ 'do' => 'versioncheck',
93
+ 'version' => $version
94
+ )
95
+ )
96
+ ->request();
97
+
98
+ $this->setLastUpdate();
99
+
100
+ $currentVersion = trim($result->getBody());
101
+ Mage::app()->saveCache($currentVersion, 'epoqinterface_version_current');
102
+
103
+ }catch (Exception $e){
104
+
105
+ return null;
106
+ }
107
+ }
108
+
109
+ if(!preg_match('/([0-9]+)\.([0-9]+)\.([0-9]+)/', $currentVersion)){
110
+ return null;
111
+ }
112
+
113
+ return $currentVersion;
114
+ }
115
+
116
+ }
app/code/community/Flagbit/EpoqInterface/Block/Track/Cart.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Cart.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Block_Track_Cart extends Flagbit_EpoqInterface_Block_Abstract
19
+ {
20
+
21
+ protected $_quote = null;
22
+
23
+ protected function _toHtml()
24
+ {
25
+
26
+ if (!$this->_beforeToHtml()
27
+ or !$this->getSession()->getCartUpdate()
28
+ && !$this->getSession()->getBlockTrackCartOutput()) {
29
+ return '';
30
+ }
31
+
32
+ $output = $this->getSession()->getBlockTrackCartOutput();
33
+
34
+ if($output){
35
+ $this->getSession()->unsBlockTrackCartOutput();
36
+ $this->getSession()->unsCartUpdate();
37
+ return $output;
38
+ }
39
+
40
+ $variables = array(
41
+ 'epoq_tenantId' => Mage::getStoreConfig('epoqinterface/config/tenant_id'),
42
+ 'epoq_sessionId' => Mage::getSingleton('core/session')->getSessionId(),
43
+ );
44
+
45
+
46
+
47
+ $function = $this->getSession()->getCartUpdate() == 'process' ? 'processCart' : 'updateCart';
48
+
49
+ $this->getSession()->unsCartUpdate();
50
+
51
+ return $this->getJavascriptOutput(
52
+ $this->arrayToString(
53
+ $this->getParamsArray()
54
+ ),
55
+ $function);
56
+ }
57
+
58
+ protected function getParamsArray(){
59
+
60
+ $variables = parent::getParamsArray();
61
+
62
+ $items = $this->getQuote()->getAllVisibleItems();
63
+
64
+ /*@var $item Mage_Sales_Model_Quote_Item */
65
+ foreach ($items as $key => $item){
66
+
67
+ if ($option = $item->getOptionByCode('simple_product')) {
68
+
69
+ $product = $option->getProduct();
70
+ $variables['epoq_variantOf'][$key] = $item->getProduct()->getId();
71
+ }else{
72
+ $product = $item->getProduct();
73
+ }
74
+
75
+ $variables['epoq_productIds'][$key] = $product->getId();
76
+ $variables['epoq_quantities'][$key] = $item->getQty();
77
+ $variables['epoq_unitPrices'][$key] = $item->getPrice();
78
+ }
79
+
80
+ return $variables;
81
+ }
82
+
83
+ /**
84
+ * get Quote
85
+ *
86
+ * @return Mage_Sales_Model_Quote
87
+ */
88
+ protected function getQuote(){
89
+
90
+ if($this->_quote === null){
91
+ $this->_quote = Mage::getSingleton('checkout/cart')->getQuote();
92
+ }
93
+
94
+ return $this->_quote;
95
+ }
96
+
97
+ public function setQuote($quote){
98
+
99
+ $this->_quote = $quote;
100
+
101
+ return $this;
102
+ }
103
+
104
+ }
app/code/community/Flagbit/EpoqInterface/Block/Track/Product.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Product.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Block_Track_Product extends Flagbit_EpoqInterface_Block_Abstract
19
+ {
20
+
21
+ protected $_categoryPath;
22
+
23
+ /**
24
+ * Internal constructor, that is called from real constructor
25
+ *
26
+ */
27
+ protected function _construct(){
28
+
29
+ if($this->getSession()->getLastRecommentationId()
30
+ && $this->_lastRecommentationId === null){
31
+ if(in_array($this->getProduct()->getId(), (array) $this->getSession()->getLastRecommentationProducts())){
32
+
33
+ $this->_lastRecommentationId = $this->getSession()->getLastRecommentationId();
34
+ }
35
+ }
36
+
37
+ parent::_construct();
38
+ }
39
+
40
+ protected function _toHtml()
41
+ {
42
+
43
+ if (!$this->_beforeToHtml()
44
+ or !$this->getProduct() instanceof Mage_Catalog_Model_Product) {
45
+ return '';
46
+ }
47
+
48
+ return $this->getJavascriptOutput(
49
+ $this->arrayToString(
50
+ $this->getParamsArray()
51
+ ),
52
+ 'viewItem');
53
+ }
54
+
55
+ protected function getParamsArray(){
56
+
57
+ $variables = array(
58
+ 'epoq_productId' => $this->getProduct()->getId(),
59
+ 'epoq_name' => $this->getProduct()->getName(),
60
+ 'epoq_price' => $this->getProductPrice($this->getProduct()),
61
+ 'epoq_productUrl' => $this->getProduct()->getProductUrl(),
62
+ 'epoq_smallImage' => (string) $this->helper('catalog/image')->init($this->getProduct(), 'small_image')->resize(135, 135),
63
+ 'epoq_category' => implode('>', $this->getCategoryPath()),
64
+ 'epoq_brand' => $this->getProduct()->getManufacturer(),
65
+ 'epog_largeImage' => (string) $this->helper('catalog/image')->init($this->getProduct(), 'image'),
66
+ 'epog_description' => $this->getProduct()->getDescription(),
67
+ 'epoqinStock' => ($this->getProduct()->isSaleable() ? 'true' : 'false'),
68
+ 'epoq_attributes' => $this->getProductAttributes(),
69
+ 'epoq_locakey' => substr(Mage::getSingleton('core/locale')->getLocale(), 0, 2)
70
+ );
71
+
72
+ return array_merge(parent::getParamsArray(), $variables);
73
+ }
74
+
75
+
76
+
77
+ }
app/code/community/Flagbit/EpoqInterface/Helper/Data.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Data.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+ class Flagbit_EpoqInterface_Helper_Data extends Mage_Core_Helper_Abstract
18
+ {
19
+
20
+
21
+ }
app/code/community/Flagbit/EpoqInterface/Model/Abstract.php ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Abstract.php 6 2009-07-03 13:40:19Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Model_Abstract extends Mage_Core_Model_Abstract {
19
+
20
+ const XML_REST_URL_PATH = 'system/epoqinterface/rest_url';
21
+ const XML_TENANT_ID_PATH = 'epoqinterface/config/tenant_id';
22
+ const XML_TIMEOUT_PATH = 'epoqinterface/config/timeout';
23
+ const XML_CUSTOMER_PROFILES_PATH = 'epoqinterface/config/customer_profiles';
24
+ const XML_ERROR_HANDLING_PATH = 'epoqinterface/error_handling/enabled';
25
+ const XML_MAX_ATTEMPTS_PATH = 'epoqinterface/error_handling/max_attempts';
26
+ const XML_IDLE_TIME_PATH = 'epoqinterface/error_handling/idle_time';
27
+ const XML_DEMO_PATH = 'epoqinterface/config/demo';
28
+ const CACHE_REQUEST_FAILURE_COUNTER = 'epoqinterface_rest_failure_counter';
29
+ const CACHE_REQUEST_FAILURE_TIME = 'epoqinterface_rest_failure_time';
30
+
31
+ protected $_restClient= null;
32
+
33
+
34
+
35
+ /**
36
+ * do REST Request an handle Error
37
+ *
38
+ * @return Zend_Rest_Client_Result | null
39
+ */
40
+ protected function _doRequest(){
41
+
42
+ // error handling
43
+ if($this->getIsErrorHandling()
44
+ && $this->getFailureCount() >= Mage::getStoreConfig(self::XML_MAX_ATTEMPTS_PATH)
45
+ && $this->getRequestFailureTime() > time()){
46
+
47
+ return null;
48
+ }
49
+
50
+ try{
51
+ /*@var $result Zend_Rest_Client_Result */
52
+ $result = $this->getRestClient()->get();
53
+
54
+ }catch (Exception $e){
55
+
56
+ // developer mode
57
+ if(Mage::getIsDeveloperMode()){
58
+
59
+ Zend_Debug::dump($this->getRestClient()->getUri()->getUri());
60
+ Zend_Debug::dump($this->getRestClient()->getHttpClient()->getLastResponse());
61
+ throw $e;
62
+
63
+ // error handling
64
+ }elseif($this->getIsErrorHandling()){
65
+
66
+ $this->updateRequestFailureTime();
67
+ $this->updateFailureCount();
68
+ }
69
+ return null;
70
+ }
71
+
72
+ // reset error handling
73
+ if($this->getIsErrorHandling() && $this->getFailureCount()){
74
+ $this->updateFailureCount(true);
75
+ }
76
+
77
+ return $result;
78
+ }
79
+
80
+ /**
81
+ * return Zend Rest Client
82
+ *
83
+ * @return Zend_Rest_Client
84
+ */
85
+ public function getRestClient(){
86
+
87
+ if(!$this->_restClient instanceof Zend_Rest_Client) {
88
+
89
+ $this->_restClient = new Zend_Rest_Client();
90
+ $this->_restClient->getHttpClient()->setConfig(
91
+ array(
92
+ 'timeout' => Mage::getStoreConfig(self::XML_TIMEOUT_PATH)
93
+ )
94
+ );
95
+ }
96
+
97
+ return $this->_restClient;
98
+ }
99
+
100
+ /**
101
+ * update Request Failure Time
102
+ *
103
+ */
104
+ public function updateRequestFailureTime(){
105
+
106
+ Mage::app()->saveCache(time() + Mage::getStoreConfig(self::XML_IDLE_TIME_PATH) * 60, self::CACHE_REQUEST_FAILURE_TIME);
107
+ }
108
+
109
+ /**
110
+ * get Request Failure Time
111
+ *
112
+ * @return int
113
+ */
114
+ public function getRequestFailureTime(){
115
+
116
+ return Mage::app()->loadCache(self::CACHE_REQUEST_FAILURE_TIME);
117
+ }
118
+
119
+ /**
120
+ * update Failure Counter
121
+ *
122
+ * @param boolean $reset
123
+ */
124
+ public function updateFailureCount($reset=false)
125
+ {
126
+
127
+ $count = $reset ? 0 : $this->getFailureCount() + 1;
128
+
129
+ Mage::app()->saveCache($count, self::CACHE_REQUEST_FAILURE_COUNTER);
130
+ }
131
+
132
+
133
+ /**
134
+ * get Failure count
135
+ *
136
+ * @return int
137
+ */
138
+ public function getFailureCount()
139
+ {
140
+ return Mage::app()->loadCache(self::CACHE_REQUEST_FAILURE_COUNTER);
141
+ }
142
+
143
+ /**
144
+ * get is Error Handling enabled
145
+ *
146
+ * @return boolean
147
+ */
148
+ public function getIsErrorHandling(){
149
+
150
+ return Mage::getStoreConfig(self::XML_ERROR_HANDLING_PATH) ? true : false;
151
+ }
152
+
153
+ /**
154
+ * get Session
155
+ *
156
+ * @return Flagbit_EpoqInterface_Model_Session
157
+ */
158
+ protected function getSession(){
159
+
160
+ return Mage::getSingleton('epoqinterface/session');
161
+ }
162
+
163
+
164
+
165
+ protected function getParamsArray(){
166
+
167
+ $variables = array(
168
+ 'tenantId' => Mage::getStoreConfig(self::XML_TENANT_ID_PATH),
169
+ 'sessionId' => Mage::getSingleton('core/session')->getSessionId(),
170
+ );
171
+
172
+ return $variables;
173
+ }
174
+
175
+
176
+ public function getRestUrl(){
177
+
178
+ return Mage::getStoreConfig(self::XML_REST_URL_PATH);
179
+ }
180
+
181
+ public function getTenantId(){
182
+
183
+ return Mage::getStoreConfig(self::XML_TENANT_ID_PATH);
184
+ }
185
+
186
+ public function getSessionId(){
187
+
188
+ return Mage::getSingleton('core/session')->getSessionId();
189
+ }
190
+
191
+ }
app/code/community/Flagbit/EpoqInterface/Model/Customer/Profiles.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Cart.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Model_Customer_Profiles extends Flagbit_EpoqInterface_Model_Abstract {
19
+
20
+
21
+ /**
22
+ * send Customer Data
23
+ *
24
+ * @param Mage_Sales_Model_Order $order
25
+ */
26
+ public function send($order){
27
+
28
+ if(!Mage::getStoreConfig(self::XML_CUSTOMER_PROFILES_PATH)){
29
+ return;
30
+ }
31
+
32
+
33
+ /*@var $address Mage_Sales_Model_Order_Address */
34
+ $address = $order->getBillingAddress();
35
+
36
+ $customerData = array(
37
+ 'tenantId' => Mage::getStoreConfig(self::XML_TENANT_ID_PATH),
38
+ 'sessionId' => Mage::getSingleton('core/session')->getSessionId(),
39
+ 'customerId' => $order->getCustomerId(),
40
+ 'firstName' => $address->getFirstname(),
41
+ 'lastName' => $address->getLastname(),
42
+ 'sex' => '',
43
+ 'title' => '',
44
+ 'street' => preg_replace('([0-9]*)', '', (string) $address->getData('street')),
45
+ 'house' => preg_replace('/([^0-9]*)/', '', (string) $address->getData('street')),
46
+ 'city' => $address->getCity(),
47
+ 'zip' => $address->getPostcode(),
48
+ 'phone' => $address->getTelephone(),
49
+ 'country' => $address->getCountryId()
50
+ );
51
+
52
+ /*@var $client Zend_Rest_Client*/
53
+ $client = $this->getRestClient();
54
+
55
+ /*@var $httpClient Zend_Http_Client */
56
+ $httpClient = $client->getHttpClient();
57
+ $result = $httpClient
58
+ ->setUri($this->getRestUrl().'setAddress?tenantId='.Mage::getStoreConfig(self::XML_TENANT_ID_PATH).'&')
59
+ ->setParameterPost($customerData)
60
+ ->request(Zend_Http_Client::POST);
61
+
62
+ }
63
+
64
+
65
+ }
66
+
app/code/community/Flagbit/EpoqInterface/Model/Observer.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Observer.php 8 2009-07-06 15:09:21Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Model_Observer {
19
+
20
+ /**
21
+ * get Session
22
+ *
23
+ * @return Flagbit_EpoqInterface_Model_Session
24
+ */
25
+ protected function getSession(){
26
+
27
+ return Mage::getSingleton('epoqinterface/session');
28
+ }
29
+
30
+ /**
31
+ * Observer: Add product to shopping cart (quote)
32
+ *
33
+ * @param Varien_Event_Observer $observer
34
+ */
35
+ public function checkoutCartProductAddAfter($observer){
36
+
37
+ $this->getSession()->setCartUpdate('add');
38
+ }
39
+
40
+ /**
41
+ * Observer: Update cart items information
42
+ *
43
+ * @param Varien_Event_Observer $observer
44
+ */
45
+ public function checkoutCartUpdateItemsAfter($observer){
46
+
47
+ $this->getSession()->setCartUpdate('update');
48
+ }
49
+
50
+
51
+ /**
52
+ * Observer: Update cart items information
53
+ *
54
+ * @param Varien_Event_Observer $observer
55
+ */
56
+ public function controllerActionPredispatchCheckoutCartDelete($observer){
57
+
58
+ $this->getSession()->setCartUpdate('remove');
59
+ }
60
+
61
+
62
+ /**
63
+ * Observer: salesOrderPlaceAfter
64
+ *
65
+ * @param Varien_Event_Observer $observer
66
+ */
67
+ public function salesOrderPlaceAfter($observer){
68
+
69
+ /*@var $order Mage_Sales_Model_Order */
70
+ $order = $observer->getOrder();
71
+
72
+ Mage::getSingleton('epoqinterface/customer_profiles')->send($order);
73
+ }
74
+
75
+ /**
76
+ * Observer: sales_order_place_before
77
+ *
78
+ * @param Varien_Event_Observer $observer
79
+ */
80
+ public function salesOrderPlaceBefore($observer){
81
+
82
+ $this->getSession()->setCartUpdate('process');
83
+
84
+ /*@var $block Flagbit_EpoqInterface_Block_Track_Cart */
85
+ $block = Mage::app()->getLayout()->createBlock('epoqinterface/track_cart', 'epoqinterface_track_order');
86
+
87
+ $this->getSession()->setBlockTrackCartOutput($block->toHtml());
88
+
89
+ }
90
+
91
+ }
app/code/community/Flagbit/EpoqInterface/Model/Recommendation/Abstract.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Abstract.php 7 2009-07-06 15:05:38Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Model_Recommendation_Abstract extends Flagbit_EpoqInterface_Model_Abstract {
19
+
20
+
21
+ /**
22
+ * Constructor
23
+ *
24
+ * @param string|Zend_Uri_Http $uri URI for the web service
25
+ * @return void
26
+ */
27
+ public function __construct()
28
+ {
29
+ // get Data
30
+ $result = $this->_doRequest();
31
+ if(!$result instanceof Zend_Rest_Client_Result){
32
+ return;
33
+ }
34
+
35
+ // generate product ID array
36
+ $productIds = array();
37
+ if($result->getIterator() instanceof SimpleXMLElement){
38
+
39
+ foreach($result->getIterator()->recommendation as $product){
40
+ $productIds[] = (int) $product->productId;
41
+
42
+ }
43
+ }
44
+
45
+ // set Data
46
+ $this->setProductIds($productIds);
47
+ $this->setRecommendationId((string) $result->getIterator()->recommendationId);
48
+
49
+ $this->getSession()->setLastRecommentationId($this->getRecommendationId());
50
+ $this->getSession()->setLastRecommentationProducts($this->getProductIds());
51
+
52
+ }
53
+
54
+
55
+ /**
56
+ * get Product Collection
57
+ *
58
+ * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
59
+ */
60
+ public function getCollection(){
61
+
62
+ /*@var $collection Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection */
63
+ $collection = Mage::getResourceModel('catalog/product_collection');
64
+
65
+ $collection->addIdFilter($this->getProductIds());
66
+ return $collection;
67
+ }
68
+
69
+ /**
70
+ * return Zend Rest Client
71
+ *
72
+ * @return Zend_Rest_Client
73
+ */
74
+ public function getRestClient(){
75
+
76
+ if(!$this->_restClient instanceof Zend_Rest_Client) {
77
+
78
+ $url = $this->getRestUrl().'getRecommendationsFor'.$this->_getRecommendationFor.'?'.$this->_httpBuildQuery($this->getParamsArray());
79
+
80
+ $this->_restClient = new Zend_Rest_Client($url);
81
+ $this->_restClient->getHttpClient()->setConfig(
82
+ array(
83
+ 'timeout' => Mage::getStoreConfig(self::XML_TIMEOUT_PATH)
84
+ )
85
+ );
86
+ }
87
+
88
+ return $this->_restClient;
89
+ }
90
+
91
+ protected function _httpBuildQuery($array, $previousKey=''){
92
+
93
+ $string = '';
94
+ foreach($array as $key => $value){
95
+
96
+ if(is_array($value)){
97
+ $string .= ($string ? '&' : '').$this->_httpBuildQuery($value, $key);
98
+ continue;
99
+ }
100
+
101
+ $string .= ($string ? '&' : '').(is_numeric($key) && $previousKey ? $previousKey : $key ).($value ? '='.urlencode($value) : '');
102
+ }
103
+ return $string;
104
+ }
105
+
106
+ protected function getParamsArray(){
107
+
108
+ $variables = array(
109
+ 'tenantId' => Mage::getStoreConfig(self::XML_TENANT_ID_PATH),
110
+ 'sessionId' => Mage::getSingleton('core/session')->getSessionId(),
111
+ 'demo' => Mage::getStoreConfig(self::XML_DEMO_PATH) ? 0 : 6,
112
+ 'widgetTheme' => 'xml'
113
+ );
114
+
115
+ if($customerId = Mage::getSingleton('customer/session')->getId()){
116
+ $variables['customerId'] = $customerId;
117
+ }
118
+
119
+ return $variables;
120
+ }
121
+
122
+
123
+
124
+ }
app/code/community/Flagbit/EpoqInterface/Model/Recommendation/Cart.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Cart.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Model_Recommendation_Cart extends Flagbit_EpoqInterface_Model_Recommendation_Abstract {
19
+
20
+ protected $_getRecommendationFor = 'Cart';
21
+
22
+ protected function getParamsArray(){
23
+
24
+ $params = parent::getParamsArray();
25
+
26
+ $items = $this->getQuote()->getAllVisibleItems();
27
+
28
+ /*@var $item Mage_Sales_Model_Quote_Item */
29
+ foreach ($items as $key => $item){
30
+
31
+ if ($option = $item->getOptionByCode('simple_product')) {
32
+
33
+ $product = $option->getProduct();
34
+ $variables['variantOf'][$key] = $item->getProduct()->getId();
35
+ }else{
36
+ $product = $item->getProduct();
37
+ }
38
+
39
+ $params['productId'][$key] = $product->getId();
40
+ $params['quantity'][$key] = $item->getQty();
41
+ $params['unitPrice'][$key] = $item->getPrice();
42
+ }
43
+
44
+ $params['updateCart'] = '';
45
+
46
+ return $params;
47
+ }
48
+
49
+
50
+ /**
51
+ * get Quote
52
+ *
53
+ * @return Mage_Sales_Model_Quote
54
+ */
55
+ protected function getQuote(){
56
+
57
+ if($this->_quote === null){
58
+ $this->_quote = Mage::getSingleton('checkout/cart')->getQuote();
59
+ }
60
+
61
+ return $this->_quote;
62
+ }
63
+
64
+ }
65
+
app/code/community/Flagbit/EpoqInterface/Model/Recommendation/Product.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Product.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Model_Recommendation_Product extends Flagbit_EpoqInterface_Model_Recommendation_Abstract {
19
+
20
+ protected $_getRecommendationFor = 'Item';
21
+
22
+ protected function getParamsArray(){
23
+
24
+ $params = array(
25
+ 'productId' => $this->getProduct()->getId(),
26
+ );
27
+
28
+ return array_merge($params, parent::getParamsArray());
29
+ }
30
+
31
+
32
+ /**
33
+ * get current Product
34
+ *
35
+ * @return Mage_Catalog_Model_Product
36
+ */
37
+ public function getProduct()
38
+ {
39
+ return Mage::registry('current_product');
40
+ }
41
+
42
+
43
+ }
44
+
app/code/community/Flagbit/EpoqInterface/Model/Recommendation/User.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: User.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Model_Recommendation_User extends Flagbit_EpoqInterface_Model_Recommendation_Abstract {
19
+
20
+ protected $_getRecommendationFor = 'Customer';
21
+
22
+
23
+ }
24
+
app/code/community/Flagbit/EpoqInterface/Model/Session.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Session.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Model_Session extends Mage_Core_Model_Session_Abstract {
19
+
20
+ public function __construct()
21
+ {
22
+ $this->init('epoqinterface');
23
+ }
24
+
25
+ }
app/code/community/Flagbit/EpoqInterface/Model/System/Config/Source/Attemps.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Abstract.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Model_System_Config_Source_Attemps
19
+ {
20
+ public function toOptionArray()
21
+ {
22
+ $array = array();
23
+ for($i=1; $i<=10; $i++){
24
+
25
+ $array[$i] = $i;
26
+ }
27
+
28
+ return $array;
29
+ }
30
+ }
app/code/community/Flagbit/EpoqInterface/Model/System/Config/Source/Idletime.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Abstract.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Model_System_Config_Source_Idletime
19
+ {
20
+ public function toOptionArray()
21
+ {
22
+ return array(
23
+ 5 => Mage::helper('epoqinterface')->__('%d Minutes', 5),
24
+ 10 => Mage::helper('epoqinterface')->__('%d Minutes', 10),
25
+ 20 => Mage::helper('epoqinterface')->__('%d Minutes', 20),
26
+ 30 => Mage::helper('epoqinterface')->__('%d Minutes', 30),
27
+ 60 => Mage::helper('epoqinterface')->__('%d Hour', 1),
28
+ 120 => Mage::helper('epoqinterface')->__('%d Hours', 2),
29
+
30
+ );
31
+ }
32
+ }
app/code/community/Flagbit/EpoqInterface/Model/System/Config/Source/Timeout.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: Abstract.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_Model_System_Config_Source_Timeout
19
+ {
20
+ public function toOptionArray()
21
+ {
22
+ $array = array();
23
+ for($i=1; $i<=10; $i++){
24
+
25
+ if($i == 1){
26
+ $array[$i] = Mage::helper('epoqinterface')->__('%d Second', $i);
27
+ }else{
28
+ $array[$i] = Mage::helper('epoqinterface')->__('%d Seconds', $i);
29
+ }
30
+ }
31
+
32
+ return $array;
33
+ }
34
+ }
app/code/community/Flagbit/EpoqInterface/controllers/IndexController.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * epoqinterface is free software; you can redistribute it and/or modify *
6
+ * it under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: IndexController.php 5 2009-07-03 09:22:08Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+
18
+ class Flagbit_EpoqInterface_IndexController extends Mage_Core_Controller_Front_Action {
19
+
20
+ const XML_STATUS_PATH = 'epoqinterface/export/enabled';
21
+ const XML_AUTH_USERNAME_PATH = 'epoqinterface/export/username';
22
+ const XML_AUTH_PASSWORD_PATH = 'epoqinterface/export/password';
23
+
24
+ public function preDispatch()
25
+ {
26
+
27
+ // check if export is enabled
28
+ if(!Mage::getStoreConfig(self::XML_STATUS_PATH)){
29
+ $this->setFlag('', self::FLAG_NO_DISPATCH, true);
30
+ }
31
+
32
+ $username = Mage::getStoreConfig(self::XML_AUTH_USERNAME_PATH);
33
+ $password = Mage::getStoreConfig(self::XML_AUTH_PASSWORD_PATH);
34
+
35
+ // Authentication
36
+ if(!empty($username)
37
+ && !empty($password)
38
+ && ($this->getRequest()->getServer('PHP_AUTH_USER') != $username
39
+ or $this->getRequest()->getServer('PHP_AUTH_PW') != $password)){
40
+
41
+ $this->getResponse()->setHeader('status', 'Unauthorized', true);
42
+ $this->getResponse()->setHeader('WWW-authenticate', 'basic realm="epoq Interface"', true);
43
+ $this->getResponse()->sendHeaders();
44
+ $this->setFlag('', self::FLAG_NO_DISPATCH, true);
45
+ }
46
+
47
+ return parent::preDispatch();
48
+ }
49
+
50
+ public function indexAction(){
51
+
52
+ $this->_forward('productlist');
53
+ }
54
+
55
+
56
+ public function productlistAction(){
57
+ $this->getResponse()->setHeader('Content-type', 'text/plain; charset=UTF-8');
58
+ //$this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8');
59
+ $this->loadLayout(false);
60
+ $this->renderLayout();
61
+ }
62
+
63
+
64
+ /**
65
+ * The main function for converting to an XML document.
66
+ * Pass in a multi dimensional array and this recrusively loops through and builds up an XML document.
67
+ *
68
+ * @param array $data
69
+ * @param string $rootNodeName - what you want the root node to be - defaultsto data.
70
+ * @param DomElement $elem - should only be used recursively
71
+ * @param DOMDocument $xml - should only be used recursively
72
+ * @return object DOMDocument
73
+ */
74
+ protected function dataToXml($data, $rootNodeName = 'data', $elem=null, $xml=null)
75
+ {
76
+
77
+ if ($xml === null)
78
+ {
79
+ $xml = new DOMDocument("1.0", "UTF-8");
80
+ $xml->formatOutput = true;
81
+ $elem = $xml->createElement( $rootNodeName );
82
+ $xml->appendChild( $elem );
83
+ }
84
+
85
+ // loop through the data passed in.
86
+ foreach($data as $key => $value)
87
+ {
88
+ // no numeric keys in our xml please!
89
+ if (is_numeric($key))
90
+ {
91
+ // make string key...
92
+ $key = "node_". (string) $key;
93
+ }
94
+
95
+ // replace anything not alpha numeric
96
+ $key = preg_replace('/[^a-z0-9\_]/i', '', $key);
97
+
98
+ // if there is another array found recrusively call this function
99
+ if (is_array($value))
100
+ {
101
+ $subelem = $xml->createElement( $key );
102
+ $elem->appendChild( $subelem);
103
+ // recrusive call.
104
+ $this->DataToXml($value, $rootNodeName, $subelem, $xml);
105
+ }
106
+ else
107
+ {
108
+ $subelem = $xml->createElement( $key );
109
+ $subelem->appendChild(
110
+ strstr($value, array('<','>'))
111
+ ? $xml->createCDATASection( $value )
112
+ : $xml->createTextNode( $value )
113
+ );
114
+ $elem->appendChild( $subelem );
115
+
116
+ }
117
+
118
+ }
119
+ // pass back as DOMDocument object
120
+ return $xml;
121
+ }
122
+
123
+ }
124
+
app/code/community/Flagbit/EpoqInterface/etc/config.xml ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /* *
4
+ * This script is part of the epoq Recommendation Service project *
5
+ * *
6
+ * epoqinterface is free software; you can redistribute it and/or modify *
7
+ * it under the terms of the GNU General Public License version 2 as *
8
+ * published by the Free Software Foundation. *
9
+ * *
10
+ * This script is distributed in the hope that it will be useful, but *
11
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
12
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
13
+ * Public License for more details. *
14
+ * *
15
+ * @version $Id: config.xml 7 2009-07-06 15:05:38Z weller $
16
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <Flagbit_EpoqInterface>
22
+ <active>true</active>
23
+ <version>0.1.0</version>
24
+ </Flagbit_EpoqInterface>
25
+ </modules>
26
+
27
+ <global>
28
+
29
+ <helpers>
30
+ <epoqinterface>
31
+ <class>Flagbit_EpoqInterface_Helper</class>
32
+ </epoqinterface>
33
+ </helpers>
34
+
35
+ <blocks>
36
+ <epoqinterface>
37
+ <class>Flagbit_EpoqInterface_Block</class>
38
+ </epoqinterface>
39
+ </blocks>
40
+ <models>
41
+ <epoqinterface>
42
+ <class>Flagbit_EpoqInterface_Model</class>
43
+ </epoqinterface>
44
+ </models>
45
+
46
+ <events>
47
+ <checkout_cart_product_add_after>
48
+ <observers>
49
+ <epoqinterface>
50
+ <type>singleton</type>
51
+ <class>epoqinterface/observer</class>
52
+ <method>checkoutCartProductAddAfter</method>
53
+ </epoqinterface>
54
+ </observers>
55
+ </checkout_cart_product_add_after>
56
+ <checkout_cart_update_items_after>
57
+ <observers>
58
+ <epoqinterface>
59
+ <type>singleton</type>
60
+ <class>epoqinterface/observer</class>
61
+ <method>checkoutCartUpdateItemsAfter</method>
62
+ </epoqinterface>
63
+ </observers>
64
+ </checkout_cart_update_items_after>
65
+ <controller_action_predispatch_checkout_cart_delete>
66
+ <observers>
67
+ <epoqinterface>
68
+ <type>singleton</type>
69
+ <class>epoqinterface/observer</class>
70
+ <method>controllerActionPredispatchCheckoutCartDelete</method>
71
+ </epoqinterface>
72
+ </observers>
73
+ </controller_action_predispatch_checkout_cart_delete>
74
+ <sales_order_save_before>
75
+ <observers>
76
+ <epoqinterface>
77
+ <type>singleton</type>
78
+ <class>epoqinterface/observer</class>
79
+ <method>salesOrderPlaceBefore</method>
80
+ </epoqinterface>
81
+ </observers>
82
+ </sales_order_save_before>
83
+ <sales_order_save_after>
84
+ <observers>
85
+ <epoqinterface>
86
+ <type>singleton</type>
87
+ <class>epoqinterface/observer</class>
88
+ <method>salesOrderPlaceAfter</method>
89
+ </epoqinterface>
90
+ </observers>
91
+ </sales_order_save_after>
92
+ </events>
93
+
94
+
95
+ </global>
96
+
97
+ <frontend>
98
+ <layout>
99
+ <updates>
100
+ <epoqinterface>
101
+ <file>epoqinterface.xml</file>
102
+ </epoqinterface>
103
+ </updates>
104
+ </layout>
105
+
106
+
107
+ <routers>
108
+ <epoqinterface>
109
+ <use>standard</use>
110
+ <args>
111
+ <module>Flagbit_EpoqInterface</module>
112
+ <frontName>epoqinterface</frontName>
113
+ </args>
114
+ </epoqinterface>
115
+ </routers>
116
+ </frontend>
117
+
118
+ <adminhtml>
119
+ <acl>
120
+ <resources>
121
+ <admin>
122
+ <children>
123
+ <system>
124
+ <children>
125
+ <config>
126
+ <children>
127
+ <epoqinterface>
128
+ <title>epoq Recommendation Service</title>
129
+ </epoqinterface>
130
+ </children>
131
+ </config>
132
+ </children>
133
+ </system>
134
+ </children>
135
+ </admin>
136
+ </resources>
137
+ </acl>
138
+ <translate>
139
+ <modules>
140
+ <Flagbit_EpoqInterface>
141
+ <files>
142
+ <default>Flagbit_EpoqInterface.csv</default>
143
+ </files>
144
+ </Flagbit_EpoqInterface>
145
+ </modules>
146
+ </translate>
147
+ </adminhtml>
148
+
149
+ <default>
150
+ <epoqinterface>
151
+ <config>
152
+ <timeout>2</timeout>
153
+ <demo>0</demo>
154
+ <customer_profiles>0</customer_profiles>
155
+ </config>
156
+ <display_recommendation>
157
+ <user>1</user>
158
+ <cart>1</cart>
159
+ <product>1</product>
160
+ </display_recommendation>
161
+ <export>
162
+ <username>epoq</username>
163
+ </export>
164
+ <error_handling>
165
+ <enabled>0</enabled>
166
+ <max_attempts>3</max_attempts>
167
+ <idle_time>10</idle_time>
168
+ </error_handling>
169
+ </epoqinterface>
170
+ <system>
171
+ <epoqinterface>
172
+ <rest_url>http://rs1.epoq.de/inbound-servletapi/</rest_url>
173
+ <rest_failure_counter>0</rest_failure_counter>
174
+ </epoqinterface>
175
+ </system>
176
+ </default>
177
+
178
+
179
+ </config>
app/code/community/Flagbit/EpoqInterface/etc/system.xml ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /* *
4
+ * This script is part of the epoq Recommendation Service project *
5
+ * *
6
+ * epoqinterface is free software; you can redistribute it and/or modify *
7
+ * it under the terms of the GNU General Public License version 2 as *
8
+ * published by the Free Software Foundation. *
9
+ * *
10
+ * This script is distributed in the hope that it will be useful, but *
11
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
12
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
13
+ * Public License for more details. *
14
+ * *
15
+ * @version $Id: system.xml 7 2009-07-06 15:05:38Z weller $
16
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
17
+ */
18
+ -->
19
+ <config>
20
+ <sections>
21
+ <epoqinterface translate="label" module="epoqinterface">
22
+ <label>epoq Recommendation Service</label>
23
+ <tab>service</tab>
24
+ <frontend_type>text</frontend_type>
25
+ <sort_order>101</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>General 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
+ <version translate="label">
39
+ <label>Version</label>
40
+ <frontend_model>epoqinterface/system_config_form_field_version</frontend_model>
41
+ <sort_order>5</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ </version>
46
+ <tenant_id translate="label">
47
+ <label>Tenant ID</label>
48
+ <frontend_type>text</frontend_type>
49
+ <sort_order>10</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ </tenant_id>
54
+ <timeout translate="label">
55
+ <label>Timeout</label>
56
+ <frontend_type>select</frontend_type>
57
+ <source_model>epoqinterface/system_config_source_timeout</source_model>
58
+ <sort_order>20</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </timeout>
63
+ <demo translate="label">
64
+ <label>Demo mode</label>
65
+ <frontend_type>select</frontend_type>
66
+ <source_model>adminhtml/system_config_source_yesno</source_model>
67
+ <sort_order>30</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ </demo>
72
+ <customer_profiles translate="label">
73
+ <label>send Customer Profiles</label>
74
+ <frontend_type>select</frontend_type>
75
+ <source_model>adminhtml/system_config_source_yesno</source_model>
76
+ <sort_order>40</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>1</show_in_store>
80
+ </customer_profiles>
81
+ </fields>
82
+ </config>
83
+ <display_recommendation translate="label">
84
+ <label>Display Recommendations</label>
85
+ <frontend_type>text</frontend_type>
86
+ <sort_order>20</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>1</show_in_store>
90
+ <fields>
91
+ <cart translate="label">
92
+ <label>Cart</label>
93
+ <frontend_type>select</frontend_type>
94
+ <source_model>adminhtml/system_config_source_yesno</source_model>
95
+ <sort_order>10</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>1</show_in_website>
98
+ <show_in_store>1</show_in_store>
99
+ </cart>
100
+ <product translate="label">
101
+ <label>Productview</label>
102
+ <frontend_type>select</frontend_type>
103
+ <source_model>adminhtml/system_config_source_yesno</source_model>
104
+ <sort_order>20</sort_order>
105
+ <show_in_default>1</show_in_default>
106
+ <show_in_website>1</show_in_website>
107
+ <show_in_store>1</show_in_store>
108
+ </product>
109
+ <user translate="label">
110
+ <label>My Account</label>
111
+ <frontend_type>select</frontend_type>
112
+ <source_model>adminhtml/system_config_source_yesno</source_model>
113
+ <sort_order>30</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>1</show_in_website>
116
+ <show_in_store>1</show_in_store>
117
+ </user>
118
+
119
+ </fields>
120
+ </display_recommendation>
121
+ <export translate="label">
122
+ <label>Export Settings</label>
123
+ <frontend_type>text</frontend_type>
124
+ <sort_order>30</sort_order>
125
+ <show_in_default>1</show_in_default>
126
+ <show_in_website>1</show_in_website>
127
+ <show_in_store>1</show_in_store>
128
+ <fields>
129
+ <enabled translate="label">
130
+ <label>enabled</label>
131
+ <frontend_type>select</frontend_type>
132
+ <source_model>adminhtml/system_config_source_yesno</source_model>
133
+ <sort_order>10</sort_order>
134
+ <show_in_default>1</show_in_default>
135
+ <show_in_website>1</show_in_website>
136
+ <show_in_store>1</show_in_store>
137
+ </enabled>
138
+ <!--
139
+ <username translate="label">
140
+ <label>Username</label>
141
+ <frontend_type>text</frontend_type>
142
+ <sort_order>20</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>1</show_in_website>
145
+ <show_in_store>1</show_in_store>
146
+ </username>
147
+ -->
148
+ <password translate="label">
149
+ <label>Password</label>
150
+ <frontend_type>text</frontend_type>
151
+ <sort_order>30</sort_order>
152
+ <show_in_default>1</show_in_default>
153
+ <show_in_website>1</show_in_website>
154
+ <show_in_store>1</show_in_store>
155
+ </password>
156
+ </fields>
157
+ </export>
158
+ <error_handling translate="label">
159
+ <label>Error Handling</label>
160
+ <frontend_type>text</frontend_type>
161
+ <sort_order>30</sort_order>
162
+ <show_in_default>1</show_in_default>
163
+ <show_in_website>1</show_in_website>
164
+ <show_in_store>1</show_in_store>
165
+ <fields>
166
+ <enabled translate="label">
167
+ <label>enabled</label>
168
+ <frontend_type>select</frontend_type>
169
+ <source_model>adminhtml/system_config_source_yesno</source_model>
170
+ <sort_order>10</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
+ </enabled>
175
+
176
+ <max_attempts translate="label">
177
+ <label>max Attemps</label>
178
+ <frontend_type>select</frontend_type>
179
+ <source_model>epoqinterface/system_config_source_attemps</source_model>
180
+ <sort_order>20</sort_order>
181
+ <show_in_default>1</show_in_default>
182
+ <show_in_website>1</show_in_website>
183
+ <show_in_store>1</show_in_store>
184
+ </max_attempts>
185
+
186
+ <idle_time translate="label">
187
+ <label>Idle time</label>
188
+ <frontend_type>select</frontend_type>
189
+ <source_model>epoqinterface/system_config_source_idletime</source_model>
190
+ <sort_order>30</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
+ </idle_time>
195
+ </fields>
196
+ </error_handling>
197
+ </groups>
198
+ </epoqinterface>
199
+ </sections>
200
+ </config>
app/design/frontend/default/default/layout/epoqinterface.xml ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /* *
4
+ * This script is part of the epoq Recommendation Service project *
5
+ * *
6
+ * TypoGento is free software; you can redistribute it and/or modify it *
7
+ * under the terms of the GNU General Public License version 2 as *
8
+ * published by the Free Software Foundation. *
9
+ * *
10
+ * This script is distributed in the hope that it will be useful, but *
11
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
12
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
13
+ * Public License for more details. *
14
+ * *
15
+ * @version $Id: epoqinterface.xml 4 2009-06-30 12:42:11Z weller $
16
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
17
+ */
18
+ -->
19
+ <layout version="0.1.0">
20
+
21
+ <default>
22
+ <reference name="head">
23
+ <block type="epoqinterface/head" name="epoqinterface_head" output="toHtml"/>
24
+ </reference>
25
+ </default>
26
+
27
+ <catalog_product_view>
28
+ <reference name="content">
29
+ <block type="epoqinterface/track_product" name="epoqinterface.track.product"/>
30
+ <reference name="product.info.additional">
31
+ <block type="epoqinterface/recommentation_product" name="epoqinterface.recommendation.product" template="epoqinterface/recommendation/product.phtml"/>
32
+ </reference>
33
+ </reference>
34
+ </catalog_product_view>
35
+
36
+ <checkout_cart_index>
37
+ <reference name="content">
38
+ <block type="epoqinterface/track_cart" name="epoqinterface.track.cart"/>
39
+ <reference name="checkout.cart">
40
+ <block type="epoqinterface/recommentation_cart" name="epoqinterface.recommendation.cart" template="epoqinterface/recommendation/cart.phtml"/>
41
+ </reference>
42
+ </reference>
43
+ </checkout_cart_index>
44
+
45
+ <checkout_multishipping_success>
46
+ <reference name="content">
47
+ <block type="epoqinterface/track_cart" name="epoqinterface.track.cart"/>
48
+ </reference>
49
+ </checkout_multishipping_success>
50
+
51
+ <checkout_onepage_success>
52
+ <reference name="content">
53
+ <block type="epoqinterface/track_cart" name="epoqinterface.track.cart"/>
54
+ </reference>
55
+ </checkout_onepage_success>
56
+
57
+ <customer_account_index>
58
+ <reference name="customer_account_dashboard">
59
+ <block type="epoqinterface/recommentation_user" name="epoqinterface.recommendation.user" as="info1" template="epoqinterface/recommendation/user.phtml"/>
60
+ </reference>
61
+ </customer_account_index>
62
+
63
+ <epoqinterface_index_productlist>
64
+ <block type="epoqinterface/export_productlist" output="toHtml" name="epoqinterface.productlist"/>
65
+ </epoqinterface_index_productlist>
66
+ </layout>
app/design/frontend/default/default/template/epoqinterface/recommendation/cart.phtml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * TypoGento is free software; you can redistribute it and/or modify it *
6
+ * under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: cart.phtml 4 2009-06-30 12:42:11Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+ ?>
18
+
19
+ <?php if(count($this->getItemCollection()->getItems())): ?>
20
+ <div class="collateral-box up-sell">
21
+ <div class="head"><h4><?php echo $this->__('epoq: You may also be interested in the following product(s)') ?></h4></div>
22
+ <table cellspacing="0" class="generic-product-grid catalog-listing" id="upsell-product-table">
23
+ <?php // $this->setColumnCount(4); // uncomment this line if you want to have another number of columns. also can be changed in layout ?>
24
+ <?php $this->resetItemsIterator() ?>
25
+ <?php for($_i=0;$_i<$this->getRowCount();$_i++): ?>
26
+ <tr>
27
+ <?php for($_j=0;$_j<$this->getColumnCount();$_j++): ?>
28
+ <?php if($_link=$this->getIterableItem()): ?>
29
+ <td>
30
+ <p class="product-image"><a href="<?php echo $_link->getProductUrl() ?>"><img src="<?php echo $this->helper('catalog/image')->init($_link, 'small_image')->resize(125) ?>" width="125" height="125" alt="<?php echo $this->htmlEscape($_link->getName()) ?>" /></a></p>
31
+ <h5><a href="<?php echo $_link->getProductUrl() ?>"><?php echo $this->htmlEscape($_link->getName()) ?></a></h5>
32
+ <?php echo $this->getPriceHtml($_link, true) ?>
33
+ <?php echo $this->getReviewsSummaryHtml($_link) ?>
34
+ </td>
35
+ <?php else: ?>
36
+ <td class="empty-product">&nbsp;</td>
37
+ <?php endif; ?>
38
+ <?php endfor; ?>
39
+ </tr>
40
+ <?php endfor; ?>
41
+ </table>
42
+ <script type="text/javascript">decorateTable('upsell-product-table')</script>
43
+ </div>
44
+ <?php endif ?>
app/design/frontend/default/default/template/epoqinterface/recommendation/product.phtml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * TypoGento is free software; you can redistribute it and/or modify it *
6
+ * under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: product.phtml 4 2009-06-30 12:42:11Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+ ?>
18
+
19
+ <?php if(count($this->getItemCollection()->getItems())): ?>
20
+ <div class="collateral-box up-sell">
21
+ <div class="head"><h4><?php echo $this->__('epoq: You may also be interested in the following product(s)') ?></h4></div>
22
+ <table cellspacing="0" class="generic-product-grid catalog-listing" id="upsell-product-table">
23
+ <?php // $this->setColumnCount(4); // uncomment this line if you want to have another number of columns. also can be changed in layout ?>
24
+ <?php $this->resetItemsIterator() ?>
25
+ <?php for($_i=0;$_i<$this->getRowCount();$_i++): ?>
26
+ <tr>
27
+ <?php for($_j=0;$_j<$this->getColumnCount();$_j++): ?>
28
+ <?php if($_link=$this->getIterableItem()): ?>
29
+ <td>
30
+ <p class="product-image"><a href="<?php echo $_link->getProductUrl() ?>"><img src="<?php echo $this->helper('catalog/image')->init($_link, 'small_image')->resize(125) ?>" width="125" height="125" alt="<?php echo $this->htmlEscape($_link->getName()) ?>" /></a></p>
31
+ <h5><a href="<?php echo $_link->getProductUrl() ?>"><?php echo $this->htmlEscape($_link->getName()) ?></a></h5>
32
+ <?php echo $this->getPriceHtml($_link, true) ?>
33
+ <?php echo $this->getReviewsSummaryHtml($_link) ?>
34
+ </td>
35
+ <?php else: ?>
36
+ <td class="empty-product">&nbsp;</td>
37
+ <?php endif; ?>
38
+ <?php endfor; ?>
39
+ </tr>
40
+ <?php endfor; ?>
41
+ </table>
42
+ <script type="text/javascript">decorateTable('upsell-product-table')</script>
43
+ </div>
44
+ <?php endif ?>
app/design/frontend/default/default/template/epoqinterface/recommendation/user.phtml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* *
3
+ * This script is part of the epoq Recommendation Service project *
4
+ * *
5
+ * TypoGento is free software; you can redistribute it and/or modify it *
6
+ * under the terms of the GNU General Public License version 2 as *
7
+ * published by the Free Software Foundation. *
8
+ * *
9
+ * This script is distributed in the hope that it will be useful, but *
10
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
11
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
12
+ * Public License for more details. *
13
+ * *
14
+ * @version $Id: user.phtml 4 2009-06-30 12:42:11Z weller $
15
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
16
+ */
17
+ ?>
18
+
19
+ <?php if(count($this->getItemCollection()->getItems())): ?>
20
+
21
+ <div class="account-box up-sell">
22
+ <div class="head"><h4><?php echo $this->__('epoq: You may also be interested in the following product(s)') ?></h4></div>
23
+ <table cellspacing="0" class="generic-product-grid catalog-listing" id="upsell-product-table">
24
+ <?php // $this->setColumnCount(4); // uncomment this line if you want to have another number of columns. also can be changed in layout ?>
25
+ <?php $this->resetItemsIterator() ?>
26
+ <?php for($_i=0;$_i<$this->getRowCount();$_i++): ?>
27
+ <tr>
28
+ <?php for($_j=0;$_j<$this->getColumnCount();$_j++): ?>
29
+ <?php if($_link=$this->getIterableItem()): ?>
30
+ <td>
31
+ <p class="product-image"><a href="<?php echo $_link->getProductUrl() ?>"><img src="<?php echo $this->helper('catalog/image')->init($_link, 'small_image')->resize(125) ?>" width="125" height="125" alt="<?php echo $this->htmlEscape($_link->getName()) ?>" /></a></p>
32
+ <h5><a href="<?php echo $_link->getProductUrl() ?>"><?php echo $this->htmlEscape($_link->getName()) ?></a></h5>
33
+ <?php echo $this->getPriceHtml($_link, true) ?>
34
+ <?php echo $this->getReviewsSummaryHtml($_link) ?>
35
+ </td>
36
+ <?php else: ?>
37
+ <td class="empty-product">&nbsp;</td>
38
+ <?php endif; ?>
39
+ <?php endfor; ?>
40
+ </tr>
41
+ <?php endfor; ?>
42
+ </table>
43
+ <script type="text/javascript">decorateTable('upsell-product-table')</script>
44
+ </div>
45
+ <?php endif ?>
app/etc/modules/Flagbit_EpoqInterface.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /* *
4
+ * This script is part of the epoq Recommendation Service project *
5
+ * *
6
+ * TypoGento is free software; you can redistribute it and/or modify it *
7
+ * under the terms of the GNU General Public License version 2 as *
8
+ * published by the Free Software Foundation. *
9
+ * *
10
+ * This script is distributed in the hope that it will be useful, but *
11
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
12
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
13
+ * Public License for more details. *
14
+ * *
15
+ * @version $Id: Flagbit_EpoqInterface.xml 4 2009-06-30 12:42:11Z weller $
16
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <Flagbit_EpoqInterface>
22
+ <active>true</active>
23
+ <codePool>community</codePool>
24
+ </Flagbit_EpoqInterface>
25
+ </modules>
26
+ </config>
app/locale/de_DE/Flagbit_EpoqInterface.csv ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "epoq Recommendation Service", "epoq Vorschlag-Service"
2
+ "General Settings", "Allgemeine Einstellungen"
3
+ "Timeout", "Zeitüberschreitung"
4
+ "new Version %s ready for Download", "neue Version %s fertig zum Download"
5
+ "Demo mode", "Demo Modus"
6
+ "send Customer Profiles", "Kundeninformationen senden"
7
+ "%d Second", "%d Sekunde"
8
+ "%d Seconds", "%d Sekunden"
9
+ "Display Recommendations", "Empfehlungen anzeigen"
10
+ "Cart", "Warenkorb"
11
+ "Productview", "Artikelansicht"
12
+ "My Account", "Mein Konto"
13
+ "Error Handling", "Fehlerbehandlung"
14
+ "enabled", "aktiviert"
15
+ "max Attemps", "max. Versuche",
16
+ "Idle time", "Wartezeit"
17
+ "%d Minutes", "%d Minuten",
18
+ "%d Hour", "%d Stunde",
19
+ "%d Hours", "%d Stunden",
20
+ "Export Settings", "Export Einstellungen"
21
+ "Password", "Passwort"
22
+ "up to date", "aktuell"
package.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>epoqRS</name>
4
+ <version>0.9.9</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/gpl-license.php">GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Integrates the epoq Recommendation Service for improved product consulting and cross selling functionality.</summary>
10
+ <description>epoq RS offers an intelligent, self-learning recommendation system for web shops that increase sales by up to 15% through efficient management of cross selling, increase of conversion rates and increased customer satisfaction.
11
+
12
+ The quick and easy integration of epoq RS makes your Magento sell more within a few hours. You do not have to submit and update your product data and there is no need to connect to any internal systems - all available information - click stream, product data, cart information - are automatically processed for maximum quality recommendations.
13
+
14
+ Try epoq Recommendation System - free and without obligation in our 30-day trial version.</description>
15
+ <notes>First stable release.
16
+ Will be updated to Version 1.0.0 as soon as documentation is available.</notes>
17
+ <authors><author><name>Flagbit Magento Team</name><user>auto-converted</user><email>magento@flagbit.de</email></author><author><name>Michael T&#xFC;rk</name><user>auto-converted</user><email>tuerk@flagbit.de</email></author></authors>
18
+ <date>2009-08-06</date>
19
+ <time>11:14:56</time>
20
+ <contents><target name="magelocale"><dir name="de_DE"><file name="Flagbit_EpoqInterface.csv" hash="22bc5867c4cc76d3ee9fbb7d5ebc727a"/></dir></target><target name="magecommunity"><dir name="Flagbit"><dir name="EpoqInterface"><dir name="Block"><dir name="Export"><file name="Productlist.php" hash="eadd65e6ad0fa30df0bb4f8ab82a02d6"/></dir><dir name="Recommentation"><file name="Abstract.php" hash="a65dc52fdb9a122c58f43827282eb1e9"/><file name="Cart.php" hash="4b1acb11387aed4f14e318ec591b67be"/><file name="Product.php" hash="4e11b20c12390a48dd3a86e39ff09a31"/><file name="User.php" hash="6f09f23065a812f9e36ef8e624366fc4"/></dir><dir name="System"><dir name="Config"><dir name="Form"><dir name="Field"><file name="Version.php" hash="7a4da0c6e4723b7f684090119d0a2b02"/></dir></dir></dir></dir><dir name="Track"><file name="Cart.php" hash="90dc5c18041bcab48c66e3501f87f345"/><file name="Product.php" hash="13a5d69b45b0eec3daad0da1ddbd4742"/></dir><file name="Abstract.php" hash="5554ffc9fadf84c5c47820c91f33ab2c"/><file name="Head.php" hash="6515db5c64186c3a085797afde496dcd"/></dir><dir name="controllers"><file name="IndexController.php" hash="e450b4f05ad4a78474c5ba15b1199c9b"/></dir><dir name="etc"><file name="config.xml" hash="f83c9004d8708439b9cb977be9734b39"/><file name="system.xml" hash="448a0987d8d0ee634d593b8edd0114fc"/></dir><dir name="Helper"><file name="Data.php" hash="bb5b622529165daf1f0a3fb6f8b40caa"/></dir><dir name="Model"><dir name="Customer"><file name="Profiles.php" hash="fbedb6a3259a29db05b2c8783d02957b"/></dir><dir name="Recommendation"><file name="Abstract.php" hash="99534518963856d6dac30794094e053e"/><file name="Cart.php" hash="933c323892f5ab338d928188cb6e2641"/><file name="Product.php" hash="e8d9c9c76b4b718d332cb13760603f50"/><file name="User.php" hash="0c1c4f5c215304db6e2054dd1434f3da"/></dir><dir name="System"><dir name="Config"><dir name="Source"><file name="Attemps.php" hash="c01ebd5c76fd4d51305ed7111326d57d"/><file name="Idletime.php" hash="957ec9d0c4af2d52add60a9765c4e573"/><file name="Timeout.php" hash="95c38625ad50dc44ba2b2d371de1db65"/></dir></dir></dir><file name="Abstract.php" hash="b6338b4c898a1e1333eae681303410a8"/><file name="Observer.php" hash="74ed501de640fdbba70cbb04d748eac1"/><file name="Session.php" hash="6edb0cdfa45dc7b1714ae6352b77c306"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="epoqinterface.xml" hash="075cadf2db9b4d32cc0a23f30c025b8b"/></dir><dir name="template"><dir name="epoqinterface"><dir name="recommendation"><file name="cart.phtml" hash="3cc622495dbfe78e6d6f9e0a49830ffb"/><file name="product.phtml" hash="28b367b4500f5d5ae86cf4e6001c62c6"/><file name="user.phtml" hash="bfd6a6c778f13306fdcfb7a24aa8b46d"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Flagbit_EpoqInterface.xml" hash="5137430772e95ad995c3733e09b4909f"/></dir></target></contents>
21
+ <compatible/>
22
+ <dependencies/>
23
+ </package>