easysize - Version 1.4.0

Version Notes

Size filter removed from bundle module.

Real time stock update notifications to EasySize added. This improves our product recommendation for your customers

Download this release

Release Info

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


Code changes from version 1.3.7 to 1.4.0

app/code/community/EasySize/SizeGuide/Block/Data.php CHANGED
@@ -37,7 +37,7 @@ class EasySize_SizeGuide_Block_Data extends Mage_Core_Block_Template {
37
  }
38
 
39
  $required_attributes->product_type = implode(',', $this->getProductCategoriesNames($product));
40
- $required_attributes->sizes_in_stock = $this->getProductSizesInStock($product, $shop_configuration['sizeguide_size_attributes']);
41
  $required_attributes->shop_id = $shop_configuration['sizeguide_shopid'];
42
  $required_attributes->placeholder = $shop_configuration['sizeguide_button_placeholder'];
43
  $required_attributes->size_selector = "attribute{$this->size_attribute_id}";
@@ -83,10 +83,11 @@ class EasySize_SizeGuide_Block_Data extends Mage_Core_Block_Template {
83
  * Iterates through all the simple products created from the configurable product
84
  * Returns array of products' sizes in stock.
85
  */
86
- private function getProductSizesInStock($product, $size_attribute_codes) {
87
  $sizes_in_stock = array();
88
 
89
  if($product->getTypeId() == 'configurable') {
 
90
  $child_products = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
91
  $product_attributes = Mage::getModel('eav/config')
92
  ->getEntityAttributeCodes(Mage_Catalog_Model_Product::ENTITY,$product);
37
  }
38
 
39
  $required_attributes->product_type = implode(',', $this->getProductCategoriesNames($product));
40
+ $required_attributes->sizes_in_stock = $this->getProductSizesInStock($product);
41
  $required_attributes->shop_id = $shop_configuration['sizeguide_shopid'];
42
  $required_attributes->placeholder = $shop_configuration['sizeguide_button_placeholder'];
43
  $required_attributes->size_selector = "attribute{$this->size_attribute_id}";
83
  * Iterates through all the simple products created from the configurable product
84
  * Returns array of products' sizes in stock.
85
  */
86
+ private function getProductSizesInStock($product) {
87
  $sizes_in_stock = array();
88
 
89
  if($product->getTypeId() == 'configurable') {
90
+ $size_attribute_codes = Mage::getStoreConfig('sizeguide/sizeguide/sizeguide_size_attributes');
91
  $child_products = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
92
  $product_attributes = Mage::getModel('eav/config')
93
  ->getEntityAttributeCodes(Mage_Catalog_Model_Product::ENTITY,$product);
app/code/community/EasySize/SizeGuide/Model/Observer.php CHANGED
@@ -10,7 +10,6 @@ class EasySize_SizeGuide_Model_Observer {
10
 
11
  // iterate through all items in the order
12
  foreach($order->getAllItems() as $order_item) {
13
- // Unserialize item data
14
  $item = unserialize($order_item->product_options);
15
 
16
  // Check whether ordered item exists in cart
@@ -59,117 +58,55 @@ class EasySize_SizeGuide_Model_Observer {
59
  }
60
  }
61
 
62
- public function updateCart($observer) {
63
- // todo. Fix update cart
64
- }
65
-
66
- public function filterProducts($observer)
67
- {
68
- if(isset($_REQUEST['easysize_sizefilter_products'])) {
69
- $observer->getEvent()->getCollection()->addAttributeToFilter('entity_id', array('in' => $_REQUEST['easysize_sizefilter_products']));
70
- }
71
-
72
- if (Mage::registry('easysize_sizefilter_applied') || Mage::getStoreConfig('sizeguide/sizefilter/sizefilter_enabled') != 1) { return; }
73
-
74
- // Get product attribute names for data extraction
75
- $shop_configuration = Mage::getStoreConfig('sizeguide/sizeguide');
76
- $gender_attribute_name = $shop_configuration['sizeguide_gender_attribute'];
77
- $easysize_shop_id = $shop_configuration['sizeguide_shopid'];
78
-
79
- if(isset($_COOKIE['esui'])) {
80
- $easysize_user_id = $_COOKIE['esui'];
81
-
82
- if(!is_numeric($easysize_user_id) || is_numeric($easysize_user_id) && $easysize_user_id < 0) {
83
- Mage::register('easysize_sizefilter_applied', true);
84
- return;
 
 
85
  }
86
- } else {
87
- Mage::register('easysize_sizefilter_applied', true);
88
- return;
89
- }
90
-
91
- $collection = $observer->getEvent()->getCollection()
92
- ->addAttributeToSelect('manufacturer');
93
- $collection_product_ids = $collection->getAllIds();
94
- $first_item = Mage::getModel('catalog/product')->getCollection()
95
- ->addAttributeToSelect($gender_attribute_name)
96
- ->addAttributeToFilter('entity_id', array('in' => $collection_product_ids))
97
- ->addAttributeToFilter('type_id', 'configurable')
98
- ->getFirstItem();
99
-
100
- $current_store = Mage::app()->getRequest()->getParam('store');
101
-
102
- // Using first item from collection, get gender and category of items
103
- if(strlen($shop_configuration['sizeguide_gender_one_attribute']) > 0) {
104
- $product_gender = $shop_configuration['sizeguide_gender_one_attribute'];
105
- } else {
106
- $product_gender = $first_item->getAttributeText($gender_attribute_name);
107
- }
108
-
109
- $params = [];
110
- $params[] = "shop_id={$easysize_shop_id}";
111
- $params[] = "gender={$product_gender}";
112
- $params[] = "easysize_user_id={$easysize_user_id}";
113
-
114
- if($first_item->getCategory() && $product_type = $first_item->getCategory()->getName()) {
115
- $product_type_decoded = urlencode($product_type);
116
-
117
- if($this->isCategoryABrand($first_item->getCategory())) {
118
- $params[] = "brand={$product_type_decoded}";
119
- } else {
120
- $params[] = "category={$product_type_decoded}";
121
  }
122
- } else {
123
- /*
124
- If product attribute extraction fails, register a notice to not have an overload
125
- */
126
- Mage::register('easysize_sizefilter_applied', true);
127
- return;
128
- }
129
 
130
- $params = implode('&', $params);
131
- $url = "https://popup.easysize.me/filterProductsBySize?${params}";
132
- $curl = curl_init();
133
- curl_setopt_array($curl, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $url ));
134
- $data = json_decode(curl_exec($curl), true);
135
- curl_close($curl);
136
-
137
- $filtered_product_ids = [];
138
- foreach ($data as $item) {
139
- $filtered_product_ids[] = $item['product_id'];
140
  }
141
 
142
- if(sizeof($filtered_product_ids) > 0) {
143
- $_REQUEST['easysize_sizefilter_has_products'] = true;
144
-
145
- if(!isset($_POST['easysize_sizefilter'])) { $_POST['easysize_sizefilter'] = ''; }
146
-
147
- if (
148
- isset($_POST['easysize_sizefilter']) && $_POST['easysize_sizefilter'] == "enable"
149
- || isset($_SESSION['easysize_sizefilter']) && $_SESSION['easysize_sizefilter'] == 1 && $_POST['easysize_sizefilter'] != "disable") {
150
-
151
- $_SESSION['easysize_sizefilter'] = 1;
152
- $_REQUEST['easysize_sizefilter_applied'] = true;
153
- $_REQUEST['easysize_sizefilter_products'] = $filtered_product_ids;
154
- } elseif(isset($_POST['easysize_sizefilter']) && $_POST['easysize_sizefilter'] === "disable") {
155
- $_SESSION['easysize_sizefilter'] = 0;
156
- }
157
- }
158
-
159
- Mage::register('easysize_sizefilter_applied', true);
160
- }
161
-
162
- private function isCategoryABrand($category) {
163
- $brandFromCategory = Mage::getModel('catalog/category')->load(Mage::getStoreConfig('sizeguide/sizeguide/sizeguide_brand_attribute'));
164
- if($brandFromCategory->getId()) {
165
- $_parentCategories = $category->getParentCategories();
166
- foreach($_parentCategories as $_parentCategory) {
167
- if($brandFromCategory->getId() != $_parentCategory->getId() && in_array($brandFromCategory->getId(), $_parentCategory->getPathIds())) {
168
- return true;
169
- }
170
- }
171
- } else {
172
- return false;
173
  }
174
  }
175
  }
10
 
11
  // iterate through all items in the order
12
  foreach($order->getAllItems() as $order_item) {
 
13
  $item = unserialize($order_item->product_options);
14
 
15
  // Check whether ordered item exists in cart
58
  }
59
  }
60
 
61
+ public function updateProductStock($observer) {
62
+ $sizes_in_stock = array();
63
+ $size_attribute_codes = Mage::getStoreConfig('sizeguide/sizeguide/sizeguide_size_attributes');
64
+ $shop_id = Mage::getStoreConfig('sizeguide/sizeguide/sizeguide_shopid');
65
+
66
+ $product = $observer->getData('product');
67
+ $product_id = $product->getId();
68
+ $product_attributes = Mage::getModel('eav/config')
69
+ ->getEntityAttributeCodes(Mage_Catalog_Model_Product::ENTITY,$product);
70
+
71
+ if($product->getTypeId() == 'configurable') {
72
+ $child_products = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
73
+
74
+ // Iterate through all simple products
75
+ foreach ($child_products as $simple_product) {
76
+ // Iterate through all size attributes
77
+ foreach (explode(',', $size_attribute_codes) as $size_attribute) {
78
+ if (in_array($size_attribute, $product_attributes)) {
79
+ $current_simple_product_id = $simple_product->getId();
80
+ $current_simple_product = Mage::getModel('catalog/product')->load($current_simple_product_id);
81
+ $quantity = $current_simple_product->getStockItem()->getQty();
82
+ $size = $current_simple_product->getAttributeText($size_attribute);
83
+ $sizes_in_stock[$size] = $quantity;
84
+ }
85
+ }
86
  }
87
+ } else if($product->getTypeId() == 'simple') {
88
+ foreach (explode(',', $size_attribute_codes) as $size_attribute) {
89
+ if (in_array($size_attribute, $product_attributes)) {
90
+ $current_simple_product_id = $product->getId();
91
+ $current_simple_product = Mage::getModel('catalog/product')->load($current_simple_product_id);
92
+ $quantity = $current_simple_product->getStockItem()->getQty();
93
+ $size = $current_simple_product->getAttributeText($size_attribute);
94
+ $sizes_in_stock[$size] = $quantity;
95
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  }
 
 
 
 
 
 
 
97
 
98
+ $product_id = Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild($product->getId())[0];
 
 
 
 
 
 
 
 
 
99
  }
100
 
101
+ if($product_id) {
102
+ $data = json_encode(array("sizes_in_stock" => $sizes_in_stock));
103
+ $ch = curl_init();
104
+ curl_setopt($ch, CURLOPT_URL, "https://popup.easysize.me/api/{$shop_id}/product_stock/{$product_id}");
105
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: '.strlen($data)));
106
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
107
+ curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
108
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
109
+ $response = curl_exec($ch);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  }
111
  }
112
  }
app/code/community/EasySize/SizeGuide/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <EasySize_SizeGuide>
5
- <version>1.3.7</version>
6
  </EasySize_SizeGuide>
7
  </modules>
8
 
@@ -56,24 +56,6 @@
56
  </easysize_sizeguide_add_to_cart>
57
  </observers>
58
  </checkout_cart_product_add_after>
59
- <checkout_cart_update_item_complete>
60
- <observers>
61
- <easysize_sizeguide_update_cart>
62
- <type>singleton</type>
63
- <class>sizeguide/observer</class>
64
- <method>updateCart</method>
65
- </easysize_sizeguide_update_cart>
66
- </observers>
67
- </checkout_cart_update_item_complete>
68
-
69
- <catalog_product_collection_apply_limitations_after>
70
- <observers>
71
- <easysize_sizefilter_product_filter>
72
- <class>EasySize_SizeGuide_Model_Observer</class>
73
- <method>filterProducts</method>
74
- </easysize_sizefilter_product_filter>
75
- </observers>
76
- </catalog_product_collection_apply_limitations_after>
77
  </events>
78
  </frontend>
79
 
@@ -104,5 +86,17 @@
104
  </setup>
105
  </sizeguide_setup>
106
  </resources>
 
 
 
 
 
 
 
 
 
 
 
 
107
  </global>
108
  </config>
2
  <config>
3
  <modules>
4
  <EasySize_SizeGuide>
5
+ <version>1.4.0</version>
6
  </EasySize_SizeGuide>
7
  </modules>
8
 
56
  </easysize_sizeguide_add_to_cart>
57
  </observers>
58
  </checkout_cart_product_add_after>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  </events>
60
  </frontend>
61
 
86
  </setup>
87
  </sizeguide_setup>
88
  </resources>
89
+
90
+ <events>
91
+ <catalog_product_save_commit_after>
92
+ <observers>
93
+ <easysize_sizeguide_update_product>
94
+ <type>singletone</type>
95
+ <class>sizeguide/observer</class>
96
+ <method>updateProductStock</method>
97
+ </easysize_sizeguide_update_product>
98
+ </observers>
99
+ </catalog_product_save_commit_after>
100
+ </events>
101
  </global>
102
  </config>
app/code/community/EasySize/SizeGuide/etc/system.xml CHANGED
@@ -125,39 +125,6 @@
125
  </sizeguide_add_to_cart_button>
126
  </fields>
127
  </sizeguide>
128
-
129
- <sizefilter>
130
- <label>Size Filter</label>
131
- <frontend_type>text</frontend_type>
132
- <sort_order>2</sort_order>
133
- <show_in_default>2</show_in_default>
134
- <show_in_website>2</show_in_website>
135
- <show_in_store>2</show_in_store>
136
- <fields>
137
- <sizefilter_header>
138
- <label>Size filter feature config</label>
139
- <comment>This part requires some technical knowledge. Please contact EasySize if you need assistance settings this up.</comment>
140
- <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
141
- <sort_order>1</sort_order>
142
- <show_in_default>1</show_in_default>
143
- <show_in_website>1</show_in_website>
144
- <show_in_store>1</show_in_store>
145
- </sizefilter_header>
146
-
147
- <sizefilter_enabled>
148
- <label>Enabled</label>
149
- <comment>
150
- <![CDATA[Enable or Disable size filter feature.]]>
151
- </comment>
152
- <frontend_type>select</frontend_type>
153
- <source_model>adminhtml/system_config_source_enabledisable</source_model>
154
- <sort_order>2</sort_order>
155
- <show_in_default>2</show_in_default>
156
- <show_in_website>2</show_in_website>
157
- <show_in_store>2</show_in_store>
158
- </sizefilter_enabled>
159
- </fields>
160
- </sizefilter>
161
  </groups>
162
  </sizeguide>
163
  </sections>
125
  </sizeguide_add_to_cart_button>
126
  </fields>
127
  </sizeguide>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  </groups>
129
  </sizeguide>
130
  </sections>
app/code/community/EasySize/SizeGuide/sql/sizeguide_setup/{install-1.3.7.php → install-1.4.0.php} RENAMED
File without changes
app/design/frontend/base/default/template/sizeguide/sizefilter.phtml DELETED
@@ -1,13 +0,0 @@
1
- <?php if(isset($_REQUEST['easysize_sizefilter_has_products']) && $_REQUEST['easysize_sizefilter_has_products'] == true): ?>
2
- <form class="easysize-sizefilter easysize-sizefilter-custom" method="POST">
3
- <?php if(isset($_POST['easysize_sizefilter']) && $_POST['easysize_sizefilter'] == 'disable' ||
4
- isset($_SESSION['easysize_sizefilter']) && $_SESSION['easysize_sizefilter'] != 1 ||
5
- !isset($_POST['easysize_sizefilter']) && !isset($_SESSION['easysize_sizefilter'])): ?>
6
- <input type="hidden" name="easysize_sizefilter" value="enable"/>
7
- <input type="submit" value="Shop by size"/>
8
- <?php else: ?>
9
- <input type="hidden" name="easysize_sizefilter" value="disable"/>
10
- <input class="easysize-sizefilter-turn-off" type="submit" value="Show all"/>
11
- <?php endif; ?>
12
- </form>
13
- <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
package.xml CHANGED
@@ -1,18 +1,20 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>easysize</name>
4
- <version>1.3.7</version>
5
  <stability>stable</stability>
6
  <license uri="https://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>Checkout tracking updates</notes>
 
 
12
  <authors><author><name>EasySize IVS</name><user>EasySize</user><email>gk@easysize.me</email></author></authors>
13
- <date>2016-10-17</date>
14
- <time>13:19:45</time>
15
- <contents><target name="magecommunity"><dir name="EasySize"><dir name="SizeGuide"><dir name="Block"><file name="Data.php" hash="f0db0b5c6ddb7942a7d8ad4df847fe2f"/></dir><dir name="Helper"><file name="Data.php" hash="e1f1c548146a5eedc58222620232a758"/></dir><dir name="Model"><file name="Observer.php" hash="b8828cd8338e1f9c4dde4d3a330321ab"/><dir name="Resource"><file name="Setup.php" hash="db68d16089806da3849ab919e4e35a01"/></dir><file name="ShopAttributes.php" hash="f53c64e27f9a3c7f2b2a11ea74afe01e"/></dir><dir name="etc"><file name="config.xml" hash="7ba866abaa6e3b0a5af9dca8be333a0a"/><file name="system.xml" hash="3b9d574c828581df0c306608eb0aeae1"/></dir><dir name="sql"><dir name="sizeguide_setup"><file name="install-1.3.7.php" hash="f105323c8b2ab85bcf002fa382b0ad00"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="sizeguide"><file name="easysize.phtml" hash="d24ea6c57ef8c630e56204147bbc4adc"/><file name="sizefilter.phtml" hash="1fa6522b7f6482c9bdf42c4360b9b801"/></dir></dir><dir name="layout"><file name="sizeguide.xml" hash="abb47cb6331cc1271de76dd485bc374f"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EasySize_SizeGuide.xml" hash="2397289fc71f8ddb23dec37aefdf4779"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="easysize"><dir name="css"><file name="easysize.sizefilter.css" hash="939a9901108e5daa86252cd98d8b9824"/></dir></dir></dir></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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>easysize</name>
4
+ <version>1.4.0</version>
5
  <stability>stable</stability>
6
  <license uri="https://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>Size filter removed from bundle module.&#xD;
12
+ &#xD;
13
+ Real time stock update notifications to EasySize added. This improves our product recommendation for your customers</notes>
14
  <authors><author><name>EasySize IVS</name><user>EasySize</user><email>gk@easysize.me</email></author></authors>
15
+ <date>2016-11-29</date>
16
+ <time>09:43:05</time>
17
+ <contents><target name="magecommunity"><dir name="EasySize"><dir name="SizeGuide"><dir name="Block"><file name="Data.php" hash="5e5609f195682b10704ea06b3aba0fd9"/></dir><dir name="Helper"><file name="Data.php" hash="e1f1c548146a5eedc58222620232a758"/></dir><dir name="Model"><file name="Observer.php" hash="825d5d1034305c6042e9e9c3cc29de74"/><dir name="Resource"><file name="Setup.php" hash="db68d16089806da3849ab919e4e35a01"/></dir><file name="ShopAttributes.php" hash="f53c64e27f9a3c7f2b2a11ea74afe01e"/></dir><dir name="etc"><file name="config.xml" hash="6f1d2ee69d058898d2f2f9dfdb3d87db"/><file name="system.xml" hash="e689462cfa4ba35e935735ace1525cc4"/></dir><dir name="sql"><dir name="sizeguide_setup"><file name="install-1.4.0.php" hash="f105323c8b2ab85bcf002fa382b0ad00"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="sizeguide"><file name="easysize.phtml" hash="d24ea6c57ef8c630e56204147bbc4adc"/></dir></dir><dir name="layout"><file name="sizeguide.xml" hash="abb47cb6331cc1271de76dd485bc374f"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="EasySize_SizeGuide.xml" hash="2397289fc71f8ddb23dec37aefdf4779"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="easysize"><dir name="css"><file name="easysize.sizefilter.css" hash="939a9901108e5daa86252cd98d8b9824"/></dir></dir></dir></dir></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.3.0</min><max>6.0.0</max></php></required></dependencies>
20
  </package>