unbxd_feedconnector - Version 1.0.0

Version Notes

pushes the data to unbxd server

Download this release

Release Info

Developer ananthesh
Extension unbxd_feedconnector
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (28) hide show
  1. app/code/local/Unbxdsearch/Datafeeder/.DS_Store +0 -0
  2. app/code/local/Unbxdsearch/Datafeeder/Block/Edit.php +12 -0
  3. app/code/local/Unbxdsearch/Datafeeder/Block/Index.php +76 -0
  4. app/code/local/Unbxdsearch/Datafeeder/Helper/.DS_Store +0 -0
  5. app/code/local/Unbxdsearch/Datafeeder/Helper/Data.php +14 -0
  6. app/code/local/Unbxdsearch/Datafeeder/Helper/UnbxdIndexingHelper.php +676 -0
  7. app/code/local/Unbxdsearch/Datafeeder/Helper/UnbxdTaxonomyHelper.php +318 -0
  8. app/code/local/Unbxdsearch/Datafeeder/Model/Attribute.php +22 -0
  9. app/code/local/Unbxdsearch/Datafeeder/Model/Conf.php +12 -0
  10. app/code/local/Unbxdsearch/Datafeeder/Model/Facet.php +14 -0
  11. app/code/local/Unbxdsearch/Datafeeder/Model/Field.php +11 -0
  12. app/code/local/Unbxdsearch/Datafeeder/Model/Mysql4/Attribute.php +22 -0
  13. app/code/local/Unbxdsearch/Datafeeder/Model/Mysql4/Conf.php +44 -0
  14. app/code/local/Unbxdsearch/Datafeeder/Model/Mysql4/Conf/Collection.php +16 -0
  15. app/code/local/Unbxdsearch/Datafeeder/Model/Mysql4/Field.php +94 -0
  16. app/code/local/Unbxdsearch/Datafeeder/Model/Mysql4/Field/Collection.php +16 -0
  17. app/code/local/Unbxdsearch/Datafeeder/Model/Mysql4/Resource/Attribute.php +22 -0
  18. app/code/local/Unbxdsearch/Datafeeder/controllers/ConfigController.php +67 -0
  19. app/code/local/Unbxdsearch/Datafeeder/controllers/FieldController.php +31 -0
  20. app/code/local/Unbxdsearch/Datafeeder/controllers/IndexController.php +60 -0
  21. app/code/local/Unbxdsearch/Datafeeder/etc/adminhtml.xml +16 -0
  22. app/code/local/Unbxdsearch/Datafeeder/etc/config.xml +119 -0
  23. app/code/local/Unbxdsearch/Datafeeder/scripts/Cron.php +25 -0
  24. app/code/local/Unbxdsearch/Datafeeder/scripts/abstract.php +218 -0
  25. app/code/local/Unbxdsearch/Datafeeder/sql/datafeeder_setup/mysql4-install-0.1.0.php +36 -0
  26. app/design/adminhtml/base/default/template/datafeeder/conf.phtml +252 -0
  27. package.xml +18 -0
  28. shell/UnbxdFeed.php +25 -0
