EasyStoreview - Version 1.0.0

Version Notes

Initial functionality of creating storeview is done in this module

Download this release

Release Info

Developer madhumala krishnan
Extension EasyStoreview
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Ameex/EasyStorecreation/Helper/Data.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Ameex_EasyStorecreation_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ }
app/code/community/Ameex/EasyStorecreation/Model/Blockvalue.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ameex_EasyStorecreation_Model_Blockvalue
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value'=>3, 'label'=>Mage::helper('easystorecreation')->__('No')),
8
+ array('value'=>4, 'label'=>Mage::helper('easystorecreation')->__('Yes')));
9
+
10
+ }
11
+ }
app/code/community/Ameex/EasyStorecreation/Model/Newvalue.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ameex_EasyStorecreation_Model_Newvalue
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value'=>1, 'label'=>Mage::helper('easystorecreation')->__('No')),
8
+ array('value'=>2, 'label'=>Mage::helper('easystorecreation')->__('Yes')));
9
+
10
+ }
11
+ }
app/code/community/Ameex/EasyStorecreation/Model/Observer.php ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ameex_EasyStorecreation_Model_Observer
3
+ {
4
+ public function handle_adminSystemConfigChangedSection(Varien_Event_Observer $observer)
5
+ {
6
+
7
+ $allStores = Mage::app()->getStores();
8
+ foreach ($allStores as $_eachStoreId => $val)
9
+ {
10
+ $_storeCode[] = Mage::app()->getStore($_eachStoreId)->getCode();
11
+ }
12
+ $postData = Mage::app()->getRequest()->getPost();
13
+ $string = $postData['groups']['configure']['fields'];
14
+ foreach ($string as $str)
15
+ {
16
+ foreach ($str as $keyvalues => $valuelabel)
17
+ {
18
+ $stringvalue=$valuelabel;
19
+ }
20
+ }
21
+ $urls=$stringvalue;
22
+ $languageoptions=Mage::app()->getLocale()->getOptionLocales();
23
+ foreach($languageoptions as $languageoption)
24
+ {
25
+ $value[]=$languageoption[value];
26
+ $label[]=$languageoption[label];
27
+
28
+ }
29
+ $languagecombined=array_combine($value,$label);
30
+ foreach ($urls as $url)
31
+ {
32
+ $url = explode(" ",$url);
33
+ $urls=array_flip($url);
34
+ $new[]=array_intersect_key($languagecombined,$urls);
35
+ }
36
+ $newscode=array();
37
+ foreach ($new as $newcode){
38
+ $newcode[key($newcode)]=current($newcode);
39
+ $lab[]=array_keys($newcode);
40
+ $labvalue=array_values($newcode);
41
+ $label=implode($labvalue); // here we get the locale with country code
42
+ $string = preg_replace('/[(,)]/', '', $label); //removing the bracket in the country name
43
+ $newtexts=str_replace(' ', '_', $string); //replacing the locale with country name
44
+ $newlabel[]=strtolower($newtexts); //converting the label to lowercase and assigning these value as a store name and code
45
+ }
46
+ foreach ($newlabel as $keys=>$newsite){
47
+ if(!in_array($newsite,$_storeCode))
48
+ {
49
+ $store = Mage::getModel('core/store'); //this section creates the storeview
50
+ $store->setCode($newsite)
51
+ ->setWebsiteId(1)
52
+ ->setGroupId(1)
53
+ ->setName($newsite)
54
+ ->setIsActive(1)
55
+ ->save();
56
+ $newval = $lab[$keys];
57
+ $newvals=implode($newval);
58
+ $store->load('store_code','code');
59
+ $storeId=$store->getStoreId();
60
+ Mage::getModel('core/config')->saveConfig('general/locale/code',$newvals,'stores',$storeId); //this assign locale to storeview
61
+ }
62
+ }
63
+ }
64
+ public function handleproducts_adminSystemConfigChangedSection(Varien_Event_Observer $observer){
65
+ $all = Mage::app()->getWebsites();
66
+ foreach ($all as $eachStoreId => $vals)
67
+ {
68
+ $storeCode[]= Mage::app()->getWebsite($eachStoreId)->getId();
69
+
70
+ }
71
+ $post = Mage::app()->getRequest()->getPost();
72
+ $selectval= $post['groups']['productsconfigure']['fields'];
73
+ foreach ($selectval as $selectedval)
74
+ {
75
+ foreach ($selectedval as $keyselect => $valueselect)
76
+ {
77
+ $selectedlabels[]=$valueselect;
78
+ }
79
+ }
80
+ if(in_array(1,$selectedlabels)){
81
+ $productIds= Mage::getResourceModel('catalog/product_collection')->getAllIds();
82
+ Mage::getModel('catalog/product_website')->addProducts($storeCode, $productIds); //this section for assigning all the products to main website
83
+ }
84
+ }
85
+ public function handlecms_adminSystemConfigChangedSection(Varien_Event_Observer $observer){
86
+ $allStores = Mage::app()->getStores();
87
+ foreach ($allStores as $_eachStoreId => $val)
88
+ {
89
+ $_storeCode[] = Mage::app()->getStore($_eachStoreId)->getId();
90
+ }
91
+ $storefirst=$_storeCode[0];
92
+ $postcms = Mage::app()->getRequest()->getPost();
93
+ $cmsval= $postcms['groups']['cmsconfigure']['fields'];
94
+ foreach ($cmsval as $selectedcms)
95
+ {
96
+ foreach ($selectedcms as $cmsselect => $valuecms)
97
+ {
98
+ $cmsoption[]=$valuecms;
99
+ }
100
+ }
101
+ if(in_array(2,$cmsoption)){
102
+ $cms_pages = Mage::getModel('cms/page')->getCollection()->load(); //this section for assigning cms pages
103
+ foreach($cms_pages as $_page)
104
+ {
105
+ $data = $_page->getData();
106
+ $url[]=$data['identifier'];
107
+ }
108
+ foreach ($url as $identifier){
109
+ Mage::getModel('cms/page')->load($identifier)
110
+ ->setData('stores', 0) //array(0) represents all storeview
111
+ ->save();
112
+ }
113
+ }
114
+ if(in_array(1,$cmsoption)){
115
+ $cms_pages = Mage::getModel('cms/page')->getCollection()->load();
116
+ foreach($cms_pages as $_page)
117
+ {
118
+ $data = $_page->getData();
119
+ $url[]=$data['identifier'];
120
+ }
121
+ foreach ($url as $identifier){
122
+ Mage::getModel('cms/page')->load($identifier)
123
+ ->setData('stores',$storefirst) //array (1) represents default storeview
124
+ ->save();
125
+ }
126
+ }
127
+ if(in_array(4,$cmsoption)){
128
+ $cms_blocks = Mage::getModel('cms/block')->getCollection()->load(); //this section for assigning cms blocks
129
+ foreach($cms_blocks as $_block)
130
+ {
131
+ $data = $_block->getData();
132
+ $urls[]=$data['identifier'];
133
+ }
134
+ foreach ($urls as $identifiers)
135
+ {
136
+ Mage::getModel('cms/block')->load($identifiers)
137
+ ->setData('stores', 0)
138
+ ->save();
139
+ }
140
+ }
141
+ if(in_array(3,$cmsoption)){
142
+ $cms_blocks = Mage::getModel('cms/block')->getCollection()->load();
143
+ foreach($cms_blocks as $_block)
144
+ {
145
+ $data = $_block->getData();
146
+ $urls[]=$data['identifier'];
147
+ }
148
+ foreach ($urls as $identifiers)
149
+ {
150
+ Mage::getModel('cms/block')->load($identifiers)
151
+ ->setData('stores', $storefirst)
152
+ ->save();
153
+ }
154
+ }
155
+ }
156
+ }
app/code/community/Ameex/EasyStorecreation/Model/Value.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ameex_EasyStorecreation_Model_Value
3
+ {
4
+ public function toOptionArray()
5
+ {
6
+ return array(
7
+ array('value'=>1, 'label'=>Mage::helper('easystorecreation')->__('Yes')),
8
+ array('value'=>2, 'label'=>Mage::helper('easystorecreation')->__('No')));
9
+
10
+ }
11
+ }
app/code/community/Ameex/EasyStorecreation/controllers/IndexController.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Ameex_EasyStorecreation_IndexController extends Mage_Core_Controller_Front_Action{
3
+ public function indexAction(){
4
+ $this->loadLayout();
5
+ $this->renderLayout();
6
+ $allStores = Mage::app()->getStores();
7
+ foreach ($allStores as $_eachStoreId => $val)
8
+ {
9
+ $_storeCode[] = Mage::app()->getStore($_eachStoreId)->getId();
10
+ }
11
+ print_r($_storeCode[0]);
12
+ }
13
+
14
+ }
app/code/community/Ameex/EasyStorecreation/etc/config.xml ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Ameex_EasyStorecreation>
5
+ <version>1.0.0</version>
6
+ </Ameex_EasyStorecreation>
7
+ </modules>
8
+ <frontend>
9
+ <routers>
10
+ <easystorecreation>
11
+ <use>standard</use>
12
+ <args>
13
+ <module>Ameex_EasyStorecreation</module>
14
+ <frontName>easystorecreation</frontName>
15
+ </args>
16
+ </easystorecreation>
17
+ </routers>
18
+ </frontend>
19
+ <global>
20
+ <events>
21
+ <admin_system_config_changed_section_easystorecreation_options>
22
+ <observers>
23
+ <easystorecreation>
24
+ <type>singleton</type>
25
+ <class>Ameex_EasyStorecreation_Model_Observer</class>
26
+ <method>handle_adminSystemConfigChangedSection</method>
27
+ </easystorecreation>
28
+ </observers>
29
+ </admin_system_config_changed_section_easystorecreation_options>
30
+ <admin_system_config_changed_section_easystorecreation_products>
31
+ <observers>
32
+ <easystorecreationproducts>
33
+ <type>singleton</type>
34
+ <class>Ameex_EasyStorecreation_Model_Observer</class>
35
+ <method>handleproducts_adminSystemConfigChangedSection</method>
36
+ </easystorecreationproducts>
37
+ </observers>
38
+ </admin_system_config_changed_section_easystorecreation_products>
39
+ <admin_system_config_changed_section_easystorecreation_cms>
40
+ <observers>
41
+ <easystorecreation_cms>
42
+ <type>singleton</type>
43
+ <class>Ameex_EasyStorecreation_Model_Observer</class>
44
+ <method>handlecms_adminSystemConfigChangedSection</method>
45
+ </easystorecreation_cms>
46
+ </observers>
47
+ </admin_system_config_changed_section_easystorecreation_cms>
48
+ </events>
49
+ <blocks>
50
+ <easystorecreation>
51
+ <class>Ameex_EasyStorecreation_Block</class>
52
+ </easystorecreation>
53
+ </blocks>
54
+ <helpers>
55
+ <easystorecreation>
56
+ <class>Ameex_EasyStorecreation_Helper</class>
57
+ </easystorecreation>
58
+ </helpers>
59
+ <models>
60
+ <easystorecreation>
61
+ <class>Ameex_EasyStorecreation_Model</class>
62
+ </easystorecreation>
63
+ </models>
64
+ </global>
65
+ <adminhtml>
66
+ <acl>
67
+ <resources>
68
+ <admin>
69
+ <children>
70
+ <system>
71
+ <children>
72
+ <config>
73
+ <children>
74
+ <easystorecreation_options>
75
+ <title>EasyStorecreation Configuration</title>
76
+ </easystorecreation_options>
77
+ <easystorecreation_products>
78
+ <title>EasyStorecreation Configuration</title>
79
+ </easystorecreation_products>
80
+ <easystorecreation_cms>
81
+ <title>EasyStorecreation Configuration</title>
82
+ </easystorecreation_cms>
83
+ </children>
84
+ </config>
85
+ </children>
86
+ </system>
87
+ </children>
88
+ </admin>
89
+ </resources>
90
+ </acl>
91
+ </adminhtml>
92
+ </config>
app/code/community/Ameex/EasyStorecreation/etc/system.xml ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <easystorecreation translate="label" module="easystorecreation">
5
+ <sort_order>1</sort_order>
6
+ <label>EasyStorecreation configuration</label>
7
+ </easystorecreation>
8
+ </tabs>
9
+ <sections>
10
+ <easystorecreation_options translate="label" module="easystorecreation">
11
+ <label>Settings for storeview</label>
12
+ <tab>easystorecreation</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>1</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <configure translate="label">
20
+ <label>Configure the settings</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>1</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <storeviewoptions>
28
+ <label>Choose the storeview you want to create</label>
29
+ <frontend_type>multiselect</frontend_type>
30
+ <sort_order>1</sort_order>
31
+ <source_model>adminhtml/system_config_source_locale</source_model>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </storeviewoptions>
36
+ </fields>
37
+
38
+ </configure>
39
+ </groups>
40
+ </easystorecreation_options>
41
+ <easystorecreation_products translate="label" module="easystorecreation">
42
+ <label>Products Assignment</label>
43
+ <tab>easystorecreation</tab>
44
+ <frontend_type>text</frontend_type>
45
+ <sort_order>2</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>1</show_in_store>
49
+ <groups>
50
+ <productsconfigure translate="label">
51
+ <label>Products Assignment setting</label>
52
+ <frontend_type>text</frontend_type>
53
+ <sort_order>1</sort_order>
54
+ <show_in_default>1</show_in_default>
55
+ <show_in_website>1</show_in_website>
56
+ <show_in_store>1</show_in_store>
57
+ <fields>
58
+ <storeviewproducts>
59
+ <label>Do you want to assign all the products</label>
60
+ <frontend_type>select</frontend_type>
61
+ <sort_order>110</sort_order>
62
+ <source_model>easystorecreation/value</source_model>
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
+ </storeviewproducts>
67
+ </fields>
68
+ </productsconfigure>
69
+ </groups>
70
+ </easystorecreation_products>
71
+ <easystorecreation_cms translate="label" module="easystorecreation">
72
+ <label>CMS Assignment</label>
73
+ <tab>easystorecreation</tab>
74
+ <frontend_type>text</frontend_type>
75
+ <sort_order>3</sort_order>
76
+ <show_in_default>1</show_in_default>
77
+ <show_in_website>1</show_in_website>
78
+ <show_in_store>1</show_in_store>
79
+ <groups>
80
+ <cmsconfigure translate="label">
81
+ <label>Cms assignment setting</label>
82
+ <frontend_type>text</frontend_type>
83
+ <sort_order>1</sort_order>
84
+ <show_in_default>1</show_in_default>
85
+ <show_in_website>1</show_in_website>
86
+ <show_in_store>1</show_in_store>
87
+ <fields>
88
+ <storeviewcmspage>
89
+ <label>Do you want to assign all the cms pages for all storeview</label>
90
+ <frontend_type>select</frontend_type>
91
+ <sort_order>110</sort_order>
92
+ <source_model>easystorecreation/newvalue</source_model>
93
+ <show_in_default>1</show_in_default>
94
+ <show_in_website>1</show_in_website>
95
+ <show_in_store>1</show_in_store>
96
+ </storeviewcmspage>
97
+ </fields>
98
+ <fields>
99
+ <storeviewcmsblock>
100
+ <label>Do you want to assign all the cms blocks for all storeview</label>
101
+ <frontend_type>select</frontend_type>
102
+ <sort_order>110</sort_order>
103
+ <source_model>easystorecreation/blockvalue</source_model>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>1</show_in_website>
106
+ <show_in_store>1</show_in_store>
107
+ </storeviewcmsblock>
108
+ </fields>
109
+ </cmsconfigure>
110
+ </groups>
111
+ </easystorecreation_cms>
112
+ </sections>
113
+ </config>
app/etc/modules/Ameex_EasyStorecreation.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Ameex_EasyStorecreation>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Ameex_EasyStorecreation>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>EasyStoreview</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license>Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Easystoreview creation module is used to create storeview in a single step, and assigns locale to the created storeview.It also assigns all products,cms pages and blocks to all created storeview</summary>
10
+ <description>Easy storeview creation module is used in multistoreview creation.First step is creating storeview by selecting country in dropdown that appears in admin. It also assigns locale to the created storeview.&#xD;
11
+ Second step is it assigns all products to main website on selecting yes in the products assignment section.Third step is it assigns cms pages and cms blocks to all storeview on selecting "yes". And on selecting "no" it assigns to default storeview</description>
12
+ <notes>Initial functionality of creating storeview is done in this module</notes>
13
+ <authors><author><name>madhumala krishnan</name><user>madhumala</user><email>madhujerlin@gmail.com</email></author></authors>
14
+ <date>2015-08-06</date>
15
+ <time>07:38:38</time>
16
+ <contents><target name="mageetc"><dir><dir name="modules"><file name="Ameex_EasyStorecreation.xml" hash="e0d640907522cf85ab7498fe21cccde6"/></dir></dir></target><target name="magecommunity"><dir><dir name="Ameex"><dir name="EasyStorecreation"><dir><dir name="Helper"><file name="Data.php" hash="80fd48c18c5b321ae085200eaad2635c"/></dir><dir name="Model"><file name="Blockvalue.php" hash="0c15c4704417de907a979dab329edc9a"/><file name="Newvalue.php" hash="87076e0ac8d8f1b60b8888861ab9b504"/><file name="Observer.php" hash="19f1721c5c137c51d70e6300c1b22387"/><file name="Value.php" hash="bdd5ef3d617aa4576ee65475d1ea357c"/></dir><dir name="controllers"><file name="IndexController.php" hash="e82e109cd6c0af430b962c3f5ced624d"/></dir><dir name="etc"><file name="config.xml" hash="09025e2db2e928854f2ddf6cc7a136ce"/><file name="system.xml" hash="9707a4aeb54a6a4513a3b326fc884959"/></dir></dir></dir></dir></dir></target></contents>
17
+ <compatible/>
18
+ <dependencies><required><php><min>5.1.0</min><max>5.5.0</max></php></required></dependencies>
19
+ </package>