easysize - Version 1.3.4

Version Notes

Bugfixes / Performance improvements

Download this release

Release Info

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


Code changes from version 1.3.3 to 1.3.4

app/code/community/EasySize/SizeGuide/Block/Data.php CHANGED
@@ -10,6 +10,10 @@ class EasySize_SizeGuide_Block_Data extends Mage_Core_Block_Template {
10
  $product_id = $this->getRequest()->getParam('id');
11
  $product = Mage::getModel('catalog/product')->load($product_id);
12
 
 
 
 
 
13
  // Get all sizeguide settings from shop configurations
14
  $shop_configuration = Mage::getStoreConfig('sizeguide/sizeguide');
15
 
@@ -80,33 +84,37 @@ class EasySize_SizeGuide_Block_Data extends Mage_Core_Block_Template {
80
  * Returns array of products' sizes in stock.
81
  */
82
  private function getProductSizesInStock($product, $size_attribute_codes) {
83
- $child_products = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null, $product);
84
  $sizes_in_stock = array();
85
- $product_attributes = Mage::getModel('eav/config')
86
- ->getEntityAttributeCodes(Mage_Catalog_Model_Product::ENTITY,$product);
87
-
88
- // Iterate through all simple products
89
- foreach ($child_products as $simple_product) {
90
- // Iterate through all size attributes
91
- foreach (explode(',', $size_attribute_codes) as $size_attribute) {
92
- if(in_array($size_attribute, $product_attributes)) {
93
- $current_simple_product_id = $simple_product->getId();
94
- $current_simple_product = Mage::getModel('catalog/product')->load($current_simple_product_id);
95
- $quantity = $current_simple_product->getStockItem()->getQty();
96
- $size = $current_simple_product->getAttributeText($size_attribute);
97
- $sizes_in_stock[$size] = $quantity;
98
-
99
- /* When looking for size attribute id,
100
- * make sure there is atleast one item of that attribute,
101
- * and attribute is actually set
102
- */
103
- if(!$this->size_attribute_id && $quantity > 0 && strlen($size) > 0) {
104
- $this->size_attribute_id = Mage::getResourceModel('eav/entity_attribute')
105
- ->getIdByCode('catalog_product', $size_attribute);
 
 
 
 
106
  }
107
  }
108
  }
109
  }
 
110
 
111
  return $sizes_in_stock;
112
  }
10
  $product_id = $this->getRequest()->getParam('id');
11
  $product = Mage::getModel('catalog/product')->load($product_id);
12
 
13
+ if($product->getTypeId() != 'configurable') {
14
+ return json_encode($required_attributes);
15
+ }
16
+
17
  // Get all sizeguide settings from shop configurations
18
  $shop_configuration = Mage::getStoreConfig('sizeguide/sizeguide');
19
 
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);
93
+
94
+ // Iterate through all simple products
95
+ foreach ($child_products as $simple_product) {
96
+ // Iterate through all size attributes
97
+ foreach (explode(',', $size_attribute_codes) as $size_attribute) {
98
+ if(in_array($size_attribute, $product_attributes)) {
99
+ $current_simple_product_id = $simple_product->getId();
100
+ $current_simple_product = Mage::getModel('catalog/product')->load($current_simple_product_id);
101
+ $quantity = $current_simple_product->getStockItem()->getQty();
102
+ $size = $current_simple_product->getAttributeText($size_attribute);
103
+ $sizes_in_stock[$size] = $quantity;
104
+
105
+ /* When looking for size attribute id,
106
+ * make sure there is atleast one item of that attribute,
107
+ * and attribute is actually set
108
+ */
109
+ if(!$this->size_attribute_id && $quantity > 0 && strlen($size) > 0) {
110
+ $this->size_attribute_id = Mage::getResourceModel('eav/entity_attribute')
111
+ ->getIdByCode('catalog_product', $size_attribute);
112
+ }
113
  }
114
  }
115
  }
116
  }
117
+
118
 
119
  return $sizes_in_stock;
120
  }
app/code/community/EasySize/SizeGuide/Model/Observer.php CHANGED
@@ -61,7 +61,7 @@ class EasySize_SizeGuide_Model_Observer {
61
  $observer->getEvent()->getCollection()->addAttributeToFilter('entity_id', array('in' => $_REQUEST['easysize_sizefilter_products']));
62
  }
63
 
64
- if (Mage::registry('easysize_sizefilter_applied')) { return; }
65
 
66
  // Get product attribute names for data extraction
67
  $shop_configuration = Mage::getStoreConfig('sizeguide/sizeguide');
@@ -97,12 +97,20 @@ class EasySize_SizeGuide_Model_Observer {
97
  $params[] = "gender={$product_gender}";
98
  $params[] = "easysize_user_id={$easysize_user_id}";
99
 
100
- $product_type = $first_item->getCategory()->getName();
101
- $product_type_decoded = urlencode($product_type);
102
- if($this->isCategoryABrand($first_item->getCategory())) {
103
- $params[] = "brand={$product_type_decoded}";
 
 
 
 
104
  } else {
105
- $params[] = "category={$product_type_decoded}";
 
 
 
 
106
  }
107
 
108
  $params = implode('&', $params);
61
  $observer->getEvent()->getCollection()->addAttributeToFilter('entity_id', array('in' => $_REQUEST['easysize_sizefilter_products']));
62
  }