app/code/local/Unbxdsearch/Datafeeder/.DS_Store ADDED
Binary file
app/code/local/Unbxdsearch/Datafeeder/Block/Edit.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Unbxdsearch_Datafeeder_Block_Edit extends Mage_Core_Block_Template
5
+ {
6
+
7
+ public function getCollection()
8
+ {
9
+ return Mage::getModel('datafeeder/field')->getCollection();
10
+ }
11
+ }
12
+ ?>
app/code/local/Unbxdsearch/Datafeeder/Block/Index.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Unbxdsearch_Datafeeder_Block_Index extends Mage_Adminhtml_Block_Template
5
+ {
6
+ public function getFullindexFormAction()
7
+ {
8
+
9
+ return Mage::getUrl('*/*/fullindex', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()));
10
+ }
11
+
12
+ public function getTaxonomyUploadFormAction(){
13
+ return Mage::getUrl('*/*/taxonomyindex', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()));
14
+ }
15
+
16
+ public function getSaveApiUrl(){
17
+ return Mage::getUrl('*/*/saveapi', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()));
18
+ }
19
+
20
+ public function getSaveFieldUrl()
21
+ {
22
+ return Mage::getUrl('*/field/save', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()));
23
+ }
24
+
25
+ public function saveFeedConf(){
26
+ return Mage::getUrl('*/*/savefeedconf', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()));
27
+ }
28
+
29
+ public function checkApiKeyExists()
30
+ {
31
+ if(Mage::getResourceSingleton("datafeeder/conf")->getValue("apiKey")=="empty"){
32
+ return false;
33
+ }
34
+ else{
35
+ return true;
36
+ }
37
+ }
38
+
39
+ public function getApiKey(){
40
+ return Mage::getResourceSingleton("datafeeder/conf")->getValue("apiKey");
41
+ }
42
+
43
+ public function getFields($site)
44
+ {
45
+
46
+ return Mage::getResourceSingleton('datafeeder/field')->getFields($site);
47
+ }
48
+
49
+ public function getIncrementalIndexFormAction()
50
+ {
51
+ return Mage::getUrl('*/*/incrementalindex', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()));
52
+ }
53
+
54
+ public function getProgressUrl()
55
+ {
56
+
57
+ return Mage::getUrl('datafeeder/config/progress', array('_secure' =>Mage::app()->getFrontController()->getRequest()->isSecure()));
58
+ }
59
+
60
+ public function getFeedConf()
61
+ {
62
+
63
+ return Mage::getUrl('datafeeder/config/getfeedconf', array('_secure' =>Mage::app()->getFrontController()->getRequest()->isSecure()));
64
+ }
65
+
66
+ public function getResetAction(){
67
+ return Mage::getUrl('datafeeder/config/reset', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()));
68
+ }
69
+
70
+ public function getEditUrl()
71
+ {
72
+ return Mage::getUrl('*/field/config', array('_secure' => Mage::app()->getFrontController()->getRequest()->isSecure()));
73
+ }
74
+ }
75
+
76
+ ?>
app/code/local/Unbxdsearch/Datafeeder/Helper/.DS_Store ADDED
Binary file
app/code/local/Unbxdsearch/Datafeeder/Helper/Data.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Unbxdsearch_Datafeeder_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ public function getsetaddressparams()
7
+ {
8
+ $params=$this->_getRequest()->getParams();
9
+ return $params;
10
+ }
11
+
12
+
13
+
14
+ }
app/code/local/Unbxdsearch/Datafeeder/Helper/UnbxdIndexingHelper.php ADDED
@@ -0,0 +1,676 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Created on 14-May-2013
4
+ *
5
+ * @author antz(ananthesh@unbxd.com)
6
+ */
7
+
8
+ class Unbxdsearch_Datafeeder_Helper_UnbxdIndexingHelper {
9
+ // This is like to act as a temporary cache, which holds the fieldName to fieldType information
10
+ // so that just to avoid multiple database reads, and make it faster
11
+ var $fieldType = array();
12
+ // This is the name of the logFile which it is writing in to//
13
+ var $logFile;
14
+ // This is also act like a temporary cache, which holds the category id to category information,
15
+ // so that just to avoid multiple database reads, and make it faster
16
+ var $categoryMap = array();
17
+ // size to fetch how much products should it pick in batches
18
+ var $PAGE_SIZE = 500;
19
+ // the file to write to..
20
+ var $file;
21
+ // fields to be selected to push to unbxd
22
+ var $fields;
23
+ // Feed unlock interval
24
+ //LOCK_TIMEOUT = 60 * 30;
25
+
26
+ public function __construct(){
27
+ $this->logFile = Mage::getBaseDir('log').DS.'generic.log';
28
+ $this->file = Mage::getBaseDir('tmp').DS.'unbxdFeed.xml';
29
+ $this-log("calling setfeilds method");
30
+ $this->fields = [];
31
+ }
32
+
33
+ public function setFields($site) {
34
+ $this->fields = Mage::getResourceSingleton('datafeeder/field')->getEnabledFields($site);
35
+ $this-log("inside setfeilds method");
36
+ $this->fields[] = 'entity_id';
37
+ $this->log("fields are " .json_encode($this->fields));
38
+ }
39
+
40
+ /**
41
+ * Function to create a file
42
+ */
43
+ private function createXmlFile(){
44
+ try{
45
+ $f=fopen($this->file,'w');
46
+
47
+ fclose($f);
48
+ if(!file_exists($this->file)) {
49
+ $this->log("UNBXD_MODULE:Couldn't create the file");
50
+ return false;
51
+ }
52
+ $this->log("UNBXD_MODULE: created the file");
53
+ return true;
54
+ } catch (Exception $ex) {
55
+ $this->log("UNBXD_MODULE:Error while creating the file");
56
+ $this->log($ex->getMessage());
57
+ return false;
58
+ }
59
+ }
60
+
61
+ /**
62
+ * Function to append the contents to the file
63
+ */
64
+ private function appendTofile($content){
65
+ try{
66
+
67
+ if(file_put_contents($this->file, $content, FILE_APPEND)) {
68
+ return true;
69
+ } else {
70
+ return false;
71
+ }
72
+ } catch(Exception $ex) {
73
+ $this->log("UNBXD_MODULE:Error while appending the contents to feed file");
74
+ $this->log($ex->getMessage());
75
+ return false;
76
+ }
77
+ }
78
+
79
+
80
+ /**
81
+ * Function to create a file
82
+ */
83
+ private function createLogFile(){
84
+ try {
85
+ $f=fopen($this->logFile,'w');
86
+ fclose($f);
87
+ return true;
88
+ } catch (Exception $ex) {
89
+ error_log("UNBXD_MODULE:Error while creating the file");
90
+ error_log($ex->getMessage());
91
+ return false;
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Function to appened the contents to the file
97
+ */
98
+ public function log($content){
99
+ try{
100
+ $resp = file_put_contents($this->logFile, date('Y-m-d H:i:s').$content."\n", FILE_APPEND);
101
+ if($resp){
102
+ return true;
103
+ } else {
104
+ error_log("UNBXD_MODULE:Error while appending the contents to log file");
105
+ return false;
106
+ }
107
+ return true;
108
+ }catch(Exception $ex) {
109
+ error_log("UNBXD_MODULE:Error while appending the contents to log file");
110
+ Mage::throwException($ex->getMessage());
111
+ return false;
112
+ }
113
+ }
114
+
115
+ /**
116
+ * Function to delete the file
117
+ */
118
+ private function deleteFile(){
119
+ unlink($this->file);
120
+ }
121
+
122
+ /**
123
+ * function to get the file name
124
+ */
125
+ private function getFile(){
126
+ return $this->file;
127
+ }
128
+
129
+ /**
130
+ * Write Header contents to the file
131
+ *
132
+ */
133
+ private function writeXmlHeaderContents($operation){
134
+ $headerContent="<feed>"."<taxonomyname>".$this->tax.
135
+ "</taxonomyname><username>unbxd</username>".
136
+ "<feedname>feed</feedname>".
137
+ "<entry>"."<data>" .
138
+ "<unbxdActionType>".$operation.
139
+ "</unbxdActionType>"."<products>";
140
+
141
+ return $this->appendTofile($headerContent);
142
+
143
+ }
144
+
145
+ /**
146
+ * function to append the xml footer contents to the file
147
+ *
148
+ */
149
+ private function writeXmlFooterContents(){
150
+ $footerContent="</products></data></entry></feed>";
151
+ return $this->appendTofile($footerContent);
152
+ }
153
+
154
+ /**
155
+ * function to append the product contents to the file
156
+ */
157
+ private function writeXmlProductContents($fromdate,$todate,$site,$operation,$ids){
158
+
159
+ $this-> setFieldType();
160
+ $collection=$this->getCatalogCollection($fromdate,$todate,$site,$operation,$ids);
161
+ // get total size
162
+ //set the time limit to infinite
163
+ set_time_limit(0);
164
+ $pageNum = 0;
165
+ $this->log('started writing products');
166
+
167
+ while(true){
168
+ $collection->clear();
169
+ $collection->getSelect()->limit($this->PAGE_SIZE, ($pageNum++) * $this->PAGE_SIZE);
170
+ $collection->load();
171
+ if(count($collection) == 0){
172
+ if($pageNum == 1){
173
+ $this->log("No products found");
174
+ return false;
175
+ }
176
+ break;
177
+ }
178
+ $content=$this->getCollectionInXML($collection, $operation);
179
+ $status=$this->appendTofile($content);
180
+ if(!$status){
181
+ return false;
182
+ }
183
+ $this->log('Added '.($pageNum) * $pageSize.' products');
184
+ }
185
+
186
+ $this->log('Added all products');
187
+ return true;
188
+ }
189
+
190
+ /**
191
+ ** This method iterates over the collection and builds the xml for product object
192
+ **
193
+ **/
194
+ private function getCollectionInXML($collection, $operation){
195
+
196
+ $content='';
197
+ $count=0;
198
+ foreach($collection as $product){
199
+ $count++;
200
+ $content=$content.'<product>';
201
+ $content=$content.$this->getProductInXML($product, $operation);
202
+ $content=$content.'</product>';
203
+ }
204
+
205
+ return $content;
206
+ }
207
+
208
+ /**
209
+ ** This method builds xml string, given the product object
210
+ **
211
+ **/
212
+ private function getProductInXML($product, $operation){
213
+ $content='';
214
+ if($operation != "add"){
215
+ return $this->getAttributesInXML('uniqueId',$product->getData('entity_id'));
216
+ }
217
+ $spsPrice = $product->getData('special_price');
218
+ $spsPrice = isset($spsPrice)? $spsPrice :0;
219
+ $content = $content.$this->getAttributesInXML('saving',(int)$product->getData('price') - (int)$spsPrice);
220
+
221
+ foreach($product->getData('') as $columnHeader=>$columndata){
222
+
223
+ if(!in_array($columnHeader, $this->fields)) {
224
+ continue;
225
+ }
226
+ if(is_null($columndata)|| !isset($columndata) || $columndata==""){
227
+ continue;
228
+ }
229
+ if($columnHeader=="entity_id"){
230
+ $content=$content. $this->getAttributesInXML('uniqueId',$columndata);
231
+ }
232
+ if($columnHeader=="name"){
233
+ $content=$content. $this->getAttributesInXML('productname',$columndata);
234
+ }
235
+ if($columnHeader=="small_image"){
236
+ $content=$content. $this->getAttributesInXML('image_url',$columndata);
237
+ }
238
+
239
+ if($columnHeader=="entity_id"){
240
+ $content=$content. $this->getAttributesInXML('uniqueId',$columndata);
241
+ }
242
+ if($columnHeader == "visibility") {
243
+ $content = $content.$this->getAttributesInXML('unbxdVisibility', $columndata);
244
+ }
245
+ if($columnHeader=="url_path"){
246
+ $content=$content. $this->getAttributesInXML('url', Mage::getUrl('').$columndata);
247
+ $content=$content. $this->getAttributesInXML('url_path', Mage::getUrl('').$columndata);
248
+ } else if( $this->isMultiSelect($columnHeader) && $columnHeader != "status"){
249
+ $data = explode(",", $columndata);
250
+ $attributeModel = Mage::getResourceSingleton("datafeeder/attribute");
251
+ foreach( $data as $eachdata){
252
+ $attributeValue = $attributeModel ->getAttributeValue($columnHeader, trim($eachdata), $product);
253
+ $value = $value .$this->getAttributesInXML($columnHeader,$attributeModel ->getAttributeValue($columnHeader, trim($eachdata), $product));
254
+ if(isset($this->filterable[$columnHeader]) && ($this->filterable[$columnHeader] == 1) && isset($attributeValue) && $attributeValue != ""){
255
+ $value = $value.$this->getAttributesInXML($columnHeader."_id", trim($eachdata));
256
+ }
257
+ }
258
+ } else if($columnHeader == "created_at" ||$columnHeader == "updated_at") {
259
+ $tokens = explode(" ",$columndata);
260
+ $columndata =$tokens[0].'T'.$tokens[1].'Z';
261
+ $value =$this->getAttributesInXML($columnHeader,$columndata);
262
+ } else if($columnHeader == "category_id"){
263
+ if(!isset($columndata)){
264
+ continue;
265
+ }
266
+ $categoryIds = explode(",",$columndata);
267
+ foreach($categoryIds as $categoryId){
268
+ $value = $value.$this->getAttributesInXML($columnHeader, trim($categoryId));
269
+ $value = $value.$this->getAttributesInXML("unbxdTaxonomyId",trim($categoryId));
270
+ $value = $value.$this->getAttributesInXML("category",$this->getCategoryName(trim($categoryId)));
271
+ }
272
+
273
+ } else if (is_array($columndata)){
274
+ $value = $this->getArrayAttributesInXML($columnHeader,$columndata);
275
+ } else if ($columndata instanceof Varien_Object){
276
+ $value = $this->getArrayAttributesInXML($columnHeader,$columndata->getData());
277
+ } else if ( !isset($value) || $value == ""){
278
+ $value =$this->getAttributesInXML($columnHeader, $columndata);
279
+ }
280
+ $content = $content.$value;
281
+ $value = "";
282
+ }
283
+
284
+ $content=$content.$this->getCategoryAttribute($product);
285
+ $content=$content.$this->getAttributesInXML('store','default');
286
+ return $content;
287
+ }
288
+
289
+ /*
290
+ * function to check whether the field is a multiSelect/select or not,
291
+ * This is optimized method, where it doesn't make a database call to get fieldType
292
+ * where it fetches from the local variable, which holds the information of field to fieldType mapping
293
+ */
294
+ private function isMultiSelect($attributeName = ""){
295
+ if($this->getFieldType($attributeName) == "select" || $this->getFieldType($attributeName) == "multiselect" ){
296
+ return true;
297
+ }
298
+ return false;
299
+ }
300
+
301
+ /**
302
+ * function to get Category from the category id,
303
+ * This checks it present in the global array 'categoryMap', if it is not there fetches from db
304
+ * So that once it gets one category, it doesn't make db call again for the same category
305
+ */
306
+ private function getCategory($category_id = ""){
307
+ if(!isset($this->categoryMap[$category_id])){
308
+ $category = Mage::getModel('catalog/category')->load($category_id);
309
+ $this->categoryMap[$category_id] = $category;
310
+ return $this->categoryMap[$category_id];
311
+ }
312
+ return $this->categoryMap[$category_id];
313
+ }
314
+
315
+ /**
316
+ * Method to get stock attribute in xml given the product
317
+ */
318
+ private function getStockAttribute($product){
319
+ $model = Mage::getModel('catalog/product');
320
+ $_product = $model->load($product->getId());
321
+ $stocklevel = Mage::getModel('cataloginventory/stock_item')
322
+ ->loadByProduct($product)->getQty();
323
+
324
+ $content=$this->getAttributesInXML("stock",$stocklevel);
325
+
326
+ if($stocklevel > 0){
327
+ $content=$content.$this->getAttributesInXML("Instock","1");
328
+ }
329
+ else{
330
+ $content=$content.$this->getAttributesInXML("Instock","0");
331
+ }
332
+ return $content;
333
+ }
334
+
335
+ /**
336
+ * method to get category content in xml given the product object
337
+ */
338
+ private function getCategoryAttribute($product){
339
+ $cats = $product->getCategoryIds();
340
+ $categoryId=array();
341
+ $category=array();
342
+ $content = "";
343
+ foreach ($cats as $category_id) {
344
+
345
+ $_cat = $this->getCategory($category_id);
346
+ $categoryId[]=$category_id;
347
+ $category[]=$_cat->getName();
348
+ }
349
+
350
+ $content=$content.$this->getArrayAttributesInXML("categoryIds",$categoryId);
351
+ $content=$content.$this->getArrayAttributesInXML("unbxdTaxonomyId",$categoryId);
352
+ $content=$content.$this->getArrayAttributesInXML("category",$category);
353
+ return $content;
354
+ }
355
+
356
+ /**
357
+ * method to get the xml content given the fieldname and array
358
+ */
359
+ private function getArrayAttributesInXML($columnHeader,$columndata){
360
+ $content='';
361
+
362
+ foreach($columndata as $element){
363
+
364
+ $content=$content.$this->getAttributesInXML($columnHeader,$element);
365
+ }
366
+
367
+ return $content;
368
+ }
369
+
370
+ /**
371
+ * method to get the xml content given the fieldname and value
372
+ */
373
+ private function getAttributesInXML($columnHeader,$columndata){
374
+
375
+ $columnHeader=$this->_escapeXMLHeader($columnHeader);
376
+ $content = $this->_escapeXMLValue($columndata);
377
+ $content = iconv("ISO-8859-1", "UTF-8", $content);
378
+ if($content != '' && $columnHeader != ''){
379
+ return '<'.$columnHeader.'>'.$content.'</'.$columnHeader.'>';
380
+ }else{
381
+ return '';
382
+ }
383
+ }
384
+
385
+ /**
386
+ * method to escape the xml header contents
387
+ */
388
+ private function _escapeXMLHeader($columnHeader){
389
+ if(is_numeric(substr($columnHeader,0,1))){
390
+ $columnHeader ='_'.$columnHeader;
391
+ }
392
+ return str_replace(' ','_',$columnHeader);
393
+ }
394
+
395
+ /**
396
+ * method to escape the xml contents
397
+ */
398
+ private function _escapeXMLValue($str){
399
+ $encryptedString = "";
400
+ $strlen = strlen( $str );
401
+ for( $i = 0; $i <= $strlen; $i++ ) {
402
+ $char = substr( $str, $i, 1 );
403
+ if(ord($char) == 11){
404
+ continue;
405
+ }
406
+ if((ord($char) < 32) && (ord($char) > 0) && (ord($char) != 9) && (ord($char) != 10) && (ord($char) != 13)){
407
+ $controlCharacter = true;
408
+ } else {
409
+ $controlCharacter = false;
410
+ }
411
+ $unicodeButNotAscii = (ord($char) > 126) ? true: false;
412
+ if ( ($char == "<") || ($char == "&") || ($char == ">") || ($char == '"') || ($char == "'")) {
413
+ $characterWithSpecialMeaningInXML =true;
414
+ } else {
415
+ $characterWithSpecialMeaningInXML =false;
416
+ }
417
+ if ($controlCharacter || $characterWithSpecialMeaningInXML || $unicodeButNotAscii) {
418
+ $encryptedString = $encryptedString . "&#" . (ord($char)) . ";" ;
419
+ } else {
420
+ $encryptedString = $encryptedString.$char;
421
+ }
422
+ }
423
+ return $encryptedString;
424
+ }
425
+
426
+ /**
427
+ * method to get the catalog collection
428
+ *
429
+ */
430
+ private function getCatalogCollection($fromdate,$todate,$site,$operation,$ids) {
431
+ try{
432
+ if ($operation == "add") {
433
+ // select all the attributes
434
+ $website =Mage::getModel("core/website")->setName($site);
435
+ $visiblityCondition = array('in' => array(2,3,4));
436
+
437
+ $collection = Mage::getResourceModel('catalog/product_collection')
438
+ ->addWebsiteFilter($this->validateSite($site))
439
+ ->addAttributeToFilter('status',1)
440
+ ->joinField("qty", "cataloginventory_stock_item", 'qty', 'product_id=entity_id', null, 'left')
441
+ ->addAttributeToSelect('*')
442
+ ->addAttributeToFilter('visibility',$visiblityCondition);
443
+
444
+ if(sizeof($ids) > 0){
445
+ $condition = array('in' => $ids);
446
+ $collection=$collection->addAttributeToFilter('entity_id',$condition);
447
+ }
448
+ } else {
449
+ $collection = Mage::getResourceModel('catalog/product_collection');
450
+ if(sizeof($ids) > 0) {
451
+ $condition = array('in' => $ids);
452
+ $collection= $collection->addAttributeToFilter('entity_id',$condition)->addAttributeToSelect('entity_id');
453
+ }
454
+ }
455
+
456
+ $this->log($collection->getSelect());
457
+ return $collection;
458
+ } catch(Exception $e) {
459
+ $this->log($e->getMessage());
460
+ }
461
+ }
462
+
463
+ /**
464
+ * method to get all the attributes
465
+ **/
466
+ public function getAttributes(){
467
+ return Mage::getSingleton('eav/config')
468
+ ->getEntityType(Mage_Catalog_Model_Product::ENTITY)->getAttributeCollection();
469
+ }
470
+
471
+ /**
472
+ * method to get field type of the field
473
+ **/
474
+ private function getFieldType($attributeName){
475
+ if(array_key_exists( $attributeName, $this->fieldType)){
476
+ return $this->fieldType[$attributeName];
477
+ } else {
478
+ return "text";
479
+ }
480
+ }
481
+
482
+ /**
483
+ * method to set field type to the global object
484
+ **/
485
+ private function setFieldType(){
486
+ $attributes = $this->getAttributes();
487
+ foreach($attributes as $attribute){
488
+ $this->filterable[$attribute->getAttributeCode()] = $attribute->getData('is_filterable');
489
+ $this->fieldType[$attribute->getAttributeCode()] = $attribute-> getFrontendInput();
490
+ }
491
+ }
492
+
493
+ /**
494
+ * method to get the zend date condition
495
+ */
496
+ private function getDateCondition($fromdate,$todate){
497
+ return array('from'=>$fromdate,'to'=>$todate,'date'=>true,);
498
+ }
499
+
500
+ /**
501
+ * method to create the feed
502
+ **/
503
+ public function createFeed($fromdate,$todate,$site,$operation,$ids){
504
+ if($this->createXmlFile()){
505
+ $this->log("started writing header");
506
+ if(!$this->writeXmlHeaderContents($operation)){
507
+ return false;
508
+ }
509
+ $this->log('Added header contents');
510
+ try{
511
+ if(!$this->writeXmlProductContents($fromdate,$todate,$site,$operation,$ids)){
512
+ return false;
513
+ }
514
+ }catch(Exception $e){
515
+ $this->log($e->getMessage());
516
+ $this->log($e->getTraceAsString());
517
+ return false;
518
+ }
519
+ $this->log('Added products');
520
+
521
+ if(!$this->writeXmlFooterContents()){
522
+ return false;
523
+ }
524
+ } else {
525
+ return false;
526
+ }
527
+ return true;
528
+ }
529
+
530
+ /**
531
+ * method to initiate task after index
532
+ **/
533
+ private function _afterIndex(){
534
+ $this->deleteFile();
535
+ }
536
+
537
+ /**
538
+ * method to validate whether the site exists or not
539
+ **/
540
+ public function validateSite($site){
541
+ $sites=Mage::app()->getWebsites();
542
+ if( !isset($site) || $site == "") {
543
+ return false;
544
+ }
545
+ foreach( $sites as $eachSite){
546
+ if(strcasecmp ( $eachSite->getName(), $site ) == 0 ){
547
+ return $eachSite->getWebsiteId();
548
+ }
549
+ }
550
+ return -1;
551
+ }
552
+
553
+ /**
554
+ * method to set the feedName, log, apikey based on site Name
555
+ **/
556
+ public function setUnbxdConf($site)
557
+ {
558
+ $this->key = Mage::getResourceSingleton("datafeeder/conf")->getValue("apiKey");
559
+ $this->feedName = Mage::getResourceSingleton("datafeeder/conf")->getValue($site."/feed");
560
+ $this->tax = Mage::getResourceSingleton("datafeeder/conf")->getValue($site."/tax");
561
+ $this->logFile = Mage::getBaseDir('log').DS.substr($site,0,strrpos($site, ".")-1).'unbxdDataFeeder.log';
562
+ $this->file = Mage::getBaseDir('tmp').DS.substr($site,0,strrpos($site, ".")-1).'unbxdFeed.xml';
563
+ if (!$this->log("Feed uploading started")) {
564
+ error_log("No permission to write to " + Mage::getBaseDir('log'));
565
+ return false;
566
+ }
567
+ if(!isset($this->key) || $this->key == "" || $this->key == "empty"){
568
+ $this->log("api key not set");
569
+ return false;
570
+ }
571
+ if(!isset($this->feedName) || $this->feedName == "" || $this->feedName == "empty"){
572
+ $this->log("Feed Name not set");
573
+ return false;
574
+ }
575
+ $this->setFields($site);
576
+ return true;
577
+ }
578
+
579
+ /**
580
+ * method to initiate feed uploading to the unbxd servers
581
+ **/
582
+ public function indexUnbxdFeed($fromdate,$site,$operation = "add", $ids=array()){
583
+
584
+ $this->log('unbxd Datafeeder initiated');
585
+ // validatest the site
586
+ if($this->validateSite($site) == -1){
587
+ $this->log("Invalid site Name".$site);
588
+ return;
589
+ }
590
+ // set the basic
591
+ if(! $this->setUnbxdConf($site)){
592
+ return;
593
+ }
594
+ $todate =date('Y-m-d H:i:s');
595
+
596
+ // check the lock, that if already indexing is happening
597
+ if($this->checkSiteLock($site)){
598
+ $this->log('site '. $site.' has been locked');
599
+ $action=$site.'/status';
600
+ // lock the feed
601
+ Mage::getResourceSingleton("datafeeder/conf")->updateAction($action,'1');
602
+ // create the feed
603
+
604
+ $status=$this->createFeed($fromdate,$todate,$site,$operation,$ids);
605
+ $this->log('unbxd Datafeeder finished creating file');
606
+
607
+ if($status){
608
+ try{
609
+ // if successful push it to unbxd servers
610
+ $status=$this->pushFeed($site);
611
+ }catch(Exception $e){
612
+ $this->log($e->getMessage());
613
+
614
+ }
615
+ if($status){
616
+ Mage::getResourceSingleton("datafeeder/conf")->updateAction('Lastindex',$todate);
617
+ }
618
+ }
619
+ // unlock the feed once everything is completed
620
+ Mage::getResourceSingleton("datafeeder/conf")->updateAction($action,'0');
621
+ $this->log('site '. $site.' has been unlocked');
622
+ } else {
623
+ $this->log('Feed Uploading failed because site has been locked');
624
+ }
625
+ }
626
+
627
+
628
+ /**
629
+ * method to push the feed to the Unbxd server
630
+ **/
631
+ public function pushFeed($site){
632
+ $fields=array('file'=>'@'.$this->file.';filename=unbxdFeedRenamed.xml');
633
+ $header = array('Content-Type: multipart/form-data');
634
+
635
+ $url="feed.unbxdapi.com/upload/".$this->key."/".$this->feedName;
636
+ //clear the feed
637
+ $clearFeedUrl = "http://feed.unbxdapi.com/clearfeed.do?key=".$this->key."&feedName=".$this->feedName;
638
+ file_get_contents($clearFeedUrl);
639
+ $this->log('cleared the feed');
640
+
641
+
642
+ $ch = curl_init();
643
+ curl_setopt($ch, CURLOPT_URL,$url);
644
+ curl_setopt($ch, CURLOPT_POST,true);
645
+ curl_setopt($ch, CURLOPT_POSTFIELDS,$fields);
646
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
647
+ try{
648
+ $this->log('pushing the feed');
649
+ // push the feed to the server
650
+ $response = curl_exec ($ch);
651
+ }catch(Exception $Ex){
652
+ $this->log($Ex->getMessage());
653
+ return false;
654
+ }
655
+ $this->log($response);
656
+ curl_close($ch);
657
+ return true;
658
+ }
659
+
660
+ /**
661
+ * method to check the status of the uploading
662
+ **/
663
+ public function checkSiteLock($site)
664
+ {
665
+ $value = Mage::getResourceSingleton("datafeeder/conf")->getValue($site."/status");
666
+ if($value == '0' || $value == 'empty'){
667
+ $this->log("true");
668
+ return true;
669
+ }else{
670
+ $this->log("false". $value);
671
+ return false;
672
+ }
673
+ }
674
+ }
675
+ ?>
676
+
app/code/local/Unbxdsearch/Datafeeder/Helper/UnbxdTaxonomyHelper.php ADDED
@@ -0,0 +1,318 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Unbxdsearch_Datafeeder_Helper_UnbxdTaxonomyHelper{
3
+
4
+ var $file='unbxdTaxonomy.xml';
5
+
6
+
7
+ public function __construct(){
8
+ $this->file = Mage::getBaseDir('tmp').DS.'unbxdTaxonomy.xml';
9
+ }
10
+ /**
11
+ * Function to create a file
12
+ */
13
+ private function createXmlFile(){
14
+ try{
15
+ $f=fopen($this->file,'w');
16
+ fclose($f);
17
+ return true;
18
+ } catch (Exception $Ex)
19
+ {
20
+ error_log("UNBXD_MODULE:Error while creating the file");
21
+ error_log($Ex->getMessage());
22
+ return false;
23
+ }
24
+ }
25
+
26
+ /**
27
+ * Function to appened the contents to the file
28
+ */
29
+ private function appendTofile($content){
30
+ try{
31
+
32
+ file_put_contents($this->file, $content, FILE_APPEND);
33
+ return true;
34
+ }catch(Exception $Ex){
35
+ error_log("UNBXD_MODULE:Error while appending the contents to file");
36
+ error_log($Ex->getMessage());
37
+ return false;
38
+ }
39
+ }
40
+
41
+ private function log($content){
42
+ try{
43
+ file_put_contents($this->logFile, date('Y-m-d H:i:s').$content."\n", FILE_APPEND);
44
+ return true;
45
+ }catch(Exception $Ex){
46
+ error_log("UNBXD_MODULE:Error while appending the contents to file");
47
+ Mage::throwException($Ex->getMessage());
48
+ return false;
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Function to delete the file
54
+ */
55
+ private function deleteFile(){
56
+ unlink($this->file);
57
+ }
58
+
59
+ private function writeXMLHeaderContents(){
60
+ $content="<feed>
61
+ <username>unbxd</username>
62
+ <taxonomyname>tax</taxonomyname>";
63
+ return $this->appendTofile($content);
64
+ }
65
+
66
+
67
+ private function writeXMLFooterContents(){
68
+ $content="</feed>";
69
+ return $this->appendTofile($content);
70
+ }
71
+
72
+
73
+
74
+ private function writeXMLProductsContents($site){
75
+ $stores= $this->getStores($site);
76
+ foreach( $stores as $store){
77
+ $categories=$this->getStoreCategories($store);
78
+ $content='';
79
+ $count=0;
80
+ $content=$content.'<category>';
81
+ $content=$content.$this->getAttributesInXML("name",$site);
82
+ $content=$content.$this->getAttributesInXML("parents","-1");
83
+ $content=$content.$this->getAttributesInXML("id",1);
84
+ $content=$content.$this->getAttributesInXML("url","unbxd");
85
+ $content=$content.'</category>';
86
+ foreach($categories as $category){
87
+ if( $category->getName()== "" ){
88
+ continue;
89
+ }
90
+ $content =$content.$this->getCategoryContent($category);
91
+ $category_obj = Mage::getModel('catalog/category')->load($category->getId());
92
+ $childrens = $category_obj->getAllChildren(true);
93
+ $childrenCategories = Mage::getModel('catalog/category')->getCollection()->addIdFilter($childrens)->addAttributeToSelect('*')->load();
94
+
95
+ foreach($childrenCategories as $childCategory){
96
+ $content=$content.$this->getCategoryContent($childCategory);
97
+ }
98
+ }
99
+ }
100
+ return $this->appendTofile($content);
101
+ }
102
+
103
+ private function getCategoryContent($category){
104
+ $content='';
105
+ $content=$content.'<category>';
106
+ $content=$content.$this->getAttributesInXML("name",$category->getName());
107
+ $content=$content.$this->getAttributesInXML("parents",$category->getParentId());
108
+ $content=$content.$this->getAttributesInXML("id",$category->getId());
109
+ $content=$content.$this->getAttributesInXML("url","unbxd");
110
+ $content=$content.'</category>';
111
+ $content=$content."\n";
112
+ return $content;
113
+ }
114
+
115
+
116
+
117
+ private function getAllCategories($site){
118
+ $collection = Mage::getModel('catalog/category')->getCollection()
119
+ ->setStoreId($this->getStores($site))
120
+ ->addAttributeToSelect('name')
121
+ ->addAttributeToSelect('id');
122
+
123
+ return $collection->load();
124
+
125
+ }
126
+
127
+ private function getStores($site){
128
+ $sites=Mage::app()->getWebsites();
129
+ foreach( $sites as $eachSite){
130
+ if(strcasecmp ( $eachSite->getName(), $site ) == 0 ){
131
+ return $eachSite->getStores();
132
+ }
133
+ }
134
+ }
135
+
136
+
137
+
138
+ private function getAttributesInXML($columnHeader,$columndata){
139
+
140
+ $columnHeader=$this->_escapeXMLHeader($columnHeader);
141
+ $content=$this->_escapeXMLValue($columndata);
142
+ return '<'.$columnHeader.'>'.$content.'</'.$columnHeader.'>';
143
+ }
144
+
145
+ private function _escapeXMLHeader($columnHeader){
146
+
147
+ return str_replace(' ','_',$columnHeader);
148
+ }
149
+
150
+ private function _escapeXMLValue($columndata){
151
+
152
+ return strtr($columndata,array(
153
+ "<" => "&lt;",
154
+ ">" => "&gt;",
155
+ '"' => "&quot;",
156
+ "'" => "&apos;",
157
+ "&" => "&amp;",
158
+ ));
159
+ }
160
+
161
+
162
+ public function createFeed($site){
163
+ $this->log('creating xml file');
164
+ if($this->createXmlFile()){
165
+ if(!$this->writeXmlHeaderContents()){
166
+ return false;
167
+ }
168
+ $this->log('writing header');
169
+ if(!$this->writeXMLProductsContents($site)){
170
+ return false;
171
+ }
172
+ $this->log('writing content');
173
+ if(!$this->writeXmlFooterContents()){
174
+ return false;
175
+ }
176
+ $this->log('writing footer');
177
+ } else {
178
+ return false;
179
+ }
180
+ return true;
181
+ }
182
+
183
+ public function validateSite($site){
184
+ $sites=Mage::app()->getWebsites();
185
+ if( !isset($site) || $site == "") {
186
+ return false;
187
+ }
188
+ foreach( $sites as $eachSite){
189
+ if(strcasecmp ( $eachSite->getName(), $site ) == 0 ){
190
+ return $eachSite->getWebsiteId();
191
+ }
192
+ }
193
+ return -1;
194
+ }
195
+
196
+ public function getStoreCategories($store, $sorted=false, $asCollection=false, $toLoad=true)
197
+ {
198
+ $parent = $store->getRootCategoryId();
199
+
200
+ /**
201
+ * Check if parent node of the store still exists
202
+ */
203
+ $category = Mage::getModel('catalog/category');
204
+ /* @var $category Mage_Catalog_Model_Category */
205
+ if (!$category->checkId($parent)) {
206
+ if ($asCollection) {
207
+ return new Varien_Data_Collection();
208
+ }
209
+ return array();
210
+ }
211
+
212
+ $recursionLevel = max(0, (int) Mage::app()->getStore()->getConfig('catalog/navigation/max_depth'));
213
+ $tree = Mage::getResourceModel('catalog/category_tree');
214
+ /* @var $tree Mage_Catalog_Model_Resource_Category_Tree */
215
+ $nodes = $tree->loadNode($parent)
216
+ ->loadChildren($recursionLevel)
217
+ ->getChildren();
218
+
219
+ $tree->addCollectionData(null, $sorted, $parent, $toLoad, false);
220
+ if ($asCollection) {
221
+ return $tree->getCollection();
222
+ }
223
+ return $nodes;
224
+ }
225
+
226
+ public function setUnbxdConf($site){
227
+
228
+ $this->key = Mage::getResourceSingleton("datafeeder/conf")->getValue("apiKey");
229
+ $this->feedName = Mage::getResourceSingleton("datafeeder/conf")->getValue($site."/feed");
230
+ $this->tax = Mage::getResourceSingleton("datafeeder/conf")->getValue($site."/tax");
231
+ $this->logFile = Mage::getBaseDir('log').DS.substr($site,0,strrpos($site, ".")-1).'unbxdDataFeeder.log';
232
+ $this->file = Mage::getBaseDir('tmp').DS.substr($site,0,strrpos($site, ".")-1).'unbxdTaxonomyFeed.xml';
233
+ if(!isset($this->key) || $this->key == "" || $this->key == "empty"){
234
+ $this->log("api key not set");
235
+ return false;
236
+ }
237
+ if(!isset($this->feedName) || $this->feedName == "" || $this->feedName == "empty"){
238
+ $this->log("Feed Name not set");
239
+ return false;
240
+ }
241
+ return true;
242
+ }
243
+
244
+ public function indexUnbxdFeed($site){
245
+
246
+ $this->log('unbxd Datafeeder initiated');
247
+ if($this->validateSite($site) == -1){
248
+ $this->log("Invalid site Name".$site);
249
+ return;
250
+ }
251
+ if(! $this->setUnbxdConf($site)){
252
+ return;
253
+ }
254
+ if(true){
255
+ $action='taxonomyStatus';
256
+ $this->updateAction($action,'1');
257
+ $status=$this->createFeed($site);
258
+
259
+ if($status){
260
+ $status=$this->pushFeed();
261
+ }
262
+ $action='taxonomyStatus';
263
+ $this->updateAction($action,'0');
264
+
265
+ }
266
+ }
267
+
268
+
269
+ public function pushFeed(){
270
+
271
+ $fields=array('file'=>'@'.$this->file.";filename=unbxdFeedRenamed.xml");
272
+ $url="http://feed.unbxdapi.com/taxonomy/upload/".$this->key."/".$this->tax;
273
+
274
+
275
+ $ch = curl_init();
276
+ curl_setopt($ch, CURLOPT_URL,$url);
277
+ curl_setopt($ch,CURLOPT_POST,true);
278
+ curl_setopt($ch,CURLOPT_POSTFIELDS,$fields);
279
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
280
+ try{
281
+ $response = curl_exec($ch);
282
+ }catch(Exception $Ex){
283
+ error_log($Ex->getMessage());
284
+ return false;
285
+ }
286
+ $this->log($response);
287
+ return true;
288
+
289
+ }
290
+
291
+ public function checkStatus()
292
+ {
293
+ $action='taxonomyStatus';
294
+ $collection=Mage::getModel('datafeeder/conf')->getCollection()
295
+ ->addFieldToFilter('action',$action);
296
+
297
+ $count=0;
298
+ foreach($collection as $coll){
299
+ $count++;
300
+ $value=$coll->getvalue();
301
+ }
302
+ if($count==0){
303
+ $collection=Mage::getModel('datafeeder/conf')
304
+ ->setAction($action)->setValue("0")->save();
305
+ $value="0";
306
+ }
307
+ if($value=='0'){
308
+ return true;
309
+ } else {
310
+ return false;
311
+ }
312
+ }
313
+
314
+ public function updateAction($action,$value){
315
+ Mage::getResourceSingleton("datafeeder/conf")->updateAction($action, $value);
316
+ }
317
+ }
318
+ ?>
app/code/local/Unbxdsearch/Datafeeder/Model/Attribute.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Unbxdsearch_Datafeeder_Model_Attribute{
4
+
5
+ $attributeMap = array();
6
+ public function getAttributeValue($attributeCode, $label, $product){
7
+ if(!isset($this->attributeMap[$label])){
8
+ if(!($product instanceof Mage_Catalog_Model_Product)){
9
+ return null;
10
+ }
11
+ $options = $product->getAttribute($attributeCode)
12
+ ->getSource()->getAllOptions();
13
+ foreach($options as $option){
14
+ $this->attributeMap[$option["label"]] = $option["value"];
15
+ }
16
+ }
17
+ return $this->attributeMap[$label];
18
+ }
19
+
20
+ }
21
+
22
+ ?>
app/code/local/Unbxdsearch/Datafeeder/Model/Conf.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Unbxdsearch_Datafeeder_Model_Conf extends Mage_Core_Model_Abstract {
4
+
5
+
6
+ protected function _construct()
7
+ {
8
+ $this->_init('datafeeder/conf');
9
+ }
10
+ }
11
+
12
+ ?>
app/code/local/Unbxdsearch/Datafeeder/Model/Facet.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Unbxdsearch_Datafeeder_Model_Facet extends Mage_Core_Model_Abstract {
4
+
5
+
6
+ protected function _construct()
7
+ {
8
+ $this->_init('datafeeder/facet');
9
+ }
10
+
11
+
12
+ }
13
+
14
+ ?>
app/code/local/Unbxdsearch/Datafeeder/Model/Field.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Unbxdsearch_Datafeeder_Model_Field extends Mage_Core_Model_Abstract {
4
+
5
+ protected function _construct()
6
+ {
7
+ $this->_init('datafeeder/field');
8
+ }
9
+ }
10
+
11
+ ?>
app/code/local/Unbxdsearch/Datafeeder/Model/Mysql4/Attribute.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Unbxdsearch_Datafeeder_Model_Mysql4_Attribute {
4
+
5
+ protected $attributeMap = array();
6
+ public function getAttributeValue($attributeCode, $value, $product){
7
+ if(!isset($this->attributeMap[$value])){
8
+ if(!($product instanceof Mage_Catalog_Model_Product)){
9
+ return null;
10
+ }
11
+ $options = Mage::getResourceModel('catalog/product')->getAttribute($attributeCode)
12
+ ->getSource()->getAllOptions();
13
+ foreach($options as $option){
14
+ $this->attributeMap[$option["value"]] = $option["label"];
15
+ }
16
+ }
17
+ return $this->attributeMap[$value];
18
+ }
19
+
20
+ }
21
+
22
+ ?>
app/code/local/Unbxdsearch/Datafeeder/Model/Mysql4/Conf.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Unbxdsearch_Datafeeder_Model_Mysql4_Conf extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('datafeeder/conf', 'uconfig_id');
8
+ }
9
+
10
+ public function getValue($action)
11
+ {
12
+ $collection=Mage::getModel('datafeeder/conf')->getCollection()
13
+ ->addFieldToFilter('action',$action);
14
+
15
+ $count=0;
16
+ foreach($collection as $coll){
17
+ $count++;
18
+ $value=$coll->getvalue();
19
+ }
20
+ if($count==0){
21
+ $collection=Mage::getModel('datafeeder/conf')
22
+ ->setAction($action)->setValue("empty")->save();
23
+ $value="empty";
24
+ }
25
+ return $value;
26
+ }
27
+
28
+ public function updateAction($action,$value)
29
+ {
30
+ $collection=Mage::getModel('datafeeder/conf')->getCollection()
31
+ ->addFieldToFilter('action',$action);
32
+
33
+ $count=0;
34
+ foreach($collection as $coll){
35
+ $count++;
36
+ Mage::getModel('datafeeder/conf')->load($coll->getId())->setValue($value)->save();
37
+ }
38
+ if($count==0){
39
+ $collection=Mage::getModel('datafeeder/conf')
40
+ ->setAction($action)->setValue($value)->save();
41
+ }
42
+ }
43
+ }
44
+ ?>
app/code/local/Unbxdsearch/Datafeeder/Model/Mysql4/Conf/Collection.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Unbxdsearch_Datafeeder_Model_Mysql4_Conf_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+
6
+ public function _construct()
7
+ {
8
+ $this->_init('datafeeder/conf');
9
+ }
10
+
11
+ }
12
+
13
+
14
+
15
+
16
+ ?>
app/code/local/Unbxdsearch/Datafeeder/Model/Mysql4/Field.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Unbxdsearch_Datafeeder_Model_Mysql4_Field extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('datafeeder/field', 'field_id');
8
+ }
9
+
10
+ /*
11
+ * Method to get Unbxd Fields Configuration as Mapping give the site
12
+ */
13
+ public function getFieldMapping($site) {
14
+ $results = Mage::getModel('datafeeder/field')->getCollection()->addFieldToFilter("site", $site);
15
+ $fieldMapping = [];
16
+ $_reader = Mage::getSingleton('core/resource')->getConnection('core_read');
17
+ $table = $_reader->getTableName('unbxd_search_field');
18
+ $select = $_reader->select();
19
+ $select->from($table);
20
+ $select->where("site = '" . $site. "'");
21
+
22
+ $results = $_reader->fetchAll($select);
23
+
24
+ foreach($results as $eachResult) {
25
+ $fieldMapping[$eachResult["name"]]=$eachResult['status'];
26
+ }
27
+ return $fieldMapping;
28
+ }
29
+
30
+ /**
31
+ * Returns the fields as an array of field Name to value
32
+ **/
33
+ public function getFields($site) {
34
+ $fieldMapping = $this->getFieldMapping($site);
35
+ $deltaUpdate =[];
36
+ $attributes = Mage::helper('unbxdsearch_datafeeder/UnbxdIndexingHelper')->getAttributes();
37
+ foreach($attributes as $attribute){
38
+ if (!array_key_exists($attribute->getAttributeCode(), $fieldMapping)) {
39
+ $deltaUpdate[$attribute->getAttributeCode()] = "1";
40
+ $fieldMapping[$attribute->getAttributeCode()] = "1";
41
+ }
42
+ }
43
+ if(sizeof($deltaUpdate) > 0) {
44
+ $this->saveField($deltaUpdate, $site);
45
+ }
46
+ return $fieldMapping;
47
+ }
48
+
49
+ /*
50
+ * update fields
51
+ */
52
+ public function updateFields($fieldMapping, $site) {
53
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
54
+ foreach($fieldMapping as $fieldName=>$status) {
55
+ $write->update($write->getTableName("unbxd_search_field"), array("status" => $status), "site='".$site."' AND name='".$fieldName."'");
56
+ }
57
+ }
58
+
59
+ /*
60
+ * method to save the fieldMapping information
61
+ */
62
+ public function saveField($fieldMapping, $site) {
63
+ $write = Mage::getSingleton('core/resource')->getConnection('core_write');
64
+ $insertingRequestArray = [];
65
+ foreach($fieldMapping as $field=>$value) {
66
+ $insertingRequest = [];
67
+ $insertingRequest["name"] = $field;
68
+ $insertingRequest["status"] = $value;
69
+ $insertingRequest["site"] = $site;
70
+ $insertingRequestArray[] = $insertingRequest;
71
+ }
72
+
73
+ $write->insertMultiple($write->getTableName("unbxd_search_field"), $insertingRequestArray);
74
+ }
75
+
76
+ /*
77
+ * method to get All Enabled fields
78
+ */
79
+ public function getEnabledFields($site) {
80
+ $results = Mage::getModel('datafeeder/field')->getCollection()->addFieldToFilter("site", $site);
81
+ $fields = [];
82
+ $_reader = Mage::getSingleton('core/resource')->getConnection('core_read');
83
+ $table = $_reader->getTableName('unbxd_search_field');
84
+ $select = $_reader->select();
85
+ $select->from($table);
86
+ $select->where("site = '" . $site. "' AND status='1'");
87
+ $results = $_reader->fetchAll($select);
88
+ foreach($results as $eachResult) {
89
+ $fields[]=$eachResult["name"];
90
+ }
91
+ return $fields;
92
+ }
93
+ }
94
+ ?>
app/code/local/Unbxdsearch/Datafeeder/Model/Mysql4/Field/Collection.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Unbxdsearch_Datafeeder_Model_Mysql4_Field_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+
6
+ public function _construct()
7
+ {
8
+ $this->_init('datafeeder/field');
9
+ }
10
+
11
+ }
12
+
13
+
14
+
15
+
16
+ ?>
app/code/local/Unbxdsearch/Datafeeder/Model/Mysql4/Resource/Attribute.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Unbxdsearch_Datafeeder_Model_Resource_Attribute{
4
+
5
+ $attributeMap = array();
6
+ public function getAttributeValue($attributeCode, $label, $product){
7
+ if(!isset($this->attributeMap[$label])){
8
+ if(!($product instanceof Mage_Catalog_Model_Product)){
9
+ return null;
10
+ }
11
+ $options = $product->getAttribute($attributeCode)
12
+ ->getSource()->getAllOptions();
13
+ foreach($options as $option){
14
+ $this->attributeMap[$option["label"]] = $option["value"];
15
+ }
16
+ }
17
+ return $this->attributeMap[$label];
18
+ }
19
+
20
+ }
21
+
22
+ ?>
app/code/local/Unbxdsearch/Datafeeder/controllers/ConfigController.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Unbxdsearch_Datafeeder_ConfigController extends Mage_Core_Controller_Front_Action
3
+ {
4
+
5
+ /**
6
+ * gets all the stores
7
+ */
8
+ public function getAllstoreAction(){
9
+
10
+ $allStores = Mage::app()->getStores();
11
+
12
+ foreach ($allStores as $_eachStoreId => $val)
13
+ {
14
+ $_storeCode = Mage::app()->getStore($_eachStoreId)->getCode();
15
+ $_storeName = Mage::app()->getStore($_eachStoreId)->getName();
16
+ $_storeId = Mage::app()->getStore($_eachStoreId)->getId();
17
+ echo $_storeId."<br/>";
18
+ echo $_storeCode."<br/>";
19
+ echo $_storeName."<br/>";
20
+ }
21
+ $allsites=Mage::app()->getWebsites();
22
+ foreach($allsites as $site){
23
+ echo $site->getName();
24
+ }
25
+ }
26
+
27
+ /**
28
+ * resets the lock if the feed has been locked
29
+ **/
30
+ public function resetAction(){
31
+ $site=$this->getRequest()->getParam("site");
32
+ Mage::getResourceSingleton("datafeeder/conf")->updateAction($site.'/status','0');
33
+ $this->getResponse()->setBody("success");
34
+ $this->getResponse()->setHttpResponseCode(200);
35
+ }
36
+
37
+ public function getstoreviewAction(){
38
+
39
+ echo gettype(Mage::getModel('datafeeder/field'));
40
+ $collection= Mage::getModel("datafeeder/field")->getCollection();
41
+ foreach($collection as $coll){
42
+ echo $coll->getName();
43
+ }
44
+ }
45
+
46
+ public function progressAction()
47
+ {
48
+ $site = $this->getRequest()->getParam("site");
49
+ $status = Mage::getResourceSingleton("datafeeder/conf")->getValue($site."/status");
50
+ if($status == 'empty'){
51
+ $status = '0';
52
+ }
53
+ echo '{"status":"'.$status.'"}';
54
+ }
55
+
56
+ public function getfeedconfAction(){
57
+ $site = $this->getRequest()->getParam("site");
58
+ if(isset($site) && $site != ""){
59
+ $response = array();
60
+ $response["feed"] = Mage::getResourceSingleton("datafeeder/conf")->getValue($site."/feed");
61
+ $response["tax"] = Mage::getResourceSingleton("datafeeder/conf")->getValue($site."/tax");
62
+ echo json_encode($response);
63
+ }
64
+ }
65
+ }
66
+ ?>
67
+
app/code/local/Unbxdsearch/Datafeeder/controllers/FieldController.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Unbxdsearch_Datafeeder_FieldController extends Mage_Core_Controller_Front_Action
4
+ {
5
+
6
+ const FIELD_MODEL = 'datafeeder/field';
7
+
8
+ public function configAction() {
9
+ $site=$this->getRequest()->getParam("site");
10
+ if(isset($site)){
11
+ $site="Main Website";
12
+ }
13
+ $fields = Mage::getResourceSingleton(self::FIELD_MODEL)->getFields($site);
14
+ echo json_encode($fields);
15
+ }
16
+
17
+ public function saveAction()
18
+ {
19
+ $params=$this->getRequest()->getParams();
20
+ if(!isset($params["site_name"])) {
21
+ echo json_encode(array("success"=>"false", "message"=>"Site doesnt exists"));
22
+ return;
23
+ }
24
+ $site = $params["site_name"];
25
+ unset($params["site_name"]);
26
+ unset($params["form_key"]);
27
+ $fields = Mage::getResourceSingleton(self::FIELD_MODEL)->updateFields($params,$site);
28
+ echo json_encode(array("success"=>"true"));
29
+ }
30
+ }
31
+ ?>
app/code/local/Unbxdsearch/Datafeeder/controllers/IndexController.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Unbxdsearch_Datafeeder_IndexController extends Mage_Adminhtml_Controller_Action {
4
+
5
+ protected function _getSession()
6
+ {
7
+ return Mage::getSingleton('catalog/session');
8
+ }
9
+
10
+ public function saveapiAction()
11
+ {
12
+ Mage::getResourceSingleton("datafeeder/conf")->updateAction("apiKey", $this->getRequest()->getparam("apikey"));
13
+ $this->loadLayout();
14
+ $this->_addContent($this->getLayout()->createBlock('unbxdsearch_datafeeder/index')->setTemplate('datafeeder/conf.phtml'));
15
+ $this->renderLayout();
16
+ }
17
+
18
+ public function savefeedconfAction(){
19
+ Mage::getResourceSingleton("datafeeder/conf")->updateAction($this->getRequest()->getparam("site")."/feed", $this->getRequest()->getparam("feedName"));
20
+ Mage::getResourceSingleton("datafeeder/conf")->updateAction($this->getRequest()->getparam("site")."/tax", $this->getRequest()->getparam("feedName"));
21
+
22
+ $this->loadLayout();
23
+ $this->_addContent($this->getLayout()->createBlock('unbxdsearch_datafeeder/index')->setTemplate('datafeeder/conf.phtml'));
24
+ $this->renderLayout();
25
+ }
26
+
27
+ public function indexAction()
28
+ {
29
+ error_log("index actions");
30
+ $this->loadLayout();
31
+ $this->_addContent($this->getLayout()->createBlock('unbxdsearch_datafeeder/index')->setTemplate('datafeeder/conf.phtml'));
32
+ $this->renderLayout();
33
+ }
34
+
35
+ public function fullindexAction(){
36
+ $_helper=Mage::helper('unbxdsearch_datafeeder/UnbxdIndexingHelper');
37
+ $fromdate="1970-01-01 00:00:00";
38
+ $site=$this->getRequest()->getPost("site");
39
+ $_helper->indexUnbxdFeed($fromdate,$site);
40
+ echo "Done";
41
+ }
42
+
43
+ public function taxonomyindexAction(){
44
+ $_helper=Mage::helper('unbxdsearch_datafeeder/UnbxdTaxonomyHelper');
45
+ $site=$this->getRequest()->getPost("site");
46
+ $_helper->indexUnbxdFeed($site);
47
+ }
48
+
49
+ public function incrementalindexAction()
50
+ {
51
+ $_helper=Mage::helper('unbxdsearch_datafeeder/UnbxdIndexingHelper');
52
+ $fromdate=Mage::getResourceSingleton("datafeeder/conf")->getValue("Lastindex");
53
+ if(is_null($fromdate)){
54
+ $fromdate="1970-01-01 00:00:00";
55
+ }
56
+ $site=$this->getRequest()->getPost("site");
57
+ $_helper->indexUnbxdFeed($fromdate,$site);
58
+ echo "Done";
59
+ }
60
+ } ?>
app/code/local/Unbxdsearch/Datafeeder/etc/adminhtml.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <menu>
4
+ <unbxd_datafeeder translate="title" module="unbxdsearch_datafeeder">
5
+ <title>Unbxd</title>
6
+ <sort_order>30</sort_order>
7
+ <children>
8
+ <upload translate="title" module="unbxdsearch_datafeeder">
9
+ <title>Upload Configuration</title>
10
+ <sort_order>11</sort_order>
11
+ <action>datafeeder/index/index</action>
12
+ </upload>
13
+ </children>
14
+ </unbxd_datafeeder>
15
+ </menu>
16
+ </config>
app/code/local/Unbxdsearch/Datafeeder/etc/config.xml ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Unbxdsearch_Datafeeder>
5
+ <version>0.1.0</version>
6
+ </Unbxdsearch_Datafeeder>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <datafeeder>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Unbxdsearch_Datafeeder</module>
14
+ <frontName>datafeeder</frontName>
15
+ </args>
16
+ </datafeeder>
17
+ </routers>
18
+ </frontend>
19
+ <global>
20
+ <models>
21
+ <unbxdsearch_datafeeder>
22
+ <class>Unbxdsearch_Datafeeder_Model</class>
23
+ <resourceModel>unbxdsearch_datafeeder_resource</resourceModel>
24
+ </unbxdsearch_datafeeder>
25
+ <unbxdsearch_datafeeder_resource>
26
+ <class>Unbxdsearch_Datafeeder_Model_Resource</class>
27
+ </unbxdsearch_datafeeder_resource>
28
+ </models>
29
+ <blocks>
30
+ <unbxdsearch_datafeeder>
31
+ <class>Unbxdsearch_Datafeeder_Block</class>
32
+ </unbxdsearch_datafeeder>
33
+ </blocks>
34
+ </global>
35
+ <global>
36
+ <helpers>
37
+ <unbxdsearch_datafeeder>
38
+ <class>Unbxdsearch_Datafeeder_Helper</class>
39
+ </unbxdsearch_datafeeder>
40
+ </helpers>
41
+ </global>
42
+ <admin>
43
+ <routers>
44
+ <the_name_of_this_element_is_not_important_it_should_be_unique>
45
+ <use>admin</use>
46
+ <args>
47
+ <module>Unbxdsearch_Datafeeder</module>
48
+ <frontName>datafeeder</frontName>
49
+ </args>
50
+ </the_name_of_this_element_is_not_important_it_should_be_unique>
51
+ </routers>
52
+ </admin>
53
+ <adminhtml>
54
+ <!-- The <layout> updates allow us to define our block layouts in a separate file so are aren't messin' with the Magento layout files. -->
55
+ <layout>
56
+ <updates>
57
+ <unbxdsearch_datafeeder>
58
+ <file>unbxdsearch_datafeeder.xml</file>
59
+ </unbxdsearch_datafeeder>
60
+ </updates>
61
+ </layout>
62
+ <!-- The <acl> section is for access control. Here we define the pieces where access can be controlled within a role. -->
63
+ <acl>
64
+ <resources>
65
+ <admin>
66
+ <children>
67
+ <unbxdsearch_datafeeder>
68
+ <title>Unbxdsearch Menu Item</title>
69
+ <children>
70
+ <example translate="title" module="unbxdsearch_datafeeder">
71
+ <title>Example Menu Item</title>
72
+ </example>
73
+ </children>
74
+ </unbxdsearch_datafeeder>
75
+ </children>
76
+ </admin>
77
+ </resources>
78
+ </acl>
79
+ </adminhtml>
80
+ <global>
81
+ <models>
82
+ <datafeeder>
83
+ <class>Unbxdsearch_Datafeeder_Model</class>
84
+ <resourceModel>datafeeder_mysql4</resourceModel>
85
+ </datafeeder>
86
+ <datafeeder_mysql4>
87
+ <class>Unbxdsearch_Datafeeder_Model_Mysql4</class>
88
+ <entities>
89
+ <conf>
90
+ <table>unbxd_datafeeder_conf</table>
91
+ </conf>
92
+ <field>
93
+ <table>unbxd_search_field</table>
94
+ </field>
95
+ </entities>
96
+ </datafeeder_mysql4>
97
+ </models>
98
+ <resources>
99
+ <datafeeder_setup>
100
+ <setup>
101
+ <module>Unbxdsearch_Datafeeder</module>
102
+ </setup>
103
+ <connection>
104
+ <use>core_setup</use>
105
+ </connection>
106
+ </datafeeder_setup>
107
+ <datafeeder_write>
108
+ <connection>
109
+ <use>core_write</use>
110
+ </connection>
111
+ </datafeeder_write>
112
+ <datafeeder_read>
113
+ <connection>
114
+ <use>core_read</use>
115
+ </connection>
116
+ </datafeeder_read>
117
+ </resources>
118
+ </global>
119
+ </config>
app/code/local/Unbxdsearch/Datafeeder/scripts/Cron.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'abstract.php';
3
+
4
+ class Unbxdsearch_Datafeeder_Scripts_Cron extends Mage_Shell_Abstract
5
+ {
6
+
7
+ public function _getIndexer()
8
+ {
9
+ return Mage::helper('unbxdsearch_datafeeder/UnbxdIndexingHelper');
10
+ }
11
+
12
+ public function run(){
13
+ $_helper = _getIndexer();
14
+ $fromdate="1970-01-01 00:00:00";
15
+ $site='Main Site';
16
+
17
+ $_helper->indexUnbxdFeed($fromdate,$site);
18
+ }
19
+
20
+ }
21
+
22
+
23
+ $shell = new Unbxdsearch_Datafeeder_Scripts_Cron();
24
+ $shell->run();
25
+ ?>
app/code/local/Unbxdsearch/Datafeeder/scripts/abstract.php ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Shell
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Shell scripts abstract class
29
+ *
30
+ * @category Mage
31
+ * @package Mage_Shell
32
+ * @author Magento Core Team <core@magentocommerce.com>
33
+ */
34
+ abstract class Mage_Shell_Abstract
35
+ {
36
+ /**
37
+ * Is include Mage and initialize application
38
+ *
39
+ * @var bool
40
+ */
41
+ protected $_includeMage = true;
42
+
43
+ /**
44
+ * Magento Root path
45
+ *
46
+ * @var string
47
+ */
48
+ protected $_rootPath;
49
+
50
+ /**
51
+ * Initialize application with code (store, website code)
52
+ *
53
+ * @var string
54
+ */
55
+ protected $_appCode = 'admin';
56
+
57
+ /**
58
+ * Initialize application code type (store, website, store_group)
59
+ *
60
+ * @var string
61
+ */
62
+ protected $_appType = 'store';
63
+
64
+ /**
65
+ * Input arguments
66
+ *
67
+ * @var array
68
+ */
69
+ protected $_args = array();
70
+
71
+ /**
72
+ * Initialize application and parse input parameters
73
+ *
74
+ */
75
+ public function __construct()
76
+ {
77
+ if ($this->_includeMage) {
78
+ require_once $this->_getRootPath() . 'app' . DIRECTORY_SEPARATOR . 'Mage.php';
79
+ Mage::app($this->_appCode, $this->_appType);
80
+ }
81
+
82
+ $this->_applyPhpVariables();
83
+ $this->_parseArgs();
84
+ $this->_construct();
85
+ $this->_validate();
86
+ $this->_showHelp();
87
+ }
88
+
89
+ /**
90
+ * Get Magento Root path (with last directory separator)
91
+ *
92
+ * @return string
93
+ */
94
+ protected function _getRootPath()
95
+ {
96
+ if (is_null($this->_rootPath)) {
97
+ $this->_rootPath = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR;
98
+ }
99
+ return $this->_rootPath;
100
+ }
101
+
102
+ /**
103
+ * Parse .htaccess file and apply php settings to shell script
104
+ *
105
+ */
106
+ protected function _applyPhpVariables()
107
+ {
108
+ $htaccess = $this->_getRootPath() . '.htaccess';
109
+ if (file_exists($htaccess)) {
110
+ // parse htaccess file
111
+ $data = file_get_contents($htaccess);
112
+ $matches = array();
113
+ preg_match_all('#^\s+?php_value\s+([a-z_]+)\s+(.+)$#siUm', $data, $matches, PREG_SET_ORDER);
114
+ if ($matches) {
115
+ foreach ($matches as $match) {
116
+ @ini_set($match[1], str_replace("\r", '', $match[2]));
117
+ }
118
+ }
119
+ preg_match_all('#^\s+?php_flag\s+([a-z_]+)\s+(.+)$#siUm', $data, $matches, PREG_SET_ORDER);
120
+ if ($matches) {
121
+ foreach ($matches as $match) {
122
+ @ini_set($match[1], str_replace("\r", '', $match[2]));
123
+ }
124
+ }
125
+ }
126
+ }
127
+
128
+ /**
129
+ * Parse input arguments
130
+ *
131
+ * @return Mage_Shell_Abstract
132
+ */
133
+ protected function _parseArgs()
134
+ {
135
+ $current = null;
136
+ foreach ($_SERVER['argv'] as $arg) {
137
+ $match = array();
138
+ if (preg_match('#^--([\w\d_-]{1,})$#', $arg, $match) || preg_match('#^-([\w\d_]{1,})$#', $arg, $match)) {
139
+ $current = $match[1];
140
+ $this->_args[$current] = true;
141
+ } else {
142
+ if ($current) {
143
+ $this->_args[$current] = $arg;
144
+ } else if (preg_match('#^([\w\d_]{1,})$#', $arg, $match)) {
145
+ $this->_args[$match[1]] = true;
146
+ }
147
+ }
148
+ }
149
+ return $this;
150
+ }
151
+
152
+ /**
153
+ * Additional initialize instruction
154
+ *
155
+ * @return Mage_Shell_Abstract
156
+ */
157
+ protected function _construct()
158
+ {
159
+ return $this;
160
+ }
161
+
162
+ /**
163
+ * Validate arguments
164
+ *
165
+ */
166
+ protected function _validate()
167
+ {
168
+ if (isset($_SERVER['REQUEST_METHOD'])) {
169
+ die('This script cannot be run from Browser. This is the shell script.');
170
+ }
171
+ }
172
+
173
+ /**
174
+ * Run script
175
+ *
176
+ */
177
+ abstract public function run();
178
+
179
+ /**
180
+ * Check is show usage help
181
+ *
182
+ */
183
+ protected function _showHelp()
184
+ {
185
+ if (isset($this->_args['h']) || isset($this->_args['help'])) {
186
+ die($this->usageHelp());
187
+ }
188
+ }
189
+
190
+ /**
191
+ * Retrieve Usage Help Message
192
+ *
193
+ */
194
+ public function usageHelp()
195
+ {
196
+ return <<<USAGE
197
+ Usage: php -f script.php -- [options]
198
+
199
+ -h Short alias for help
200
+ help This help
201
+ USAGE;
202
+ }
203
+
204
+ /**
205
+ * Retrieve argument value by name or false
206
+ *
207
+ * @param string $name the argument name
208
+ * @return mixed
209
+ */
210
+ public function getArg($name)
211
+ {
212
+ if (isset($this->_args[$name])) {
213
+ return $this->_args[$name];
214
+ }
215
+ return false;
216
+ }
217
+ }
218
+
app/code/local/Unbxdsearch/Datafeeder/sql/datafeeder_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ $installer = $this;
5
+ /* @var $installer Mage_Core_Model_Resource_Setup */
6
+
7
+ $installer->startSetup();
8
+
9
+ $installer->run("
10
+
11
+ DROP TABLE IF EXISTS `{$installer->getTable('unbxd_search_field')}`;
12
+
13
+ CREATE TABLE `{$installer->getTable('unbxd_search_field')}` (
14
+ `field_id` int(10) unsigned NOT NULL auto_increment,
15
+ `name` varchar(255) NOT NULL default '',
16
+ `status` varchar(255),
17
+ `site` varchar(255) NOT NULL default '',
18
+ PRIMARY KEY (`field_id`)
19
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
20
+
21
+
22
+
23
+ DROP TABLE IF EXISTS `{$installer->getTable('unbxd_datafeeder_conf')}`;
24
+
25
+ CREATE TABLE `{$installer->getTable('unbxd_datafeeder_conf')}` (
26
+ `uconfig_id` int(10) unsigned NOT NULL auto_increment,
27
+ `action` varchar(255) NOT NULL default '',
28
+ `value` varchar(255),
29
+ PRIMARY KEY (`uconfig_id`)
30
+
31
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
32
+
33
+ ");
34
+ $installer->endSetup();
35
+
36
+
app/design/adminhtml/base/default/template/datafeeder/conf.phtml ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
2
+ <script src="http://malsup.github.com/jquery.form.js"></script>
3
+ <style type="text/css">
4
+ td
5
+ {
6
+ margin-left:100cm;
7
+ padding:10px;
8
+ vertical-align:left;
9
+ }
10
+ .datafeeder-form input[type="text"] {
11
+ width: 300px;
12
+ }
13
+ </style>
14
+ <script type="text/javascript">
15
+ var $jq = jQuery.noConflict();
16
+ </script>
17
+ <frameset cols="50%,50%">
18
+ <frame name="actual_frame">
19
+ <div class="datafeeder-form" onload="allset()">
20
+ <form action="<?php echo $this->getSaveApiUrl();?>" method="POST" >
21
+
22
+ <span><b>Unbxd API Key: </b><span>
23
+ <input type="text" name="apikey" style="margin-left: 10px;" value="<?php echo $this->getApiKey(); ?>">
24
+ <input type="submit" style="margin-left: 10px;" value="SAVE"/>
25
+ </form>
26
+ <form action="<?php echo $this->saveFeedConf();?>" method="POST" >
27
+ <p class="switcher">
28
+ <label for="store_switcher"><b>Choose Store View: </b><label>
29
+
30
+ <select id="site" class="site" name="site" onload="newajaxcall('<?php echo $this->getFeedConf(); ?>')" onchange="newajaxcall('<?php echo $this->getFeedConf();?>')">
31
+ <?php $allsites=Mage::app()->getWebsites();?>
32
+ <?php foreach ($allsites as $site):?>
33
+ <option value="<?php echo $site->getName()?>"><?php echo $site->getName()?></option>
34
+ <?php endforeach;?>
35
+ </select>
36
+ </p>
37
+
38
+
39
+ <table class="form-list" onload="allset()" id="form-list" name="form-list" cellspacing="0" style="background:none repeat scroll 0 0 #FAFAFA;border=1px solid #D6D6D6;width: 100%;" width="5000px">
40
+ <div class="datafeeder-form" width="parent" style="background:none repeat scroll 0 0 #6F8992;padding:5px 10px; color: white;">
41
+ FEED CONFIGURATION
42
+ </div>
43
+ <tr>
44
+ <td class="label">
45
+ <b>Unbxd Site Name: </b>
46
+ </td>
47
+ <td class="value">
48
+ <input type="text" id="feedName" name="feedName" value="" disabled/>
49
+ </td>
50
+ </tr>
51
+ </tr>
52
+ <tr>
53
+ <td class="label">
54
+ </td>
55
+ <td class="value">
56
+ <input type="button" name="editButton" value="EDIT"/> <input style="margin-left: 10px;" type="submit" value="SAVE"/>
57
+ </td>
58
+ </tr>
59
+ </table>
60
+
61
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
62
+ </form>
63
+ <script type="text/javascript">
64
+
65
+ $jq('[name=editButton]').click(function(evt){
66
+ $jq('[name="feedName"]').attr('disabled', false);
67
+ });
68
+
69
+ function progressbar()
70
+ {
71
+ $jq.ajax({
72
+ //async:false,
73
+ url: "<?php echo $this->getProgressUrl(); ?>",
74
+ type:"POST",
75
+ dataType:"json",
76
+ data:{"form_key":"<?php echo Mage::getSingleton('core/session')->getFormKey()?>",
77
+ "site": $jq('[name=site]').val()
78
+ },
79
+ success: function(data) {
80
+ document.getElementById("ProgressBar").innerHTML="";
81
+ if(data.status=="0"){
82
+ document.getElementById("ProgressBar").innerHTML="<b>Status: Indexed</b>";
83
+ document.getElementById("fullupload").disabled=false;
84
+ }else if(data.status=="1"){
85
+ document.getElementById("ProgressBar").innerHTML="<b>Status: Indexing</b>";
86
+ document.getElementById("fullupload").disabled=true;
87
+ }
88
+ }
89
+ });
90
+
91
+ }
92
+
93
+ function callSetInterval()
94
+ {
95
+ setInterval(progressbar,20000);
96
+ }
97
+
98
+ function newajaxcall(ajaxurl){
99
+ //createTable('<?php echo $this->getEditUrl();?>');
100
+ $jq.ajax({
101
+
102
+ url: ajaxurl,
103
+ timeout:3000,
104
+ type:"POST",
105
+ dataType: "json",
106
+ data:{"form_key":"<?php echo Mage::getSingleton('core/session')->getFormKey()?>",
107
+ "site":$jq('[name=site]').val(),
108
+ },
109
+
110
+ success: function(data) {
111
+
112
+ if(data.feed !== "empty") $jq('[name=feedName]').val(data.feed); else $jq('[name=feedName]').val("");
113
+
114
+
115
+ },
116
+
117
+ fail: function(XMLHttpRequest, textStatus, errorThrown) {
118
+ }
119
+ });
120
+ }
121
+
122
+ newajaxcall("<?php echo $this->getFeedConf();?>");
123
+
124
+ function makeajaxcall(ajaxurl){
125
+
126
+ $jq.ajax({
127
+
128
+ url: ajaxurl,
129
+ timeout:100000,
130
+ type:"POST",
131
+ data:{"form_key":"<?php echo Mage::getSingleton('core/session')->getFormKey()?>",
132
+ "site": $jq('[name=site]').val()
133
+ },
134
+
135
+ complete: function(xhr, statusText){
136
+ },
137
+
138
+ done: function(data) {
139
+ console.log(data);
140
+ },
141
+
142
+ fail: function(XMLHttpRequest, textStatus, errorThrown) {
143
+ }
144
+ });
145
+ }
146
+
147
+ setInterval(progressbar,10000);
148
+ </script>
149
+
150
+
151
+ <table class="form-list" width="parent" id="form-list" name="form-list" cellspacing="0" style="background:none repeat scroll 0 0 #FAFAFA;border=1px solid #D6D6D6;width: 100%;">
152
+ <div class="datafeeder-form" width="parent" style="background:none repeat scroll 0 0 #6F8992;padding:5px 10px;color: white;">
153
+ <div class="refreshDiv" style="float: right;"><span id="ProgressBar"></span><input type="button" id="refresh" onclick="progressbar()" value="REFRESH" style="margin-left: 10px;vertical-align: top;"></div>
154
+ <b>UPLOAD &amp; INDEX (manual)</b>
155
+ </div>
156
+
157
+ <tr>
158
+ <td class="label"><b>TAXONOMY UPLOAD: </b></td>
159
+ <td class="value"><input type="button" id="taxonomyupload" onclick="makeajaxcall('<?php echo $this->getTaxonomyUploadFormAction(); ?>')" value="START"/></td>
160
+ </tr>
161
+
162
+
163
+ <tr>
164
+ <td class="label"><b>PRODUCT FEED UPLOAD: </b></td>
165
+ <td class="value"><input type="button" id="fullupload" onclick="makeajaxcall('<?php echo $this->getFullIndexFormAction(); ?>')" value="START"/></td>
166
+
167
+ </tr>
168
+
169
+ </table>
170
+
171
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>"/>
172
+ </div>
173
+ </frame>
174
+ <frame name="login_frame"></frame>
175
+ </frameset>
176
+
177
+ <!-- FIELD CONFIGURATION -->
178
+ <script type="text/javascript">
179
+ $jq('#config_edit_form').ready(function(){
180
+ createTable('<?php echo $this->getEditUrl();?>');
181
+ });
182
+
183
+ function formSubmit()
184
+ {
185
+ $jq('[name=site_name]').val($jq('[name=site]').val());
186
+ $jq('#config_edit_form').ajaxSubmit();
187
+ }
188
+
189
+ function createTable(ajaxurl)
190
+ {
191
+ site= $jq("#site").val();
192
+ $jq.ajax({
193
+ url: ajaxurl,
194
+ type:"POST",
195
+ data:{"site":site},
196
+ }).done( function(data) {
197
+ jarray = $jq.parseJSON(data);
198
+ tableString="<tbody>";
199
+ $jq("#field-list").find("tr").remove();
200
+ $jq.each(jarray, function(key, value) {
201
+ tableString+='<tr><td class="label">'+key+"</td>"+'<td class="value">'+'<select name="'+key+'">'+"<option";
202
+ if(value=="0"){
203
+ tableString+=' selected="selected"';
204
+ }
205
+ tableString+=' value="0">Disabled</option><option';
206
+ if(value!="0"){
207
+ tableString+=' selected="selected"';
208
+ }
209
+ tableString+=' value="1">Enabled</option></select></td>';
210
+ tableString+='<td class="scope-label"></td><td class=""></td></tr>'
211
+ });
212
+ tableString+="</tbody>";
213
+ $jq('#field-list').append(tableString)
214
+ });
215
+ }
216
+ </script>
217
+
218
+ <div class="editconfig">
219
+ <div class="content-header">
220
+ <table cellspacing="0">
221
+ <tr>
222
+ <td>
223
+ <h3 <?php if($this->getHeaderCss()): ?>
224
+ class="<?php echo $this->getHeaderCss()?>" <?php endif; ?>>
225
+ <?php echo Mage::helper('adminhtml')->__("FIELD CONFIGURATION") ?>
226
+ </h3>
227
+ </td>
228
+ <td class="form-buttons">
229
+ <input type="button" style='background:url("images/btn_bg.gif") repeat-x scroll 0 100% #FFAC47;border-color:#ED6502 #A04300 #A04300 #ED6502;border-style:solid;border-width:1px;color:#FFFFFF;font:bold 12px arial,helvetica,sans-serif;text-align:center !important;white-space:nowrap;padding: 3px;' onclick="formSubmit()" value="SAVE"/>
230
+ </td>
231
+ </tr>
232
+ </table>
233
+ </div>
234
+ <div class="unbxd_edit_config" style="background:none repeat scroll 0 0 #FAFAFA;border:1px solid #D6D6D6">
235
+
236
+ <form action="<?php echo $this->getSaveFieldUrl() ?>" method="post"
237
+ id="config_edit_form" onload="createTable('<?php echo $this->getEditUrl();?>')">
238
+ <input name="site_name" id= "site_name" type="hidden" />
239
+ <!--<center>-->
240
+ <p class="switcher">
241
+ <label for="store_switcher"><b> Field Configuration </b><label>
242
+ </p>
243
+
244
+ <table class="form-list" id="field-list" name="form-list" cellspacing="0" style="color: #2F2F2F;
245
+ font: 12px/1.5em Arial,Helvetica,sans-serif; margin-left: 10%;">
246
+ </table>
247
+
248
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
249
+
250
+ </form>
251
+ </div>
252
+ </div>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>unbxd_feedconnector</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>pushes the products from the magento to unbxd servers</summary>
10
+ <description>pushes the products from the magento to unbxd servers</description>
11
+ <notes>pushes the data to unbxd server</notes>
12
+ <authors><author><name>ananthesh</name><user>ananthesh</user><email>ananthesh@unbxd.com</email></author></authors>
13
+ <date>2014-05-13</date>
14
+ <time>10:55:40</time>
15
+ <contents><target name="magelocal"><dir name="Unbxdsearch"><dir name="Datafeeder"><dir name="Block"><file name="Edit.php" hash="592e99623deb15cfa9c923f5b7b7e5fc"/><file name="Index.php" hash="9833c478dcf1eb02b28a2c053b34b1f8"/></dir><dir name="Helper"><file name="Data.php" hash="21f8904963d88a84e1b0320444eec6ce"/><file name="UnbxdIndexingHelper.php" hash="aede82f2555e0af0b16051eb3650870c"/><file name="UnbxdTaxonomyHelper.php" hash="89bdf9463b29697e51d5b69278b5e5f8"/><file name=".DS_Store" hash="801d9a1a1f478b210726cfc656cec74f"/></dir><dir name="Model"><file name="Attribute.php" hash="d188424940429362ac3509779b690c98"/><file name="Conf.php" hash="e91eb879eba35139b11e7a0324392881"/><file name="Facet.php" hash="70addbc9dde26974ed81ca4723633028"/><file name="Field.php" hash="eebcc70e5949b4c5f0631714fd87de54"/><dir name="Mysql4"><file name="Attribute.php" hash="7cb5a9cc9d88b0ef7abb5eb926a33466"/><dir name="Conf"><file name="Collection.php" hash="758413bfdca83c8533972926d7b776da"/></dir><file name="Conf.php" hash="c2ef2f173e1a22531b761d42ea7712d7"/><dir name="Field"><file name="Collection.php" hash="c6929e2057b1d24627a89d00a7b852d6"/></dir><file name="Field.php" hash="33f4b14958edf106fcaeaffad744836f"/><dir name="Resource"><file name="Attribute.php" hash="4e9757e64a4ad8ab04806833affc4a9d"/></dir></dir></dir><dir name="controllers"><file name="ConfigController.php" hash="778b9924aca5cf595803acdb849f6d8a"/><file name="FieldController.php" hash="23d4c5cbd07c22ac3ec0283458ae4a36"/><file name="IndexController.php" hash="b0b4e6473a99415832b4164d4fd6e1d1"/></dir><dir name="etc"><file name="adminhtml.xml" hash="ead138122f3ff30faf6f57be7151551b"/><file name="config.xml" hash="a0574c85ff5965f0b8cff710ec27a326"/></dir><dir name="scripts"><file name="Cron.php" hash="64dfa150d3156d5d540a7379d435844d"/><file name="abstract.php" hash="757e66bc99da02c274a0d9723923329e"/></dir><dir name="sql"><dir name="datafeeder_setup"><file name="mysql4-install-0.1.0.php" hash="d7d0aae31e449eadd83d83ae2d3d6e68"/></dir></dir><file name=".DS_Store" hash="b4a356bd7741138b66aa79afcc4abd2f"/></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="template"><dir name="datafeeder"><file name="conf.phtml" hash="1e547975226b4efde7fd313a40ff2cc7"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="shell"><file name="UnbxdFeed.php" hash="71aae876897755613741f972355a7a23"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
shell/UnbxdFeed.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once 'abstract.php';
3
+
4
+ class Unbxdsearch_Datafeeder_Scripts_UnbxdFeed extends Mage_Shell_Abstract
5
+ {
6
+
7
+ public function _getIndexer()
8
+ {
9
+ return Mage::helper('unbxdsearch_datafeeder/UnbxdIndexingHelper');
10
+ }
11
+
12
+ public function run(){
13
+ $_helper = $this->_getIndexer();
14
+ $fromdate="1970-01-01 00:00:00";
15
+ $site='Main Website';
16
+
17
+ $_helper->indexUnbxdFeed($fromdate,$site);
18
+ }
19
+
20
+ }
21
+
22
+
23
+ $shell = new Unbxdsearch_Datafeeder_Scripts_UnbxdFeed();
24
+ $shell->run();
25
+ ?>