easysize - Version 1.0.4

Version Notes

It is stable and working

Download this release

Release Info

Developer EasySize IVS
Extension easysize
Version 1.0.4
Comparing to
See all releases


Version 1.0.4

app/code/community/Easysize/Webapp/Block/Attr.php ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Easysize_Webapp_Block_Attr extends Mage_Core_Block_Template{
4
+
5
+ private $sizeCode;
6
+ private $genderCode;
7
+ private $attrObj;
8
+
9
+ /**
10
+ * @description : get theme
11
+ **/
12
+ public function getVersion()
13
+ {
14
+ return Mage::getSingleton('core/design_package')->getTheme('frontend');
15
+ }
16
+
17
+
18
+ /**
19
+ * @notice : the product need to have a field manufacturer, gender, and size
20
+ * admin panel for "gender" & "size"
21
+ * Manufacturer it'sn't a default attribute but already implemented in magento framework
22
+ **/
23
+ public function getProductObject(){
24
+
25
+ $id = $this->getRequest()->getParam('id');
26
+ $current_product=Mage::getModel('catalog/product')->load($id);
27
+
28
+ $this->sizeCode = Mage::getStoreConfig('easysize_section/easysize_group/size_field',Mage::app()->getStore());
29
+ $this->genderCode = Mage::getStoreConfig('easysize_section/easysize_group/gender_field',Mage::app()->getStore());
30
+
31
+
32
+ if(!$current_product->isConfigurable() || !$this->attributesExist($current_product, $this->genderCode)) return false;
33
+
34
+ $this->attrObj = new stdClass();
35
+
36
+ $this->attrObj->product_id =$current_product->getSku();
37
+
38
+ $id = $this->getRequest()->getParam('id');
39
+
40
+ // Order button
41
+ $this->attrObj->order_button_id = strlen(Mage::getStoreConfig('easysize_section/easysize_group/add_to_cart_field',Mage::app()->getStore())) > 2 ? Mage::getStoreConfig('easysize_section/easysize_group/add_to_cart_field',Mage::app()->getStore()) : ".add-to-cart-buttons";
42
+
43
+ $this->attrObj->product_brand = $current_product->getAttributeText('manufacturer');
44
+
45
+ $ncat = $current_product->getCategoryIds();
46
+ $this->attrObj->product_type = array();
47
+
48
+ for ($i=0; $i < sizeof($ncat); $i++) {
49
+ $this->attrObj->product_type[] = Mage::getModel('catalog/category')->load($ncat[$i])->getName();
50
+ }
51
+
52
+ $this->attrObj->product_type = implode(",", $this->attrObj->product_type);
53
+ $this->attrObj->product_gender = $current_product->getAttributeText($this->genderCode);
54
+ $this->attrObj->user_id = $this->getUser();
55
+ $this->attrObj->size_selector = "attribute".$this->getSizeNumberAttribute();
56
+ $this->attrObj->placeholder = Mage::getStoreConfig('easysize_section/easysize_group/placeholder_field',Mage::app()->getStore());
57
+
58
+
59
+ $this->attrObj->custom_style = Mage::getStoreConfig('easysize_section/easysize_group/style_field',Mage::app()->getStore());
60
+ $this->attrObj->shop_id = Mage::getStoreConfig('easysize_section/easysize_group/id_shop_field',Mage::app()->getStore());
61
+
62
+ $attributes = $current_product->getAttributes();
63
+ $childProducts = Mage::getModel('catalog/product_type_configurable')
64
+ ->getUsedProducts(null,$current_product);
65
+
66
+ $sizeObj = array();
67
+ foreach($childProducts as $child) {
68
+ if($this->attributesExist($child, $this->sizeCode)){
69
+ $chid = $child->getId();
70
+ $current_child_product=Mage::getModel('catalog/product')->load($chid);
71
+ $qty = $current_child_product->getStockItem()->getQty();
72
+ $size = $current_child_product->getAttributeText($this->sizeCode);
73
+ $sizeObj[$size] = $qty;
74
+ }
75
+ }
76
+ $this->attrObj->sizes_in_stock = $sizeObj;
77
+
78
+
79
+ if(!empty($izeObj) || !$this->attrObj->product_brand || !$this->attrObj->product_gender){
80
+ return false;
81
+ }else{
82
+ return true;
83
+
84
+ }
85
+
86
+ }
87
+ public function getObj(){
88
+ return json_encode($this->attrObj);
89
+ }
90
+
91
+ public function getSizeNumberAttribute(){
92
+ $this->sizeCode = Mage::getStoreConfig('easysize_section/easysize_group/size_field',Mage::app()->getStore());
93
+ $tize = Mage::getSingleton("eav/config")->getAttribute('catalog_product', $this->sizeCode);
94
+ $attrSize = $tize->getData();
95
+
96
+ return $attrSize['attribute_id'];
97
+ }
98
+
99
+ public function getUser(){
100
+ if(Mage::getSingleton('customer/session')->isLoggedIn()) {
101
+ $customerData = Mage::getSingleton('customer/session')->getCustomer();
102
+ return $customerData->getId();
103
+ }else{
104
+ return -1;
105
+ }
106
+ }
107
+
108
+ public function attributesExist($product, $attrCode){
109
+ $attributes = $product->getAttributes();
110
+
111
+ foreach ($attributes as $attribute){
112
+ if($attribute->getAttributecode()==$attrCode){
113
+ return true;
114
+ }
115
+ }
116
+ return false;
117
+ }
118
+
119
+ public function getProductId(){
120
+ return $this->getRequest()->getParam('id');
121
+ }
122
+
123
+ public function checkCart(){
124
+
125
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
126
+ $cartItems = $quote->getAllVisibleItems();
127
+ $arr = Array();
128
+ foreach ($cartItems as $item){
129
+ $productId = $item->getProductId();
130
+ array_push($arr, $productId);
131
+ }
132
+
133
+ return json_encode($arr);
134
+ }
135
+
136
+ public function attributeExistsInTheShop($code){
137
+
138
+ $attributes = Mage::getModel('catalog/product')->getAttributes();
139
+ $attributeArray = array();
140
+
141
+ foreach($attributes as $a){
142
+
143
+ foreach ($a->getEntityType()->getAttributeCodes() as $attributeName) {
144
+ array_push($attributeArray, $attributeName);
145
+ }
146
+ break;
147
+ }
148
+ return in_array($code, $attributeArray);
149
+ }
150
+
151
+ public function getAllProducts($sizeCode, $genderCode){
152
+
153
+ $allProducts = Array();
154
+ $products = Mage::getModel('catalog/product')->getCollection();
155
+ $_productCollection = clone $products;
156
+ $_productCollection->clear()
157
+ ->addAttributeToFilter('type_id', 'configurable')
158
+ ->load();
159
+
160
+ foreach($_productCollection as $prod) {
161
+ $obj= new stdClass();
162
+ $valid = true;
163
+ $product = Mage::getModel('catalog/product')->load($prod->getId());
164
+
165
+ $obj->name = $product->name;
166
+ if($this->attributesExist($product, $genderCode)){
167
+ $obj->gender = $product->getAttributeText($genderCode);
168
+ }else{
169
+ $obj->gender = "No";
170
+ $valid = false;
171
+ }
172
+
173
+ $ncat = $product->getCategoryIds()[0];
174
+ $product_type = Mage::getModel('catalog/category')->load($ncat)->getName();
175
+ if($product_type){
176
+ $obj->product_type = $product_type;
177
+ }else{
178
+ $obj->product_type = "No";
179
+ $valid = false;
180
+ }
181
+
182
+ $obj->children = "No";
183
+ $childProducts = Mage::getModel('catalog/product_type_configurable')
184
+ ->getUsedProducts(null,$product);
185
+
186
+ foreach($childProducts as $child) {
187
+ if($this->attributesExist($child, $sizeCode)){
188
+ $obj->children = "Yes";
189
+ break;
190
+ }
191
+ }
192
+ if($obj->children == "No"){
193
+ $valid = false;
194
+ }
195
+
196
+
197
+ if($this->attributesExist($product, "manufacturer") && $product->getAttributeText('manufacturer') !=""){
198
+ $obj->product_brand = $product->getAttributeText("manufacturer");
199
+ }else{
200
+ $obj->product_brand = "No";
201
+ $valid = false;
202
+ }
203
+
204
+ $obj->valid = $valid;
205
+ array_push($allProducts, $obj);
206
+ }
207
+
208
+ return $allProducts;
209
+ }
210
+
211
+ }
app/code/community/Easysize/Webapp/Helper/Data.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Easysize_Webapp_Helper_Data extends Mage_Core_Helper_Abstract{
5
+
6
+
7
+ public function isAvailable($id){
8
+
9
+
10
+ $current_product=Mage::getModel('catalog/product')->load($id);
11
+
12
+ $sizeCode = Mage::getStoreConfig('easysize_section/easysize_group/size_field',Mage::app()->getStore());
13
+ $genderCode = Mage::getStoreConfig('easysize_section/easysize_group/gender_field',Mage::app()->getStore());
14
+
15
+
16
+ if(!$current_product->isConfigurable() || !$this->attributesExist($current_product, $genderCode)) return false;
17
+
18
+ $product_brand = $current_product->getAttributeText('manufacturer');
19
+
20
+ $ncat = $current_product->getCategoryIds()[0];
21
+ $product_type = Mage::getModel('catalog/category')->load($ncat)->getName();
22
+
23
+ $product_gender = $current_product->getAttributeText($genderCode);
24
+
25
+ $shop_id = Mage::getStoreConfig('easysize_section/easysize_group/id_shop_field',Mage::app()->getStore());
26
+
27
+ $attributes = $current_product->getAttributes();
28
+ $childProducts = Mage::getModel('catalog/product_type_configurable')
29
+ ->getUsedProducts(null,$current_product);
30
+
31
+ $sizeObj = array();
32
+ foreach($childProducts as $child) {
33
+ if($this->attributesExist($child, $sizeCode)){
34
+ $chid = $child->getId();
35
+ $current_child_product=Mage::getModel('catalog/product')->load($chid);
36
+ $qty = $current_child_product->getStockItem()->getQty();
37
+ $size = $current_child_product->getAttributeText($sizeCode);
38
+ $sizeObj[$size] = $qty;
39
+ }
40
+ }
41
+
42
+ if(!empty($izeObj) || !$product_brand || !$product_gender || !$product_type){
43
+ return false;
44
+ }else{
45
+ return true;
46
+ }
47
+
48
+ }
49
+
50
+ public function attributesExist($product, $attrCode){
51
+ $attributes = $product->getAttributes();
52
+
53
+ foreach ($attributes as $attribute){
54
+ if($attribute->getAttributecode()==$attrCode){
55
+ return true;
56
+ }
57
+ }
58
+ return false;
59
+ }
60
+ }
61
+
62
+
63
+
64
+ ?>
app/code/community/Easysize/Webapp/Model/Observer.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Easysize_Webapp_Model_Observer extends Varien_Event_Observer{
4
+ public function __construct(){}
5
+
6
+ public function checkoutObserver($observer){
7
+
8
+ $eso = Mage::getModel('core/cookie')->get("eso");
9
+ Mage::log('eso from cookie: ' . $eso );
10
+
11
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
12
+ $cartItems = $quote->getAllVisibleItems();
13
+
14
+ $arr = Array();
15
+
16
+ $eso = Mage::getModel('core/cookie')->get("eso");
17
+ $eso = json_decode($eso);
18
+
19
+ $order_id = $observer->getEvent()->getOrder()->getId();
20
+
21
+ foreach ($eso as $key => $value){
22
+ if($this->inTheCart($value->product_id)){
23
+ $url = 'http://54.186.147.109/prod/web_app_v1.0/php/track.php';
24
+ $data = array('pageview_id' => $value->skey,'value' => $order_id, 'action' => '19');
25
+
26
+ $options = array(
27
+ 'http' => array(
28
+ 'header' => "Content-type: application/x-www-form-urlencoded\r\n",
29
+ 'method' => 'POST',
30
+ 'content' => http_build_query($data),
31
+ ),
32
+ );
33
+ $context = stream_context_create($options);
34
+ $response = file_get_contents($url, false, $context);
35
+ Mage::log($response);
36
+ }
37
+ }
38
+
39
+ Mage::getModel('core/cookie')->delete("eso");
40
+
41
+ }
42
+ public function logCartAdd($observer){
43
+
44
+
45
+
46
+ $eso = Mage::getModel('core/cookie')->get("eso");
47
+ $skey = Mage::getModel('core/cookie')->get('skey');
48
+
49
+ $product = Mage::getModel('catalog/product')
50
+ ->load(Mage::app()->getRequest()->getParam('product', 0));
51
+ $id = $product->getId();
52
+
53
+ $helper = Mage::helper('webapp/data');
54
+ $bool = $helper->isAvailable($id);
55
+ if($bool){
56
+
57
+ $eso = Mage::getModel('core/cookie')->get("eso");
58
+
59
+ $curr = Array('skey'=>$skey, 'product_id'=>$id);
60
+ $arr = json_decode($eso);
61
+
62
+ if($eso==false || $eso==null || $eso==""){
63
+ $arr = Array();
64
+ }
65
+ array_push($arr, $curr);
66
+ $eso = json_encode($arr);
67
+
68
+ Mage::getSingleton('core/cookie')->set('eso', $eso);
69
+
70
+ }
71
+ }
72
+
73
+ public function inTheCart($id){
74
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
75
+ foreach($quote->getAllVisibleItems() as $item) {
76
+ if ($item->getData('product_id') == $id) {
77
+ return true;
78
+ break;
79
+ }
80
+ }
81
+ return false;
82
+ }
83
+
84
+
85
+ }
app/code/community/Easysize/Webapp/controllers/Adminhtml/IndexController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Easysize_Webapp_Adminhtml_IndexController extends Mage_Adminhtml_Controller_Action {
4
+ public function indexAction(){
5
+ $this->loadLayout();
6
+ $this->renderLayout();
7
+ }
8
+ }
app/code/community/Easysize/Webapp/controllers/IndexController.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Easysize_Webapp_IndexController extends Mage_Core_Controller_Front_Action {
4
+ public function indexAction(){
5
+ $this->loadLayout(array('default'));
6
+ $this->renderLayout();
7
+ }
8
+ }
app/code/community/Easysize/Webapp/etc/config.xml ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <default>
4
+ <easysize_section>
5
+ <easysize_group>
6
+ <size_field>size</size_field>
7
+ <gender_field>gender</gender_field>
8
+ <placeholder_field>product-options-wrapper</placeholder_field>
9
+ <style_field>stylepit</style_field>
10
+ </easysize_group>
11
+ </easysize_section>
12
+ </default>
13
+ <admin>
14
+ <routers>
15
+ <myadmin>
16
+ <use>admin</use>
17
+ <args>
18
+ <module>Easysize_Webapp</module>
19
+ <frontName>easysize</frontName>
20
+ </args>
21
+ </myadmin>
22
+ </routers>
23
+ </admin>
24
+ <adminhtml>
25
+ <layout>
26
+ <updates>
27
+ <webapp>
28
+ <file>webapp_admin.xml</file>
29
+ </webapp>
30
+ </updates>
31
+ </layout>
32
+ <menu>
33
+ <test translate="title" module="adminhtml">
34
+ <title>EasySize</title>
35
+ <sort_order>100</sort_order>
36
+ <children>
37
+ <set_time>
38
+ <title>Overview</title>
39
+ <action>easysize/adminhtml_index</action>
40
+ </set_time>
41
+ </children>
42
+ </test>
43
+ </menu>
44
+
45
+ </adminhtml>
46
+ <global>
47
+ <modules>
48
+ <Easysize_Webapp>
49
+ <version>1.0.1</version>
50
+ </Easysize_Webapp>
51
+ </modules>
52
+ <blocks>
53
+ <webapp>
54
+ <class>Easysize_Webapp_Block</class>
55
+ </webapp>
56
+ </blocks>
57
+ <helpers>
58
+ <webapp>
59
+ <class>Easysize_Webapp_Helper</class>
60
+ </webapp>
61
+ </helpers>
62
+ <models>
63
+ <webapp>
64
+ <class>Easysize_Webapp_Model</class>
65
+ </webapp>
66
+ </models>
67
+
68
+ <ressources>
69
+ <webapp_write>
70
+ <connection>
71
+ <use>core_write</use>
72
+ </connection>
73
+ </webapp_write>
74
+ <webapp_read>
75
+ <connection>
76
+ <use>core_read</use>
77
+ </connection>
78
+ </webapp_read>
79
+ </ressources>
80
+ </global>
81
+
82
+ <frontend>
83
+ <events>
84
+ <controller_action_predispatch_checkout_cart_add>
85
+ <observers>
86
+ <webapp>
87
+ <class>webapp/observer</class>
88
+ <method>logCartAdd</method>
89
+ </webapp>
90
+ </observers>
91
+ </controller_action_predispatch_checkout_cart_add>
92
+
93
+ <sales_order_place_after>
94
+ <observers>
95
+ <webapp>
96
+ <type>singleton</type>
97
+ <class>webapp/observer</class>
98
+ <method>checkoutObserver</method>
99
+ </webapp>
100
+ </observers>
101
+ </sales_order_place_after>
102
+ </events>
103
+ <routers>
104
+ <routeurfrontend>
105
+ <use>standard</use>
106
+ <args>
107
+ <module>Easysize_Webapp</module>
108
+ <frontName>webapp</frontName>
109
+ </args>
110
+ </routeurfrontend>
111
+ </routers>
112
+ <layout>
113
+ <updates>
114
+ <webapp>
115
+ <file>webapp.xml</file>
116
+ </webapp>
117
+ </updates>
118
+ </layout>
119
+ </frontend>
120
+
121
+ </config>
app/code/community/Easysize/Webapp/etc/system.xml ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- <?xml version="1.0" ?>
2
+ <config>
3
+ <tabs>
4
+ <easysize_tab translate="label">
5
+ <label>EasySize Configuration</label>
6
+ <sort_order>100</sort_order>
7
+ </easysize_tab>
8
+ </tabs>
9
+ <sections>
10
+ <easysize_section translate="label">
11
+ <label>General</label>
12
+ <sort_order>200</sort_order>
13
+ <show_in_default>1</show_in_default>
14
+ <show_in_website>1</show_in_website>
15
+ <show_in_store>1</show_in_store>
16
+ <tab>easysize_tab</tab>
17
+ <groups>
18
+ <easysize_group translate="label">
19
+ <label>Configuration</label>
20
+
21
+ <comment>Please fill the form with the code attribute corresponding to the value</comment>
22
+ <sort_order>10</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
+ <expanded>1></expanded>
27
+ <fields>
28
+ <size_field translate="label">
29
+ <label>Size</label>
30
+ <comment>Size code attribut here</comment>
31
+ <frontend_type>text</frontend_type>
32
+ <sort_order>10</sort_order>
33
+ <show_in_default>2</show_in_default>
34
+ <show_in_website>2</show_in_website>
35
+ <show_in_store>2</show_in_store>
36
+ </size_field>
37
+ <gender_field translate="label">
38
+ <label>Gender</label>
39
+ <comment>gender code attribut here</comment>
40
+ <frontend_type>text</frontend_type>
41
+ <sort_order>20</sort_order>
42
+ <show_in_default>2</show_in_default>
43
+ <show_in_website>2</show_in_website>
44
+ <show_in_store>2</show_in_store>
45
+ </gender_field>
46
+ <placeholder_field translate="label">
47
+ <label>Placeholder</label>
48
+ <comment>Default value : product-options-wrapper</comment>
49
+ <frontend_type>text</frontend_type>
50
+ <sort_order>30</sort_order>
51
+ <show_in_default>2</show_in_default>
52
+ <show_in_website>2</show_in_website>
53
+ <show_in_store>2</show_in_store>
54
+ </placeholder_field>
55
+ <id_shop_field translate="label">
56
+ <label>Your id shop</label>
57
+ <comment>Your id shop provided by EasySize</comment>
58
+ <frontend_type>text</frontend_type>
59
+ <sort_order>40</sort_order>
60
+ <show_in_default>2</show_in_default>
61
+ <show_in_website>2</show_in_website>
62
+ <show_in_store>2</show_in_store>
63
+ </id_shop_field>
64
+ <style_field translate="label">
65
+ <label>Style name</label>
66
+ <comment>Default value : sliding</comment>
67
+ <frontend_type>text</frontend_type>
68
+ <sort_order>40</sort_order>
69
+ <show_in_default>2</show_in_default>
70
+ <show_in_website>2</show_in_website>
71
+ <show_in_store>2</show_in_store>
72
+ </style_field>
73
+ </fields>
74
+
75
+ </easysize_group>
76
+ </groups>
77
+
78
+ </easysize_section>
79
+ </sections>
80
+ </config>
app/design/adminhtml/default/default/layout/webapp_admin.xml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" ?>
2
+ <layout version="0.1.0">
3
+
4
+ <myadmin_adminhtml_index_index>
5
+ <reference name="content">
6
+ <block type="webapp/Attr" name="admin_test" template="webapp/afficher.phtml" />
7
+ </reference>
8
+ </myadmin_adminhtml_index_index>
9
+ </layout>
10
+
11
+
app/design/adminhtml/default/default/template/webapp/afficher.phtml ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <style>
2
+
3
+ .content{
4
+ width: 100%;
5
+ margin: auto;
6
+ }
7
+ .title{
8
+ text-align: center;
9
+ }
10
+ #logo{
11
+ width: 140px;
12
+ }
13
+ .table {
14
+ margin-bottom: 20px;
15
+ max-width: 100%;
16
+ width: 100%;
17
+ }
18
+ .alert-danger {
19
+ text-align: center;
20
+ background-color: #f2dede;
21
+ border-color: #ebccd1;
22
+ color: #a94442;
23
+ }
24
+ .alert {
25
+ border: 1px solid transparent;
26
+ border-radius: 4px;
27
+ margin-bottom: 20px;
28
+ padding: 15px;
29
+ }
30
+ .alert-success {
31
+ color: #3c763d;
32
+ background-color: #dff0d8;
33
+ border-color: #d6e9c6;
34
+ }
35
+ #form{
36
+ width: 30%;
37
+ float: right;
38
+ padding: 20px;
39
+ margin: 0;
40
+ }
41
+ </style>
42
+ <?php
43
+
44
+
45
+ Mage::app()->getCacheInstance()->flush();
46
+
47
+ if(isset($_POST['sizecode'])){
48
+ $sizeCode = $_POST['sizecode'];
49
+ $genderCode = $_POST['gendercode'];
50
+ $placeholder = $_POST['placeholder'];
51
+ $shopid = $_POST['shopid'];
52
+ $design = $_POST['design'];
53
+ $add_to_cart = $_POST['add_to_cart'];
54
+
55
+ Mage::getModel('core/config')->saveConfig('easysize_section/easysize_group/size_field', $sizeCode);
56
+ Mage::getModel('core/config')->saveConfig('easysize_section/easysize_group/gender_field', $genderCode);
57
+ Mage::getModel('core/config')->saveConfig('easysize_section/easysize_group/placeholder_field', $placeholder);
58
+ Mage::getModel('core/config')->saveConfig('easysize_section/easysize_group/id_shop_field', $shopid);
59
+ Mage::getModel('core/config')->saveConfig('easysize_section/easysize_group/style_field', $design);
60
+ Mage::getModel('core/config')->saveConfig('easysize_section/easysize_group/add_to_cart_field', $add_to_cart);
61
+ }else{
62
+ $sizeCode = Mage::getStoreConfig('easysize_section/easysize_group/size_field',Mage::app()->getStore());
63
+ $genderCode = Mage::getStoreConfig('easysize_section/easysize_group/gender_field',Mage::app()->getStore());
64
+ $placeholder = Mage::getStoreConfig('easysize_section/easysize_group/placeholder_field',Mage::app()->getStore());
65
+ $shopid = Mage::getStoreConfig('easysize_section/easysize_group/id_shop_field',Mage::app()->getStore());
66
+ $design = Mage::getStoreConfig('easysize_section/easysize_group/style_field',Mage::app()->getStore());
67
+ $add_to_cart = strlen(Mage::getStoreConfig('easysize_section/easysize_group/add_to_cart_field',Mage::app()->getStore())) > 2 ? Mage::getStoreConfig('easysize_section/easysize_group/add_to_cart_field',Mage::app()->getStore()) : ".add-to-cart-buttons";
68
+ }
69
+
70
+
71
+
72
+ ?>
73
+ <div class="content">
74
+
75
+ <div id="form">
76
+ <h2>Configuration</h2>
77
+ <form method="POST" action="" style="max-width: 500px;">
78
+ <input name="form_key" type="hidden" value="<?php echo Mage::getSingleton('core/session')->getFormKey() ?>" />
79
+ <div class="alert alert-danger">
80
+ <h4 class="title">Errors</h4>
81
+ <?php
82
+ $error = false;
83
+ if (!$sizeCode) {
84
+ $error = true;
85
+ echo "<p>- A size code is needed</p></p>";
86
+ } else if (!$this->attributeExistsInTheShop($sizeCode)) {
87
+ echo "<p>- '".$sizeCode."'' is not a valid size code </p>";
88
+ $error = true;
89
+ }
90
+
91
+ if (!$genderCode) {
92
+ $error = true;
93
+ echo "<p>- A gender code is needed";
94
+ } else if (!$this->attributeExistsInTheShop($genderCode)){
95
+ $error = true;
96
+ echo "<p>- '".$genderCode."'' is not a valid gender code </p>";
97
+ }
98
+
99
+ if (!$placeholder) {
100
+ $error = true;
101
+ echo "<p>- A placeholder is needed</p>";
102
+ }
103
+
104
+ if (!$shopid) {
105
+ $error = true;
106
+ echo "<p>- Shop id is needed</p>";
107
+ }
108
+
109
+ if (!$error) {
110
+ echo '<style>.alert-danger{display:none;}</style>';
111
+ echo '<style>.alert-success{display:block;}</style>';
112
+ } else {
113
+ echo '<style>.alert-danger{display:block;}</style>';
114
+ echo '<style>.alert-success{display:none;}</style>';
115
+ }
116
+
117
+ ?>
118
+ </div>
119
+
120
+ <div class="alert alert-success">
121
+ <h4 class="title">All looks well configured</h4>
122
+
123
+ </div>
124
+
125
+
126
+ <p class="fd">
127
+ <label class="label" for="sizecode"><b>Size Code: </b></label>
128
+ <input style="float: right;" type="text" name="sizecode" id="sizecode" value="<?php echo $sizeCode;?>" /> <br/>
129
+ <i>This code represents the product size in your shop.</i>
130
+ </p>
131
+
132
+ <p class="fd">
133
+ <label class="label" for="gendercoder"><b>Gender Code: </b></label>
134
+ <input style="float: right;" type="text" name="gendercode" id="gendercode" value="<?php echo $genderCode;?>" /><br/>
135
+ <i>This code represents the product gender in your shop.</i>
136
+ </p>
137
+
138
+ <p class="fd">
139
+ <label class="label" for="placeholder"><b>Placeholder: </b></label>
140
+ <input style="float: right;" stype="text" name="placeholder" id="placeholder" value="<?php echo $placeholder;?>" /><br/>
141
+ <i>This value controls the position of the EasySize button.</i>
142
+ </p>
143
+
144
+ <p class="fd">
145
+ <label class="label" for="add_to_cart"><b>Add to cart button: </b></label>
146
+ <input style="float: right;" stype="text" name="add_to_cart" id="add_to_cart" value="<?php echo $add_to_cart;?>" /><br/>
147
+ <i>Your add to cart button selector</i>
148
+ </p>
149
+
150
+ <p class="fd">
151
+ <label class="label" for="design"><b>Design Name: </b></label>
152
+ <input style="float: right;" type="text" name="design" id="design" value="<?php echo $design;?>" /><br/>
153
+ <i>Change the design of the popup (Ask EasySize team).</i>
154
+ </p>
155
+
156
+ <p class="fd">
157
+ <label class="label" for="shopid"><b>Shop Id: </b></label>
158
+ <input style="float: right;" type="text" name="shopid" id="shopid" value="<?php echo $shopid;?>" /><br/>
159
+ <i>This value is your shop id provided by EasySize.</i>
160
+ </p>
161
+
162
+ <p>
163
+ <button style="width: 100%;" type="submit">Save</button>
164
+ </p>
165
+ </form>
166
+
167
+ <h2>Overview</h2>
168
+ <p>Below you will find all configurable product and how they fulfill EasySize parameters</p>
169
+ <i>Note: Each configurable product needs to have a category, a brand (manufacturer attribute), a gender and different(multiple) sizes available.</i>
170
+
171
+ <hr/>
172
+
173
+ <table class="table">
174
+ <thead>
175
+ <tr>
176
+ <th>Name</th>
177
+ <th>Category</th>
178
+ <th>Gender</th>
179
+ <th>Brand</th>
180
+ <th>Different(multiple) Sizes?</th>
181
+ </tr>
182
+ </thead>
183
+
184
+ <?php
185
+ $all = $this->getAllProducts($sizeCode, $genderCode);
186
+ for ($i=0; $i<sizeof($all); $i++) {
187
+ if ($all[$i]->valid) {
188
+ echo "<tr style='color: green'>";
189
+ } else {
190
+ echo "<tr style='color: red'>";
191
+ }
192
+
193
+ echo "<td>".$all[$i]->name."</td>";
194
+ echo "<td>".$all[$i]->product_type."</td>";
195
+ echo "<td>".$all[$i]->gender."</td>";
196
+ echo "<td>".$all[$i]->product_brand."</td>";
197
+ echo "<td>".$all[$i]->children."</td>";
198
+ echo "</tr>";
199
+ }
200
+ ?>
201
+ </table>
202
+
203
+ </div>
204
+
205
+ <iframe style="float: left; border:none; margin:0;" src="http://www.easysize.me/" height="800px" width="65%" >EasySize loading...</iframe>
206
+ </div>
app/design/frontend/base/default/layout/webapp.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <layout version="0.1.0">
2
+ <default>
3
+ <reference name="head">
4
+ <action method="addJs">
5
+ <script>EasySize/easysize.js</script>
6
+ </action>
7
+ </reference>
8
+ <reference name="content">
9
+ <block type="webapp/Attr" name="product.info.es" template="webapp/easysizeMod.phtml"></block>
10
+ </reference>
11
+ </default>
12
+ </layout>
app/design/frontend/base/default/template/webapp/easysizeMod.phtml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script type="text/javascript" src="http://webapp.easysize.me/web_app_v1.0/js/easysize-2.0.0.js"></script>
2
+
3
+ <?php if($this->getProductObject()){ ?>
4
+ <script type="text/javascript">
5
+ var easy_size;
6
+ window.onload = function() {
7
+ var data = <?php echo $this->getObj(); ?>;
8
+ easy_size = new EasySize(data);
9
+ easy_size.start();
10
+ }
11
+ </script>
12
+ <?php } ?>
13
+
14
+ <link href="http://webapp.easysize.me/web_app_v1.0/css/easysize_<?php echo Mage::getStoreConfig('easysize_section/easysize_group/style_field',Mage::app()->getStore());?>.css" rel="stylesheet" />
app/etc/modules/Easysize_all.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Easysize_Webapp>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Easysize_Webapp>
8
+ </modules>
9
+ </config>
js/EasySize/easysize.js ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function(){
2
+
3
+ var setItem = function (sKey, sValue, vEnd, sPath, sDomain, bSecure) {
4
+ if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; }
5
+ var sExpires = "";
6
+ if (vEnd) {
7
+ switch (vEnd.constructor) {
8
+ case Number:
9
+ sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd;
10
+ break;
11
+ case String:
12
+ sExpires = "; expires=" + vEnd;
13
+ break;
14
+ case Date:
15
+ sExpires = "; expires=" + vEnd.toUTCString();
16
+ break;
17
+ }
18
+ }
19
+ document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : "");
20
+ return true;
21
+ }
22
+
23
+ jQuery(document).delegate(".button.btn-cart", 'mouseenter', function(){
24
+ var skey = easy_size.skey();
25
+ setItem('skey', skey);
26
+ });
27
+
28
+ })();
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>easysize</name>
4
+ <version>1.0.4</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.easysize.me/terms-of-use/">EasySize</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>EasySize sizing solution</summary>
10
+ <description>EasySize was founded in October 2014 by Gulnaz Khusainova and is currently based in Copenhagen, Denmark. EasySize&#x2019;s aim is to improve the online shopping experience for customers and empower retailers to grow their online businesses by using smart technology to accurately understand what a customer&#x2019;s ideal fit is. To date, EasySize has helped over 400,000 unique users find their ideal fit all over the world. Please visit easysize.me for more information.</description>
11
+ <notes>It is stable and working</notes>
12
+ <authors><author><name>EasySize IVS</name><user>EasySize</user><email>gk@easysize.me</email></author></authors>
13
+ <date>2015-09-15</date>
14
+ <time>08:26:17</time>
15
+ <contents><target name="magecommunity"><dir name="Easysize"><dir name="Webapp"><dir name="Block"><file name="Attr.php" hash="0d5d8b24f3d4dd024fed68a788ef8eb5"/></dir><dir name="Helper"><file name="Data.php" hash="ad6aa6663faa95d5aebec81f1fa26751"/></dir><dir name="Model"><file name="Observer.php" hash="aee980532952e9316cfa1b31e824fe0c"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="IndexController.php" hash="68676dd9984c41decac75931d8b7d2d5"/></dir><file name="IndexController.php" hash="4884e9612dfb2a1beb2780f34177ad2a"/></dir><dir name="etc"><file name="config.xml" hash="6b9724d23eacfaa938d448750b4ae6dd"/><file name="system.xml" hash="33b242bc6b481b97ab9bdf459f2a6d30"/></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="webapp_admin.xml" hash="dbc673aaba2b280288921438a3e5656a"/></dir><dir name="template"><dir name="webapp"><file name="afficher.phtml" hash="930b0b5e444ed5a30f7f11da92f04998"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="webapp"><file name="easysizeMod.phtml" hash="3e626688e69517363f2269a341d22061"/></dir></dir><dir name="layout"><file name="webapp.xml" hash="6e7db4d388b083b304d193df270b513d"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Easysize_all.xml" hash="e0b74bb3a63484144a37267238d52834"/></dir></target><target name="mage"><dir name="js"><dir name="EasySize"><file name="easysize.js" hash="68f6553e60490429e266b2aee0b4619d"/></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>