63
 
64
+ if (Mage::registry('easysize_sizefilter_applied') || Mage::getStoreConfig('sizeguide/sizefilter/sizefilter_enabled') != 1) { return; }
65
 
66
  // Get product attribute names for data extraction
67
  $shop_configuration = Mage::getStoreConfig('sizeguide/sizeguide');
97
  $params[] = "gender={$product_gender}";
98
  $params[] = "easysize_user_id={$easysize_user_id}";
99
 
100
+ if($first_item->getCategory() && $product_type = $first_item->getCategory()->getName()) {
101
+ $product_type_decoded = urlencode($product_type);
102
+
103
+ if($this->isCategoryABrand($first_item->getCategory())) {
104
+ $params[] = "brand={$product_type_decoded}";
105
+ } else {
106
+ $params[] = "category={$product_type_decoded}";
107
+ }
108
  } else {
109
+ /*
110
+ If product attribute extraction fails, register a notice to not have an overload
111
+ */
112
+ Mage::register('easysize_sizefilter_applied', true);
113
+ return;
114
  }
115
 
116
  $params = implode('&', $params);
app/code/community/EasySize/SizeGuide/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <EasySize_SizeGuide>
5
- <version>1.3.2</version>
6
  </EasySize_SizeGuide>
7
  </modules>
8
 
2
  <config>
3
  <modules>
4
  <EasySize_SizeGuide>
5
+ <version>1.3.4</version>
6
  </EasySize_SizeGuide>
7
  </modules>
8
 
app/code/community/EasySize/SizeGuide/sql/sizeguide_setup/{install-1.3.2.php → install-1.3.4.php} RENAMED
File without changes
app/design/frontend/base/default/template/sizeguide/easysize.phtml CHANGED
@@ -1,4 +1,14 @@
1
- <script type="text/javascript" src="https://webapp.easysize.me/web_app_v1.0/js/easysize.js"></script>
2
- <script>
3
- var EasySize = new EasySize(<?php echo $this->getRequiredAttributes(); ?>).start();
4
- </script>
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $easysize_attributes = $this->getRequiredAttributes();
3
+ if(json_decode($easysize_attributes)->product_id): ?>
4
+ <script type="text/javascript" src="https://webapp.easysize.me/web_app_v1.0/js/easysize.js"></script>
5
+ <script>
6
+ var EasySize = new EasySize(<?php echo $easysize_attributes; ?>);
7
+
8
+ try {
9
+ EasySize.start();
10
+ } catch(e) {
11
+ console.log(e);
12
+ }
13
+ </script>
14
+ <?php endif; ?>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>easysize</name>
4
- <version>1.3.3</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>Bugfixes</notes>
12
  <authors><author><name>EasySize IVS</name><user>EasySize</user><email>gk@easysize.me</email></author></authors>
13
- <date>2016-08-10</date>
14
- <time>07:14:53</time>
15
- <contents><target name="magecommunity"><dir name="EasySize"><dir name="SizeGuide"><dir name="Block"><file name="Data.php" hash="7d63c155296507f45dc7c1b64ac98738"/></dir><dir name="Helper"><file name="Data.php" hash="e1f1c548146a5eedc58222620232a758"/></dir><dir name="Model"><file name="Observer.php" hash="4f2c957fb064a7656da69423780d8715"/><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="3ad377cb124d49565e7fff17482bcf14"/><file name="system.xml" hash="3b9d574c828581df0c306608eb0aeae1"/></dir><dir name="sql"><dir name="sizeguide_setup"><file name="install-1.3.2.php" hash="1eedf0393e809afca2e652cfc051a8b9"/></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="04a9b0118af89064f1ceb527289f1f6d"/><file name="sizefilter.phtml" hash="5a69281f7936b57eb1b363568e7b8a50"/></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.3.4</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>Bugfixes / Performance improvements</notes>
12
  <authors><author><name>EasySize IVS</name><user>EasySize</user><email>gk@easysize.me</email></author></authors>
13
+ <date>2016-08-12</date>
14
+ <time>11:02:28</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="82099c21aefe4c2affd21ca453716498"/><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="b3cca47a72ad239114c6ef3ac5667c84"/><file name="system.xml" hash="3b9d574c828581df0c306608eb0aeae1"/></dir><dir name="sql"><dir name="sizeguide_setup"><file name="install-1.3.4.php" hash="1eedf0393e809afca2e652cfc051a8b9"/></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="6ac08d92b89649dd1384ac190eb1865c"/><file name="sizefilter.phtml" hash="5a69281f7936b57eb1b363568e7b8a50"/></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>