unbxd_datafeeder - Version 0.0.2

Version Notes

alksdlka

Download this release

Release Info

Developer unbxd
Extension unbxd_datafeeder
Version 0.0.2
Comparing to
See all releases


Version 0.0.2

app/code/local/Unbxd/Datafeeder/Model/Observer.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Unbxd_Datafeeder_Model_Observer
5
+ {
6
+
7
+
8
+ public function feed()
9
+ {
10
+ $allowedvisibility = array(
11
+ array(
12
+ "finset" => array(3)
13
+ ),
14
+ array(
15
+ "finset" => array(4)
16
+ ),
17
+ );
18
+ $collection = Mage::getModel('catalog/product') ->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('visibility',$allowedvisibility);
19
+ $totalsize = $collection->getSize();
20
+
21
+ $pageStart=1;
22
+ $pageSize=50;
23
+ set_time_limit(0);
24
+
25
+ for($pageStart=1;$pageStart<=$totalsize;$pageStart=$pageStart+$pageSize)
26
+ {
27
+ if($totalsize-$pageStart<$pageSize)
28
+ $pageSize=$totalsize-$pageStart;
29
+ $collection = Mage::getModel('catalog/product') ->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('visibility',$allowedvisibility);
30
+ $collection->clear()
31
+ ->setPage($pageStart, $pageSize)
32
+ ->load();
33
+ $resultarray=array();
34
+ $resultarray["data"]=array();
35
+
36
+ foreach($collection as $item)
37
+ {
38
+ $result=array();
39
+ foreach($item->getData('') as $columnHeader=>$columndata)
40
+ {
41
+ if(!is_object($columndata))
42
+ {
43
+ if($item->getAttributeText($columnHeader))
44
+ $columndata=$item->getAttributeText($columnHeader);
45
+
46
+ $result[$columnHeader]=urlencode(addslashes($columndata));
47
+
48
+ }
49
+ $categoryIds = $item->getCategoryIds();
50
+
51
+ $categoryarray=array();
52
+ $categoryurlarray=array();
53
+ foreach($categoryIds as $categoryId) {
54
+ $category = Mage::getModel('catalog/category')->load($categoryId);
55
+ $categoryarray[]=urlencode(addslashes($category->getName()));
56
+ $categoryurlarray[]=urlencode(addslashes($category->getUrlPath()));
57
+ }
58
+ $result["category"]=$categoryarray;
59
+ $result["categoryurl"]=$categoryurlarray;
60
+
61
+ }
62
+ $resultarray["data"][]=$result;
63
+ }
64
+
65
+
66
+ $url = 'http://176.9.111.205:8080/skoolshop_an/datafeed';
67
+
68
+ $vars = 'jsondoc=' .json_encode($resultarray) ;
69
+
70
+ $ch = curl_init($url);
71
+ curl_setopt($ch, CURLOPT_POST ,1);
72
+ curl_setopt($ch, CURLOPT_POSTFIELDS ,$vars);
73
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
74
+ curl_setopt($ch, CURLOPT_HEADER ,0);
75
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
76
+ $response = curl_exec($ch);
77
+
78
+ }
79
+
80
+
81
+ }
82
+
83
+ }
app/code/local/Unbxd/Datafeeder/Model/Observer.php~ ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Unbxd_Datafeeder_Model_Observer
5
+ {
6
+
7
+
8
+ public function feed()
9
+ {
10
+ $allowedvisibility = array(
11
+ array(
12
+ "finset" => array(3)
13
+ ),
14
+ array(
15
+ "finset" => array(4)
16
+ ),
17
+ );
18
+ $collection = Mage::getModel('catalog/product') ->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('visibility',$allowedvisibility);
19
+ $totalsize = $collection->getSize();
20
+
21
+ $pageStart=1;
22
+ $pageSize=50;
23
+ set_time_limit(0);
24
+
25
+ for($pageStart=1;$pageStart<=$totalsize;$pageStart=$pageStart+$pageSize)
26
+ {
27
+ if($totalsize-$pageStart<$pageSize)
28
+ $pageSize=$totalsize-$pageStart;
29
+ $collection = Mage::getModel('catalog/product') ->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('visibility',$allowedvisibility);
30
+ $collection->clear()
31
+ ->setPage($pageStart, $pageSize)
32
+ ->load();
33
+ $resultarray=array();
34
+ $resultarray["data"]=array();
35
+
36
+ foreach($collection as $item)
37
+ {
38
+ $result=array();
39
+ foreach($item->getData('') as $columnHeader=>$columndata)
40
+ {
41
+ if(!is_object($columndata))
42
+ {
43
+ if($item->getAttributeText($columnHeader))
44
+ $columndata=$item->getAttributeText($columnHeader);
45
+
46
+ $result[$columnHeader]=urlencode(addslashes($columndata));
47
+
48
+ }
49
+ $categoryIds = $item->getCategoryIds();
50
+
51
+ $categoryarray=array();
52
+ $categoryurlarray=array();
53
+ foreach($categoryIds as $categoryId) {
54
+ $category = Mage::getModel('catalog/category')->load($categoryId);
55
+ $categoryarray[]=urlencode(addslashes($category->getName()));
56
+ $categoryurlarray[]=urlencode(addslashes($category->getUrlPath()));
57
+ }
58
+ $result["category"]=$categoryarray;
59
+ $result["categoryurl"]=$categoryurlarray;
60
+
61
+ }
62
+ $resultarray["data"][]=$result;
63
+ }
64
+
65
+
66
+ $url = 'http://176.9.111.205:8080/skoolshop_an/datafeed';
67
+
68
+ $vars = 'jsondoc=' .json_encode($resultarray) ;
69
+
70
+ $ch = curl_init($url);
71
+ curl_setopt($ch, CURLOPT_POST ,1);
72
+ curl_setopt($ch, CURLOPT_POSTFIELDS ,$vars);
73
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
74
+ curl_setopt($ch, CURLOPT_HEADER ,0);
75
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
76
+ $response = curl_exec($ch);
77
+
78
+ }
79
+
80
+
81
+ }
82
+
83
+ }
app/code/local/Unbxd/Datafeeder/etc/config.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Unbxd_Datafeeder>
6
+ <version>0.1.0</version>
7
+ </Unbxd_Datafeeder>
8
+ </modules>
9
+ <global>
10
+
11
+ <models>
12
+ <unbxd_datafeeder>
13
+ <class>Unbxd_Datafeeder_Model</class>
14
+ </unbxd_datafeeder>
15
+ </models>
16
+ </global>
17
+
18
+ <crontab>
19
+ <jobs>
20
+ <Unbxd_Datafeeder>
21
+ <schedule><cron_expr>1 1 1 1 1</cron_expr></schedule>
22
+ <run><model>unbxd_datafeeder/observer::feed</model></run>
23
+ </Unbxd_Datafeeder>
24
+ </jobs>
25
+ </crontab>
26
+ </config>
27
+
28
+
app/code/local/Unbxd/Datafeeder/etc/config.xml~ ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Unbxd_Datafeeder>
6
+ <version>0.1.0</version>
7
+ </Unbxd_Datafeeder>
8
+ </modules>
9
+ <global>
10
+
11
+ <models>
12
+ <unbxd_datafeeder>
13
+ <class>Unbxd_Datafeeder_Model</class>
14
+ </unbxd_datafeeder>
15
+ </models>
16
+ </global>
17
+
18
+ <crontab>
19
+ <jobs>
20
+ <Unbxd_Datafeeder>
21
+ <schedule><cron_expr>*/1 * * * *</cron_expr></schedule>
22
+ <run><model>unbxd_datafeeder/observer::feed</model></run>
23
+ </Unbxd_Datafeeder>
24
+ </jobs>
25
+ </crontab>
26
+ </config>
27
+
28
+
app/etc/modules/Unbxd_Datafeeder.xml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Unbxd_Datafeeder>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Unbxd_Datafeeder>
8
+
9
+
10
+ </modules>
11
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>unbxd_datafeeder</name>
4
+ <version>0.0.2</version>
5
+ <stability>stable</stability>
6
+ <license>commercial proprietary</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Uploads data</summary>
10
+ <description>uploads data</description>
11
+ <notes>alksdlka</notes>
12
+ <authors><author><name>unbxd</name><user>unbxd</user><email>ananthesh.adiga@gmail.com</email></author></authors>
13
+ <date>2012-07-16</date>
14
+ <time>02:23:51</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="Unbxd_Datafeeder.xml" hash="cf561ad820f281e52ddfbf97f2e474da"/></dir></target><target name="magelocal"><dir name="Unbxd"><dir name="Datafeeder"><dir name="Model"><file name="Observer.php" hash="173d53c5a562575a357bf28772c3f2ed"/><file name="Observer.php~" hash="173d53c5a562575a357bf28772c3f2ed"/></dir><dir name="etc"><file name="config.xml" hash="c42ff5f4933630d3f24daabfea535f31"/><file name="config.xml~" hash="62143db655a710b95c9cf80a1c589fa3"/></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.1.0</max></php></required></dependencies>
18
+ </package>