M2b - Version 0.1.3

Version Notes

Fix bugs

Download this release

Release Info

Developer Bnkle
Extension M2b
Version 0.1.3
Comparing to
See all releases


Version 0.1.3

app/code/community/Bnkle/BankleRssFeeds/Helper/Data.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+
5
+ class Bnkle_BankleRssFeeds_Helper_Data extends Mage_Core_Helper_Abstract {
6
+
7
+
8
+
9
+ }
10
+
11
+
12
+
13
+ ?>
app/code/community/Bnkle/BankleRssFeeds/Helper/SimpleXml.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+
5
+ class Bnkle_BankleRssFeeds_Helper_SimpleXml extends SimpleXMLElement {
6
+
7
+
8
+
9
+ public function addCData($nodename,$cdata_text) {
10
+
11
+ $node = $this->addChild($nodename);
12
+
13
+ $node = dom_import_simplexml($node);
14
+
15
+ $no = $node->ownerDocument;
16
+
17
+ $node->appendChild($no->createCDATASection($cdata_text));
18
+
19
+ }
20
+
21
+
22
+
23
+ }
24
+
25
+
26
+
27
+ ?>
app/code/community/Bnkle/BankleRssFeeds/controllers/IndexController.php ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Bnkle
4
+ *
5
+ */
6
+ class Bnkle_BankleRssFeeds_IndexController extends Mage_Core_Controller_Front_Action {
7
+ private $oProducts;
8
+ private $oProdudctIds;
9
+ private $sBaseXml = '<?xml version="1.0" encoding="UTF-8"?><products></products>';
10
+ private $sProductElement = 'product';
11
+ private $oFeed;
12
+ private $oXml;
13
+ private $oConfig;
14
+ private $oProductModel;
15
+ private $aBadChars = array('"',"\r\n","\n","\r","\t");
16
+ private $aReplaceChars = array(""," "," "," ","");
17
+ private $aConfigPaths = array ( 'bnklerssfeeds/general/enabled',
18
+ 'bnklerssfeeds/general/urlparam',
19
+ 'bnklerssfeeds/general/imgsmall_width',
20
+ 'bnklerssfeeds/general/imgsmall_height',
21
+ 'bnklerssfeeds/general/imgmedium_width',
22
+ 'bnklerssfeeds/general/imgmedium_height'
23
+ );
24
+
25
+ private $aDataMap = array( 'internal_id' => 'id',
26
+ 'title' => 'title',
27
+ 'description' => 'description',
28
+ 'img_large' => 'image_link_large',
29
+ 'img_medium' => 'image_link_medium',
30
+ 'img_small' => 'image_link_small',
31
+ 'link' => 'link',
32
+ 'minimum_price' => 'special_price',
33
+ 'maximum_price' => 'price',
34
+ 'category' => 'category',
35
+ 'sub_category' => 'subcategory',
36
+ 'images' => 'media_gallery');
37
+
38
+ public function indexAction() {
39
+ set_time_limit(3600);
40
+ $this->setConfig();
41
+ if($this->oConfig->general->enabled == 1) {
42
+ $this->initFeed();
43
+ $this->getProducts();
44
+ foreach($this->oProdudctIds as $iProduct) {
45
+ $this->addToFeed($iProduct);
46
+ }
47
+ $this->sendHeader();
48
+ $this->getXml();
49
+ }
50
+ }
51
+
52
+ private function setConfig() {
53
+ $this->oConfig = new StdClass();
54
+ foreach($this->aConfigPaths as $sPath) {
55
+ $aParts = explode('/',$sPath);
56
+ @$this->oConfig->$aParts[1]->$aParts[2] = Mage::getStoreConfig($sPath);
57
+ }
58
+
59
+ if(!is_numeric($this->oConfig->general->imgsmall_width)) {
60
+ $this->oConfig->general->imgsmall_width = 150;
61
+ }
62
+ if(!is_numeric($this->oConfig->general->imgsmall_height)) {
63
+ $this->oConfig->general->imgsmall_height = 150;
64
+ }
65
+ if(!is_numeric($this->oConfig->general->imgmedium_width)) {
66
+ $this->oConfig->general->imgmedium_width = 320;
67
+ }
68
+
69
+ if(!is_numeric($this->oConfig->general->imgmedium_height)) {
70
+ $this->oConfig->general->imgmedium_height = 320;
71
+ }
72
+ }
73
+
74
+ private function initFeed() {
75
+ $this->oFeed = new Bnkle_BankleRssFeeds_Helper_SimpleXml($this->sBaseXml);
76
+ }
77
+
78
+ private function getProducts() {
79
+ $this->oProducts = Mage::getModel('catalog/product')->getCollection();
80
+ $this->oProducts->addAttributeToFilter('status', 1);//enabled
81
+ $this->oProducts->addAttributeToFilter('visibility', 4);//catalog, search
82
+ $this->oProducts->addAttributeToSelect('*');
83
+ $this->oProdudctIds = $this->oProducts->getAllIds();
84
+ }
85
+
86
+ private function addToFeed($iProduct) {
87
+ $aData = $this->getSanitized($this->getProductData($iProduct));
88
+
89
+ $oFeedProduct = $this->oFeed->addChild($this->sProductElement);
90
+ $this->addDataToFeedProduct($aData,$oFeedProduct);
91
+ }
92
+
93
+ private function addDataToFeedProduct($aData,$oFeedProduct) {
94
+ foreach($this->aDataMap as $sTarget => $sSource) {
95
+ if($sSource == 'link' && $this->oConfig->general->urlparam != '') {
96
+ $aData[$sSource] = $this->addUrlParam($aData[$sSource]);
97
+ }
98
+ $oFeedProduct->addCData($sTarget,$aData[$sSource]);
99
+ }
100
+ }
101
+
102
+ private function addUrlParam($sUrl) {
103
+ if(!strstr($sUrl,'?')) {
104
+ $sUrl .= '?'.str_replace('?','',$this->oConfig->general->urlparam);
105
+ } else {
106
+ $sUrl .= '&'.str_replace('?','',$this->oConfig->general->urlparam);
107
+ }
108
+
109
+ return $sUrl;
110
+ }
111
+
112
+ private function getSanitized($aData) {
113
+ $aSanitized = array();
114
+ foreach($aData as $k=>$val){
115
+ $aSanitized[$k] = str_replace($this->aBadChars,$this->aReplaceChars,$val);
116
+ }
117
+
118
+ return $aSanitized;
119
+ }
120
+
121
+ private function getProductData($iProduct) {
122
+ $oProduct = Mage::getModel('catalog/product');
123
+ $oProduct ->load($iProduct);
124
+ //echo '<pre>';
125
+ //print_r($oProduct); die;
126
+
127
+ $aCats = $this->getCategories($oProduct);
128
+ $aData = array();
129
+ $aData['id']=$iProduct;
130
+ $aData['sku']=$oProduct->getSku();
131
+ $aData['brand']=$oProduct->getResource()->getAttribute('manufacturer')->getFrontend()->getValue($oProduct);
132
+ $aData['title']=$oProduct->getName();
133
+ $aData['description']=strip_tags($oProduct->getDescription());
134
+ $aData['price']=$oProduct->getPrice();
135
+ $aData['special_price']=$oProduct->getSpecialPrice();
136
+ $aData['availability']='yes';
137
+ $aData['condition']='';
138
+ $aData['link']=$oProduct->getProductUrl();
139
+
140
+
141
+
142
+
143
+ $aData['image_link_large']= Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$oProduct->getImage();
144
+
145
+ $aData['stock_descrip']='';
146
+ $aData['shipping_rate']='';
147
+ $aData['category'] = $aCats['main'];
148
+ $aData['subcategory'] = $aCats['sub'];
149
+
150
+ if($aData['special_price'] == '') {
151
+ $aData['special_price'] = $aData['price'];
152
+ }
153
+
154
+ $imagesArray = $oProduct->getMediaGallery();
155
+ $imagesArray1 = $imagesArray['images'];
156
+
157
+
158
+ for($i=0;isset($imagesArray1[$i]);$i++)
159
+ {
160
+ $imagesNEwArr[] = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'catalog/product'.$imagesArray1[$i]['file'];
161
+ }
162
+ //$aData['media_gallery'] = $imagesNEwArr;
163
+
164
+ $aData['media_gallery'] = implode('@@',$imagesNEwArr);
165
+
166
+
167
+ return $aData;
168
+ }
169
+
170
+ private function getCategories($oProduct) {
171
+ $aIds = $oProduct->getCategoryIds();
172
+ $aCategories = array();
173
+
174
+ foreach($aIds as $iCategory){
175
+ $oCategory = Mage::getModel('catalog/category')->load($iCategory);
176
+ // echo $oCategory->getId();die;
177
+ //$newCats[] = $oCategory->getName();
178
+ switch($oCategory->getLevel()) {
179
+ case '1':
180
+ //$aCategories['main'] = $oCategory->getName();
181
+ $ID = $oCategory->getId();
182
+ $Name = $oCategory->getName();
183
+ $newCats[] = $ID.'@@'.$Name;
184
+ case '2':
185
+ //$aCategories['main'][] = $oCategory->getName();
186
+ break;
187
+ case '3':
188
+ //$aCategories['sub'] = $oCategory->getName();
189
+ break;
190
+ }
191
+ }
192
+
193
+ $aCategories['main'] = implode('#',$newCats);
194
+ return $aCategories;
195
+ }
196
+
197
+ private function sendHeader() {
198
+ header('Content-type: text/xml');
199
+ }
200
+
201
+ private function getXml() {
202
+ $oXml = new DOMDocument('1.0');
203
+ $oXml->formatOutput = true;
204
+ $oNode = dom_import_simplexml($this->oFeed);
205
+ $oNode = $oXml->importNode($oNode, true);
206
+ $oNode = $oXml->appendChild($oNode);
207
+ echo $oXml->saveXML();
208
+ }
209
+
210
+ private function debug($m) {
211
+ echo '<pre>';
212
+ print_r($m);
213
+ echo '</pre>';
214
+ }
215
+
216
+ }
217
+
app/code/community/Bnkle/BankleRssFeeds/etc/adminhtml.xml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <config>
4
+
5
+ <acl>
6
+
7
+ <resources>
8
+
9
+ <admin>
10
+
11
+ <children>
12
+
13
+ <system>
14
+
15
+ <children>
16
+
17
+ <config>
18
+
19
+ <children>
20
+
21
+ <bnklerssfeeds translate="title" module="bnklerssfeeds">
22
+
23
+ <title>Bnkle Product Feed</title>
24
+
25
+ </bnklerssfeeds>
26
+
27
+ </children>
28
+
29
+ </config>
30
+
31
+ </children>
32
+
33
+ </system>
34
+
35
+ </children>
36
+
37
+ </admin>
38
+
39
+ </resources>
40
+
41
+ </acl>
42
+
43
+ </config>
app/code/community/Bnkle/BankleRssFeeds/etc/config.xml ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+
5
+ <modules>
6
+
7
+ <Bnkle_BankleRssFeeds>
8
+
9
+ <version>0.1.6</version>
10
+
11
+ </Bnkle_BankleRssFeeds>
12
+
13
+ </modules>
14
+
15
+ <frontend>
16
+
17
+ <routers>
18
+
19
+ <bnklerssfeeds>
20
+
21
+ <use>standard</use>
22
+
23
+ <args>
24
+
25
+ <module>Bnkle_BankleRssFeeds</module>
26
+
27
+ <frontName>bnklerssfeeds</frontName>
28
+
29
+ </args>
30
+
31
+ </bnklerssfeeds>
32
+
33
+ </routers>
34
+
35
+ </frontend>
36
+
37
+
38
+
39
+ <global>
40
+
41
+ <models>
42
+
43
+ <bnklerssfeeds>
44
+
45
+ <class>Bnkle_BankleRssFeeds_Model</class>
46
+
47
+ </bnklerssfeeds>
48
+
49
+ </models>
50
+
51
+ <blocks>
52
+
53
+ <bnklerssfeeds>
54
+
55
+ <class>Bnkle_BankleRssFeeds_Block</class>
56
+
57
+ </bnklerssfeeds>
58
+
59
+ </blocks>
60
+
61
+ <helpers>
62
+
63
+ <bnklerssfeeds>
64
+
65
+ <class>Bnkle_BankleRssFeeds_Helper</class>
66
+
67
+ </bnklerssfeeds>
68
+
69
+ </helpers>
70
+
71
+
72
+
73
+
74
+
75
+ </global>
76
+
77
+ <default>
78
+
79
+ <general>
80
+
81
+ <bnklerssfeeds>
82
+
83
+ <enabled>1</enabled>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+ </bnklerssfeeds>
94
+
95
+ </general>
96
+
97
+ </default>
98
+
99
+ </config>
100
+
app/code/community/Bnkle/BankleRssFeeds/etc/system.xml ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <config>
4
+
5
+ <tabs>
6
+
7
+ <bnkle>
8
+
9
+ <label>Bnkle</label>
10
+
11
+ <sort_order>195</sort_order>
12
+
13
+ </bnkle>
14
+
15
+ </tabs>
16
+
17
+
18
+
19
+ <sections>
20
+
21
+ <bnklerssfeeds translate="label" module="bnklerssfeeds">
22
+
23
+ <label>Bnkle Product Feed</label>
24
+
25
+ <tab>bnkle</tab>
26
+
27
+ <frontend_type>text</frontend_type>
28
+
29
+ <sort_order>71</sort_order>
30
+
31
+ <show_in_default>1</show_in_default>
32
+
33
+ <show_in_website>1</show_in_website>
34
+
35
+ <show_in_store>1</show_in_store>
36
+
37
+ <groups>
38
+
39
+ <general translate="label">
40
+
41
+ <label>General</label>
42
+
43
+ <sort_order>600</sort_order>
44
+
45
+ <show_in_default>1</show_in_default>
46
+
47
+ <show_in_website>1</show_in_website>
48
+
49
+ <show_in_store>1</show_in_store>
50
+
51
+ <fields>
52
+
53
+ <enabled translate="label">
54
+
55
+ <label>Enabled</label>
56
+
57
+ <frontend_type>select</frontend_type>
58
+
59
+ <comment><![CDATA[ When enabled you can access the feed by poiting your browser to http://yourdomain.com/bnklerssfeeds ]]></comment>
60
+
61
+ <source_model>adminhtml/system_config_source_yesno</source_model>
62
+
63
+ <sort_order>10</sort_order>
64
+
65
+ <show_in_default>1</show_in_default>
66
+
67
+ <show_in_website>1</show_in_website>
68
+
69
+ <show_in_store>1</show_in_store>
70
+
71
+ </enabled>
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ </fields>
80
+
81
+ </general>
82
+
83
+ </groups>
84
+
85
+ </bnklerssfeeds>
86
+
87
+ </sections>
88
+
89
+ </config>
app/etc/modules/Bnkle_BankleRssFeeds.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Bnkle_BankleRssFeeds>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Bnkle_BankleRssFeeds>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>M2b</name>
4
+ <version>0.1.3</version>
5
+ <stability>stable</stability>
6
+ <license>Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>bnkle-Magento integration. Auto link your bricks &amp;amp; mortar inventory to bnkle and get more customers in store.</summary>
10
+ <description>bnkle.com - let's customers search and see what's available in brick &amp;amp; mortar stores around them.&#xD;
11
+ &#xD;
12
+ The official M2b extension allows you to show the Magento store products that are in your bricks and mortar stores to customers searching with bnkle.com&#xD;
13
+ &#xD;
14
+ M2b extension features&#xD;
15
+ &#xD;
16
+ Auto sync inventory: Your Magento store inventory is auto synced to your free bnkle account. inc:&#xD;
17
+ &#xD;
18
+ - Product title&#xD;
19
+ &#xD;
20
+ - Product description&#xD;
21
+ &#xD;
22
+ - Pricing - Search tags&#xD;
23
+ &#xD;
24
+ - Images - Options (color,size, etc)&#xD;
25
+ &#xD;
26
+ - Magento product url (users click through for direct purchase - free site traffic)&#xD;
27
+ &#xD;
28
+ - Stock levels (inventory is auto refreshed daily)&#xD;
29
+ &#xD;
30
+ These features allow quick and simple creation as well as management of product listings on bnkle. Significantly reduce time required for listing maintenance.&#xD;
31
+ &#xD;
32
+ &#xD;
33
+ &#xD;
34
+ Other functions on your free bnkle.com dashboard&#xD;
35
+ &#xD;
36
+ &#xD;
37
+ &#xD;
38
+ Product controls&#xD;
39
+ &#xD;
40
+ - Control which of your Magento store categories you want to be searchable on bnkle&#xD;
41
+ &#xD;
42
+ - Control which of your Magento store products you want to be searchable on bnkle&#xD;
43
+ &#xD;
44
+ &#xD;
45
+ &#xD;
46
+ Multiple store locations&#xD;
47
+ &#xD;
48
+ &#x2013; identify all your store locations and match listings to the locations&#xD;
49
+ &#xD;
50
+ &#xD;
51
+ &#xD;
52
+ Analytics&#xD;
53
+ &#xD;
54
+ - see how individual products are performing&#xD;
55
+ &#xD;
56
+ - see which stores are performing best, by product, by store&#xD;
57
+ &#xD;
58
+ - see which products are being clicked through to your Magento store&#xD;
59
+ &#xD;
60
+ &#xD;
61
+ &#xD;
62
+ Traffic flow - Control how many product views you will get each month&#xD;
63
+ &#xD;
64
+ - Free flow: 1,000 free product views per month&#xD;
65
+ &#xD;
66
+ - Smooth flow: @65 cents per 1,000 views Set a monthly spend that is evenly spread&#xD;
67
+ &#xD;
68
+ - Rush hour: Set a monthly budget to run in response to search demand&#xD;
69
+ &#xD;
70
+ &#xD;
71
+ Visit bnkle.com/sellers to create your free account</description>
72
+ <notes>Fix bugs</notes>
73
+ <authors><author><name>Bnkle</name><user>Bnkle</user><email>andrew@bnkle.com</email></author></authors>
74
+ <date>2015-07-29</date>
75
+ <time>07:18:44</time>
76
+ <contents><target name="mageetc"><dir name="modules"><file name="Bnkle_BankleRssFeeds.xml" hash="0ce0d4c8ab53f85c81d8269b5b6bec41"/></dir></target><target name="magecommunity"><dir name="Bnkle"><dir name="BankleRssFeeds"><dir name="controllers"><file name="IndexController.php" hash="fedb59894c770a7f171e6863828e1c64"/></dir><dir name="etc"><file name="adminhtml.xml" hash="9b521ec7bcb55702b56dd8f24dd1b097"/><file name="config.xml" hash="aad552b071d0d18b9a913e645bf5baca"/><file name="system.xml" hash="98b051f041edf0221529eb5af85f9bb2"/></dir><dir name="Helper"><file name="Data.php" hash="e6a5bc301751b838fb31923975ed6319"/><file name="SimpleXml.php" hash="8930c16e7cc05542a819cd9f63472b4c"/></dir></dir></dir></target></contents>
77
+ <compatible/>
78
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
79
+ </package>