Kodecrm_Feed - Version 1.0.0

Version Notes

This is the first version of this module. If you found any bugs, then write to us at jimit@kodeplay.com

Download this release

Release Info

Developer Kodeplay
Extension Kodecrm_Feed
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Kodecrm/Feed/Helper/Data.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kodecrm_Feed_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ public function kodecrm_feed_create($feedarr) {
5
+ $feedarr = array(
6
+ 'channel' => $feedarr,
7
+ );
8
+ require_once ('Kodecrm/Feed/lib.php');
9
+ $dom = new XmlDomConstruct('1.0', 'utf-8');
10
+ $dom->fromMixed($feedarr);
11
+ $dom->formatOutput = true;
12
+ $feed = $dom->saveXML();
13
+ $feed = str_replace('<channel>','<rss version="2.0"><channel>', $feed);
14
+ $feed = str_replace('</channel>','</channel></rss>', $feed);
15
+ return $feed;
16
+ }
17
+
18
+ }
app/code/community/Kodecrm/Feed/controllers/IndexController.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Kodecrm_Feed_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction ()
5
+ {
6
+
7
+ if(Mage::getStoreConfig('chat_section/feed_group/status')) {
8
+
9
+ $collection = Mage::getModel('catalog/product')
10
+ ->getCollection()
11
+ ->addAttributeToSelect('*');
12
+
13
+ $store = Mage::app()->getStore();
14
+
15
+ $feedarr = array();
16
+ $feedarr['title'] = $store->getName();
17
+ $feedarr['link'] = $store->getUrl();
18
+ $feedarr['item'] = array();
19
+
20
+ $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
21
+
22
+ foreach ($collection as $product) {
23
+
24
+ $categories = array();
25
+ $cat_arr = $product->getCategoryCollection()->exportToArray();
26
+
27
+ foreach($cat_arr as $category) {
28
+ $categories[] = Mage::getModel('catalog/category')
29
+ ->load($category['entity_id'])->getName();
30
+ }
31
+
32
+ $feedarr['item'][] = array(
33
+ 'title' => $product->getName(),
34
+ 'brand' => $product->getAttributeText('manufacturer'),
35
+ 'description' => $product->getDescription(),
36
+ 'pid' => $product->getId(),
37
+ 'link' => ($product->getProductUrl()) ,
38
+ 'image_link' => $product->getImageUrl(),
39
+ 'price' => $product->getPrice(),
40
+ 'currency' => $currency,
41
+ 'availability' => (int) $product->isInStock(),
42
+ 'category' => $categories
43
+ );
44
+ }
45
+
46
+ $feed_helper = Mage::helper('feed');
47
+
48
+ $feed = $feed_helper->kodecrm_feed_create($feedarr);
49
+
50
+ echo $feed;
51
+ exit();
52
+ }
53
+
54
+ }
55
+ }
app/code/community/Kodecrm/Feed/etc/config.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <global>
4
+ <helpers>
5
+ <feed>
6
+ <class>Kodecrm_Feed_Helper</class>
7
+ </feed>
8
+ </helpers>
9
+ </global>
10
+ <modules>
11
+ <Kodecrm_Feed>
12
+ <version>1.0.0</version>
13
+ </Kodecrm_Feed>
14
+ </modules>
15
+ <frontend>
16
+ <routers>
17
+ <routeurfrontend>
18
+ <use>standard</use>
19
+ <args>
20
+ <module>Kodecrm_Feed</module>
21
+ <frontName>kodecrm</frontName>
22
+ </args>
23
+ </routeurfrontend>
24
+ </routers>
25
+ </frontend>
26
+ <default>
27
+ <chat_section>
28
+ <feed_group>
29
+ <url>http://{{base_url}}/index.php/kodecrm</url>
30
+ </feed_group>
31
+ </chat_section>
32
+ </default>
33
+
34
+ </config>
app/code/community/Kodecrm/Feed/etc/system.xml ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <config>
3
+ <tabs>
4
+ <chat_tab translate="label">
5
+ <label>Kodecrm</label>
6
+ <sort_order>100</sort_order>
7
+ </chat_tab>
8
+ </tabs>
9
+ <sections>
10
+
11
+ <chat_section translate="label">
12
+ <label>Setting</label>
13
+ <sort_order>200</sort_order>
14
+ <show_in_default>1</show_in_default>
15
+ <show_in_website>1</show_in_website>
16
+ <show_in_store>1</show_in_store>
17
+ <tab>chat_tab</tab>
18
+ <groups>
19
+
20
+ <feed_group translate="label">
21
+ <label>Feed Settings</label>
22
+ <comment>Kodecrm Feed Setting</comment>
23
+ <sort_order>10</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <fields>
28
+ <status translate="label comment">
29
+ <label>Feed Status Enabled</label>
30
+ <comment></comment>
31
+ <show_in_default>1</show_in_default>
32
+ <show_in_website>1</show_in_website>
33
+ <show_in_store>1</show_in_store>
34
+ <frontend_type>select</frontend_type>
35
+ <source_model>adminhtml/system_config_source_yesno</source_model>
36
+ </status>
37
+ <url translate="label comment">
38
+ <label>Feed Url</label>
39
+ <comment></comment>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ <backend_model>adminhtml/system_config_backend_baseurl</backend_model>
44
+ <frontend_type>textarea</frontend_type>
45
+ </url>
46
+ </fields>
47
+ </feed_group>
48
+ <!--
49
+ <chat_group translate="label"> <label> Chat Settings</label>
50
+ <comment>Chat Widget Settings</comment> <sort_order>10</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store> <fields> <app_id translate="label
54
+ comment"> <label>Application Id</label> <comment>Enter you
55
+ application id from Kodecrm admin</comment>
56
+ <show_in_default>1</show_in_default>
57
+ <show_in_website>1</show_in_website>
58
+ <show_in_store>1</show_in_store>
59
+ <frontend_input>text</frontend_input> </app_id> <custom
60
+ translate="label comment"> <label>Custom Settings</label>
61
+ <comment>you can find the custom settings in Kodecrm admin e.g.
62
+ color:#000;text:Chat with us;bg:0000099</comment>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>1</show_in_store>
66
+ <frontend_type>textarea</frontend_type> </custom> </fields>
67
+ </chat_group>
68
+ -->
69
+ </groups>
70
+ </chat_section>
71
+ </sections>
72
+ </config>
app/etc/modules/Kodecrm_all.xml ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version = "1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Kodecrm_Feed>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Kodecrm_Feed>
8
+ <Kodecrm_Chat>
9
+ <active>true</active>
10
+ <codePool>community</codePool>
11
+ </Kodecrm_Chat>
12
+ </modules>
13
+ <modules>
14
+ <Kodecrm_Chat>
15
+ <version>1.0.0</version>
16
+ <depends>
17
+ <!-- no dependencies -->
18
+ </depends>
19
+ </Kodecrm_Chat>
20
+ </modules>
21
+ <frontend>
22
+ <routers>
23
+ <route_chat>
24
+ <use>standard</use>
25
+ <args>
26
+ <module>Kodecrm_Chat</module>
27
+ <frontName>chat</frontName>
28
+ </args>
29
+ </route_chat>
30
+ </routers>
31
+ </frontend>
32
+ <adminhtml>
33
+ <acl>
34
+ <resources>
35
+ <admin>
36
+ <children>
37
+ <system>
38
+ <children>
39
+ <config>
40
+ <children>
41
+ <chat_section translate="title">
42
+ <title>My Section </title>
43
+ <sort_order>100</sort_order>
44
+ </chat_section>
45
+ </children>
46
+ </config>
47
+ </children>
48
+ </system>
49
+ </children>
50
+ </admin>
51
+ </resources>
52
+ </acl>
53
+ </adminhtml>
54
+ </config>
lib/Kodecrm/Feed/lib.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Extends the DOMDocument to implement personal (utility) methods.
5
+ * Code Borrowed from
6
+ * http://www.devexp.eu/2009/04/11/php-domdocument-convert-array-to-xml/
7
+ *
8
+ * Note! This class doesn't support attributes in Xml document
9
+ *
10
+ * @author Toni Van de Voorde
11
+ */
12
+ class XmlDomConstruct extends DOMDocument {
13
+
14
+ /**
15
+ * Constructs elements and texts from an array or string.
16
+ * The array can contain an element's name in the index part
17
+ * and an element's text in the value part.
18
+ *
19
+ * It can also creates an xml with the same element tagName on the same
20
+ * level.
21
+ *
22
+ * ex:
23
+ * <nodes>
24
+ * <node>text</node>
25
+ * <node>
26
+ * <field>hello</field>
27
+ * <field>world</field>
28
+ * </node>
29
+ * </nodes>
30
+ *
31
+ * Array should then look like:
32
+ *
33
+ * Array (
34
+ * "nodes" => Array (
35
+ * "node" => Array (
36
+ * 0 => "text"
37
+ * 1 => Array (
38
+ * "field" => Array (
39
+ * 0 => "hello"
40
+ * 1 => "world"
41
+ * )
42
+ * )
43
+ * )
44
+ * )
45
+ * )
46
+ *
47
+ * @param mixed $mixed An array or string.
48
+ *
49
+ * @param DOMElement[optional] $domElement Then element
50
+ * from where the array will be construct to.
51
+ *
52
+ */
53
+ public function fromMixed($mixed, DOMElement $domElement = null) {
54
+
55
+ $domElement = is_null($domElement) ? $this : $domElement;
56
+
57
+ if (is_array($mixed)) {
58
+ foreach( $mixed as $index => $mixedElement ) {
59
+ if ( is_int($index) ) {
60
+ if ( $index == 0 ) {
61
+ $node = $domElement;
62
+ } else {
63
+ $node = $this->createElement($domElement->tagName);
64
+ $domElement->parentNode->appendChild($node);
65
+ }
66
+ }
67
+
68
+ else {
69
+ $node = $this->createElement($index);
70
+ $domElement->appendChild($node);
71
+ }
72
+
73
+ $this->fromMixed($mixedElement, $node);
74
+
75
+ }
76
+ } else {
77
+ $domElement->appendChild($this->createTextNode($mixed));
78
+ }
79
+
80
+ }
81
+
82
+ }
83
+ ?>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Kodecrm_Feed</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>This package will create feed required for Kodecrm (www.kodecrm.com).</summary>
10
+ <description>This package will create feed required for Kodecrm (www.kodecrm.com).</description>
11
+ <notes>This is the first version of this module. If you found any bugs, then write to us at jimit@kodeplay.com</notes>
12
+ <authors><author><name>Kodeplay</name><user>kodeplay</user><email>info@kodeplay.com</email></author></authors>
13
+ <date>2012-08-08</date>
14
+ <time>14:21:51</time>
15
+ <contents><target name="magelib"><dir name="Kodecrm"><dir name="Feed"><file name="lib.php" hash="cede774dfc3f5aa2ee96fa023078e7dc"/></dir></dir></target><target name="magecommunity"><dir name="Kodecrm"><dir name="Feed"><dir name="Helper"><file name="Data.php" hash="483dd6193b345145bba6131ee1830e72"/></dir><dir name="controllers"><file name="IndexController.php" hash="b7f6eeebc2efae7544c4d449c4d657fe"/></dir><dir name="etc"><file name="config.xml" hash="28ddf789afd530af2a25f353da36b157"/><file name="system.xml" hash="2bc8f10143f207e0e0653385ea97d288"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Kodecrm_all.xml" hash="095e4281dc0000e388213a1bce27634f"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>