Web4pro_Stockstatus - Version 1.0.5

Version Notes

Version number: 1.0.1;
Version number: 1.0.2;
- Ability to add custom image at stockstatus;
Version number: 1.0.3;
- correct swatches behavior;
Version number: 1.0.4;
- grouped and bandle products fix

Download this release

Release Info

Developer Sergey Poprigin
Extension Web4pro_Stockstatus
Version 1.0.5
Comparing to
See all releases


Code changes from version 1.0.4 to 1.0.5

Files changed (33) hide show
  1. app/code/community/Web4pro/Stockstatus/Block/Adminhtml/Catalog/Product/Attribute/Options.php +92 -92
  2. app/code/community/Web4pro/Stockstatus/Block/Adminhtml/Catalog/Product/Attribute/Options.php~ +0 -92
  3. app/code/community/Web4pro/Stockstatus/Block/Catalog/Product/View/Type/Bundle/Option.php +62 -62
  4. app/code/community/Web4pro/Stockstatus/Block/Catalog/Product/View/Type/Bundle/Option/Checkbox.php +28 -28
  5. app/code/community/Web4pro/Stockstatus/Block/Catalog/Product/View/Type/Bundle/Option/Multi.php +28 -28
  6. app/code/community/Web4pro/Stockstatus/Block/Catalog/Product/View/Type/Bundle/Option/Radio.php +28 -28
  7. app/code/community/Web4pro/Stockstatus/Block/Catalog/Product/View/Type/Bundle/Option/Select.php +28 -28
  8. app/code/community/Web4pro/Stockstatus/Block/Catalog/Product/View/Type/Configurable.php +49 -43
  9. app/code/community/Web4pro/Stockstatus/Block/Stockstatus.php +75 -66
  10. app/code/community/Web4pro/Stockstatus/Helper/Cms/Wysiwyg/Images.php +33 -33
  11. app/code/community/Web4pro/Stockstatus/Helper/Data.php +238 -210
  12. app/code/community/Web4pro/Stockstatus/Model/Catalog/Resource/Eav/Mysql4/Attribute.php +100 -100
  13. app/code/community/Web4pro/Stockstatus/Model/Eav/Entity/Attribute/Source/Table.php +35 -35
  14. app/code/community/Web4pro/Stockstatus/Model/Eav/Mysql4/Entity/Attribute/Option.php +29 -29
  15. app/code/community/Web4pro/Stockstatus/Model/Observer.php +160 -158
  16. app/code/community/Web4pro/Stockstatus/Model/Observer.php~ +0 -158
  17. app/code/community/Web4pro/Stockstatus/controllers/Cms/Wysiwyg/ImagesController.php +34 -34
  18. app/code/community/Web4pro/Stockstatus/etc/adminhtml.xml +32 -32
  19. app/code/community/Web4pro/Stockstatus/etc/config.xml +210 -210
  20. app/code/community/Web4pro/Stockstatus/etc/system.xml +112 -103
  21. app/code/community/Web4pro/Stockstatus/sql/web4pro_stockstatus_setup/install-1.0.0.php +65 -65
  22. app/code/community/Web4pro/Stockstatus/sql/web4pro_stockstatus_setup/install-1.0.0.php~ +0 -65
  23. app/code/community/Web4pro/Stockstatus/sql/web4pro_stockstatus_setup/upgrade-1.0.0-1.0.2.php +24 -24
  24. app/code/community/Web4pro/Stockstatus/sql/web4pro_stockstatus_setup/upgrade-1.0.2-1.0.3.php +48 -48
  25. app/code/community/Web4pro/Stockstatus/sql/web4pro_stockstatus_setup/upgrade-1.0.2-1.0.3.php~ +0 -46
  26. app/code/community/Web4pro/Stockstatus/sql/web4pro_stockstatus_setup/upgrade-1.0.3-1.0.4.php +22 -22
  27. app/design/adminhtml/default/default/template/stockstatus/catalog/product/attribute/options.phtml +199 -199
  28. app/design/frontend/base/default/layout/web4pro_stockstatus.xml +29 -29
  29. app/design/frontend/base/default/template/web4pro_stockstatus/catalog/product/view/type/grouped.phtml +93 -93
  30. app/etc/modules/Web4pro_Stockstatus.xml +20 -20
  31. app/locale/en_US/Web4pro_Stockstatus.csv +18 -18
  32. package.xml +12 -12
  33. skin/frontend/base/default/js/web4pro/stockstatus/stockstatus.js +158 -158
app/code/community/Web4pro/Stockstatus/Block/Adminhtml/Catalog/Product/Attribute/Options.php CHANGED
@@ -1,92 +1,92 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <spoprigin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Product options block
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <spoprigin@corp.web4pro.com.ua>
17
- */
18
-
19
- class Web4pro_Stockstatus_Block_Adminhtml_Catalog_Product_Attribute_Options extends Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract
20
- {
21
- public function __construct()
22
- {
23
- parent::__construct();
24
- if (Mage::registry('entity_attribute')->getData('attribute_code') == 'custom_stockstatus') {
25
- $this->setTemplate('stockstatus/catalog/product/attribute/options.phtml');
26
- }
27
- }
28
-
29
- public function getOptionValues()
30
- {
31
- if (Mage::registry('entity_attribute')->getData('attribute_code') != 'custom_stockstatus') {
32
- return parent::getOptionValues();
33
- }
34
-
35
- $attributeType = $this->getAttributeObject()->getFrontendInput();
36
- $defaultValues = $this->getAttributeObject()->getDefaultValue();
37
- if ($attributeType == 'select' || $attributeType == 'multiselect') {
38
- $defaultValues = explode(',', $defaultValues);
39
- } else {
40
- $defaultValues = array();
41
- }
42
-
43
- switch ($attributeType) {
44
- case 'select':
45
- $inputType = 'radio';
46
- break;
47
- case 'multiselect':
48
- $inputType = 'checkbox';
49
- break;
50
- default:
51
- $inputType = '';
52
- break;
53
- }
54
-
55
- $values = $this->getData('option_values');
56
- if (is_null($values)) {
57
- $values = array();
58
- $optionCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
59
- ->setAttributeFilter($this->getAttributeObject()->getId())
60
- ->setPositionOrder('desc', true)
61
- ->load();
62
-
63
- foreach ($optionCollection as $option) {
64
- $value = array();
65
- if (in_array($option->getId(), $defaultValues)) {
66
- $value['checked'] = 'checked="checked"';
67
- } else {
68
- $value['checked'] = '';
69
- }
70
-
71
- $value['intype'] = $inputType;
72
- $value['id'] = $option->getId();
73
- $value['sort_order'] = $option->getSortOrder();
74
- $value['image'] = $option->getImage();
75
- foreach ($this->getStores() as $store) {
76
- $storeValues = $this->getStoreOptionValues($store->getId());
77
- if (isset($storeValues[$option->getId()])) {
78
- $value['store'.$store->getId()] = htmlspecialchars($storeValues[$option->getId()]);
79
- }
80
- else {
81
- $value['store'.$store->getId()] = '';
82
- }
83
- }
84
- $values[] = new Varien_Object($value);
85
- }
86
- $this->setData('option_values', $values);
87
- }
88
-
89
- return $values;
90
- }
91
-
92
- }
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <spoprigin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+ /**
12
+ * Product options block
13
+ *
14
+ * @category Web4pro
15
+ * @package Web4pro_Stockstatus
16
+ * @author WEB4PRO <spoprigin@corp.web4pro.com.ua>
17
+ */
18
+
19
+ class Web4pro_Stockstatus_Block_Adminhtml_Catalog_Product_Attribute_Options extends Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract
20
+ {
21
+ public function __construct()
22
+ {
23
+ parent::__construct();
24
+ if (Mage::registry('entity_attribute')->getData('attribute_code') == 'custom_stockstatus') {
25
+ $this->setTemplate('stockstatus/catalog/product/attribute/options.phtml');
26
+ }
27
+ }
28
+
29
+ public function getOptionValues()
30
+ {
31
+ if (Mage::registry('entity_attribute')->getData('attribute_code') != 'custom_stockstatus') {
32
+ return parent::getOptionValues();
33
+ }
34
+
35
+ $attributeType = $this->getAttributeObject()->getFrontendInput();
36
+ $defaultValues = $this->getAttributeObject()->getDefaultValue();
37
+ if ($attributeType == 'select' || $attributeType == 'multiselect') {
38
+ $defaultValues = explode(',', $defaultValues);
39
+ } else {
40
+ $defaultValues = array();
41
+ }
42
+
43
+ switch ($attributeType) {
44
+ case 'select':
45
+ $inputType = 'radio';
46
+ break;
47
+ case 'multiselect':
48
+ $inputType = 'checkbox';
49
+ break;
50
+ default:
51
+ $inputType = '';
52
+ break;
53
+ }
54
+
55
+ $values = $this->getData('option_values');
56
+ if (is_null($values)) {
57
+ $values = array();
58
+ $optionCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
59
+ ->setAttributeFilter($this->getAttributeObject()->getId())
60
+ ->setPositionOrder('desc', true)
61
+ ->load();
62
+
63
+ foreach ($optionCollection as $option) {
64
+ $value = array();
65
+ if (in_array($option->getId(), $defaultValues)) {
66
+ $value['checked'] = 'checked="checked"';
67
+ } else {
68
+ $value['checked'] = '';
69
+ }
70
+
71
+ $value['intype'] = $inputType;
72
+ $value['id'] = $option->getId();
73
+ $value['sort_order'] = $option->getSortOrder();
74
+ $value['image'] = $option->getImage();
75
+ foreach ($this->getStores() as $store) {
76
+ $storeValues = $this->getStoreOptionValues($store->getId());
77
+ if (isset($storeValues[$option->getId()])) {
78
+ $value['store'.$store->getId()] = htmlspecialchars($storeValues[$option->getId()]);
79
+ }
80
+ else {
81
+ $value['store'.$store->getId()] = '';
82
+ }
83
+ }
84
+ $values[] = new Varien_Object($value);
85
+ }
86
+ $this->setData('option_values', $values);
87
+ }
88
+
89
+ return $values;
90
+ }
91
+
92
+ }
app/code/community/Web4pro/Stockstatus/Block/Adminhtml/Catalog/Product/Attribute/Options.php~ DELETED
@@ -1,92 +0,0 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Product options block
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
- */
18
-
19
- class Web4pro_Stockstatus_Block_Adminhtml_Catalog_Product_Attribute_Options extends Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract
20
- {
21
- public function __construct()
22
- {
23
- parent::__construct();
24
- if (Mage::registry('entity_attribute')->getData('attribute_code') == 'custom_stockstatus') {
25
- $this->setTemplate('stockstatus/catalog/product/attribute/options.phtml');
26
- }
27
- }
28
-
29
- public function getOptionValues()
30
- {
31
- if (Mage::registry('entity_attribute')->getData('attribute_code') != 'custom_stockstatus') {
32
- return parent::getOptionValues();
33
- }
34
-
35
- $attributeType = $this->getAttributeObject()->getFrontendInput();
36
- $defaultValues = $this->getAttributeObject()->getDefaultValue();
37
- if ($attributeType == 'select' || $attributeType == 'multiselect') {
38
- $defaultValues = explode(',', $defaultValues);
39
- } else {
40
- $defaultValues = array();
41
- }
42
-
43
- switch ($attributeType) {
44
- case 'select':
45
- $inputType = 'radio';
46
- break;
47
- case 'multiselect':
48
- $inputType = 'checkbox';
49
- break;
50
- default:
51
- $inputType = '';
52
- break;
53
- }
54
-
55
- $values = $this->getData('option_values');
56
- if (is_null($values)) {
57
- $values = array();
58
- $optionCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
59
- ->setAttributeFilter($this->getAttributeObject()->getId())
60
- ->setPositionOrder('desc', true)
61
- ->load();
62
-
63
- foreach ($optionCollection as $option) {
64
- $value = array();
65
- if (in_array($option->getId(), $defaultValues)) {
66
- $value['checked'] = 'checked="checked"';
67
- } else {
68
- $value['checked'] = '';
69
- }
70
-
71
- $value['intype'] = $inputType;
72
- $value['id'] = $option->getId();
73
- $value['sort_order'] = $option->getSortOrder();
74
- $value['image'] = $option->getImage();
75
- foreach ($this->getStores() as $store) {
76
- $storeValues = $this->getStoreOptionValues($store->getId());
77
- if (isset($storeValues[$option->getId()])) {
78
- $value['store'.$store->getId()] = htmlspecialchars($storeValues[$option->getId()]);
79
- }
80
- else {
81
- $value['store'.$store->getId()] = '';
82
- }
83
- }
84
- $values[] = new Varien_Object($value);
85
- }
86
- $this->setData('option_values', $values);
87
- }
88
-
89
- return $values;
90
- }
91
-
92
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Web4pro/Stockstatus/Block/Catalog/Product/View/Type/Bundle/Option.php CHANGED
@@ -1,63 +1,63 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Attachments default helper
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
- */
18
-
19
- class Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option extends Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option
20
- {
21
- /**
22
- * Returns the formatted string for the quantity chosen for the given selection
23
- *
24
- * @param Mage_Catalog_Model_Proudct $_selection
25
- * @param bool $includeContainer
26
- * @return string
27
- */
28
- public function getSelectionQtyTitlePrice($_selection, $includeContainer = true)
29
- {
30
- $price = $this->getProduct()->getPriceModel()->getSelectionPreFinalPrice($this->getProduct(), $_selection);
31
- $_selectionProduct = Mage::getModel('catalog/product')->load($_selection->getId());
32
- $stockStatus = Mage::helper('web4pro_stockstatus')->getNewStockStatus($_selectionProduct);
33
- if($stockStatus)
34
- {
35
- $stockStatus = '(' . $stockStatus . ') &nbsp; ';
36
- }
37
-
38
- return $_selection->getSelectionQty()*1 . ' x ' . $_selection->getName() . ' &nbsp; ' . $stockStatus .
39
- ($includeContainer ? '<span class="price-notice">':'') . '+' .
40
- $this->formatPriceString($price, $includeContainer) . ($includeContainer ? '</span>':'');
41
- }
42
-
43
-
44
- /**
45
- * Get title price for selection product
46
- *
47
- * @param Mage_Catalog_Model_Product $_selection
48
- * @param bool $includeContainer
49
- * @return string
50
- */
51
- public function getSelectionTitlePrice($_selection, $includeContainer = true)
52
- {
53
- $price = $this->getProduct()->getPriceModel()->getSelectionPreFinalPrice($this->getProduct(), $_selection, 1);
54
- $_selectionProduct = Mage::getModel('catalog/product')->load($_selection->getId());
55
- $stockStatus = Mage::helper('web4pro_stockstatus')->getNewStockStatus($_selectionProduct);
56
- if($stockStatus)
57
- {
58
- $stockStatus = '(' . $stockStatus . ') &nbsp; ';
59
- }
60
- return $_selection->getName() . ' &nbsp; ' . $stockStatus . ($includeContainer ? '<span class="price-notice">':'') . '+' .
61
- $this->formatPriceString($price, $includeContainer) . ($includeContainer ? '</span>':'');
62
- }
63
  }
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+ /**
12
+ * Attachments default helper
13
+ *
14
+ * @category Web4pro
15
+ * @package Web4pro_Stockstatus
16
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
+ */
18
+
19
+ class Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option extends Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option
20
+ {
21
+ /**
22
+ * Returns the formatted string for the quantity chosen for the given selection
23
+ *
24
+ * @param Mage_Catalog_Model_Proudct $_selection
25
+ * @param bool $includeContainer
26
+ * @return string
27
+ */
28
+ public function getSelectionQtyTitlePrice($_selection, $includeContainer = true)
29
+ {
30
+ $price = $this->getProduct()->getPriceModel()->getSelectionPreFinalPrice($this->getProduct(), $_selection);
31
+ $_selectionProduct = Mage::getModel('catalog/product')->load($_selection->getId());
32
+ $stockStatus = Mage::helper('web4pro_stockstatus')->getNewStockStatus($_selectionProduct);
33
+ if($stockStatus)
34
+ {
35
+ $stockStatus = '(' . $stockStatus . ') &nbsp; ';
36
+ }
37
+
38
+ return $_selection->getSelectionQty()*1 . ' x ' . $_selection->getName() . ' &nbsp; ' . $stockStatus .
39
+ ($includeContainer ? '<span class="price-notice">':'') . '+' .
40
+ $this->formatPriceString($price, $includeContainer) . ($includeContainer ? '</span>':'');
41
+ }
42
+
43
+
44
+ /**
45
+ * Get title price for selection product
46
+ *
47
+ * @param Mage_Catalog_Model_Product $_selection
48
+ * @param bool $includeContainer
49
+ * @return string
50
+ */
51
+ public function getSelectionTitlePrice($_selection, $includeContainer = true)
52
+ {
53
+ $price = $this->getProduct()->getPriceModel()->getSelectionPreFinalPrice($this->getProduct(), $_selection, 1);
54
+ $_selectionProduct = Mage::getModel('catalog/product')->load($_selection->getId());
55
+ $stockStatus = Mage::helper('web4pro_stockstatus')->getNewStockStatus($_selectionProduct);
56
+ if($stockStatus)
57
+ {
58
+ $stockStatus = '(' . $stockStatus . ') &nbsp; ';
59
+ }
60
+ return $_selection->getName() . ' &nbsp; ' . $stockStatus . ($includeContainer ? '<span class="price-notice">':'') . '+' .
61
+ $this->formatPriceString($price, $includeContainer) . ($includeContainer ? '</span>':'');
62
+ }
63
  }
app/code/community/Web4pro/Stockstatus/Block/Catalog/Product/View/Type/Bundle/Option/Checkbox.php CHANGED
@@ -1,29 +1,29 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Attachments default helper
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
- */
18
- class Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option_Checkbox extends Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option
19
- {
20
- /**
21
- * Set template
22
- *
23
- * @return void
24
- */
25
- public function _construct()
26
- {
27
- $this->setTemplate('bundle/catalog/product/view/type/bundle/option/checkbox.phtml');
28
- }
29
  }
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+ /**
12
+ * Attachments default helper
13
+ *
14
+ * @category Web4pro
15
+ * @package Web4pro_Stockstatus
16
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
+ */
18
+ class Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option_Checkbox extends Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option
19
+ {
20
+ /**
21
+ * Set template
22
+ *
23
+ * @return void
24
+ */
25
+ public function _construct()
26
+ {
27
+ $this->setTemplate('bundle/catalog/product/view/type/bundle/option/checkbox.phtml');
28
+ }
29
  }
app/code/community/Web4pro/Stockstatus/Block/Catalog/Product/View/Type/Bundle/Option/Multi.php CHANGED
@@ -1,29 +1,29 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Attachments default helper
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
- */
18
- class Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option_Multi extends Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option
19
- {
20
- /**
21
- * Set template
22
- *
23
- * @return void
24
- */
25
- public function _construct()
26
- {
27
- $this->setTemplate('bundle/catalog/product/view/type/bundle/option/multi.phtml');
28
- }
29
  }
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+ /**
12
+ * Attachments default helper
13
+ *
14
+ * @category Web4pro
15
+ * @package Web4pro_Stockstatus
16
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
+ */
18
+ class Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option_Multi extends Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option
19
+ {
20
+ /**
21
+ * Set template
22
+ *
23
+ * @return void
24
+ */
25
+ public function _construct()
26
+ {
27
+ $this->setTemplate('bundle/catalog/product/view/type/bundle/option/multi.phtml');
28
+ }
29
  }
app/code/community/Web4pro/Stockstatus/Block/Catalog/Product/View/Type/Bundle/Option/Radio.php CHANGED
@@ -1,29 +1,29 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Attachments default helper
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
- */
18
- class Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option_Radio extends Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option
19
- {
20
- /**
21
- * Set template
22
- *
23
- * @return void
24
- */
25
- public function _construct()
26
- {
27
- $this->setTemplate('bundle/catalog/product/view/type/bundle/option/radio.phtml');
28
- }
29
  }
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+ /**
12
+ * Attachments default helper
13
+ *
14
+ * @category Web4pro
15
+ * @package Web4pro_Stockstatus
16
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
+ */
18
+ class Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option_Radio extends Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option
19
+ {
20
+ /**
21
+ * Set template
22
+ *
23
+ * @return void
24
+ */
25
+ public function _construct()
26
+ {
27
+ $this->setTemplate('bundle/catalog/product/view/type/bundle/option/radio.phtml');
28
+ }
29
  }
app/code/community/Web4pro/Stockstatus/Block/Catalog/Product/View/Type/Bundle/Option/Select.php CHANGED
@@ -1,29 +1,29 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Attachments default helper
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
- */
18
- class Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option_Select extends Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option
19
- {
20
- /**
21
- * Set template
22
- *
23
- * @return void
24
- */
25
- public function _construct()
26
- {
27
- $this->setTemplate('bundle/catalog/product/view/type/bundle/option/select.phtml');
28
- }
29
  }
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+ /**
12
+ * Attachments default helper
13
+ *
14
+ * @category Web4pro
15
+ * @package Web4pro_Stockstatus
16
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
+ */
18
+ class Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option_Select extends Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option
19
+ {
20
+ /**
21
+ * Set template
22
+ *
23
+ * @return void
24
+ */
25
+ public function _construct()
26
+ {
27
+ $this->setTemplate('bundle/catalog/product/view/type/bundle/option/select.phtml');
28
+ }
29
  }
app/code/community/Web4pro/Stockstatus/Block/Catalog/Product/View/Type/Configurable.php CHANGED
@@ -1,44 +1,50 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Attachments default helper
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
- */
18
-
19
- class Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Configurable extends Mage_Catalog_Block_Product_View_Type_Configurable
20
- {
21
- /**
22
- * Composes configuration for js
23
- *
24
- * @return string
25
- */
26
- public function getJsonConfig()
27
- {
28
- $config = parent::getJsonConfig();
29
- $config = Mage::helper('core')->jsonDecode($config);
30
- $stockstatuses = array();
31
- $helper = Mage::helper('web4pro_stockstatus');
32
- $_product = $this->getProduct();
33
- $ids = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($_product->getId());
34
- $_subproducts = Mage::getModel('catalog/product')->getCollection()
35
- ->addAttributeToFilter('entity_id', $ids)
36
- ->addAttributeToSelect('*');
37
- foreach ($_subproducts as $product){
38
- $stockstatuses[$product->getId()]["stockstatus"] = $helper->getNewStockStatus($product);
39
- $config['stockstatuses'] = $stockstatuses;
40
- $config['availability'] = $helper->__('Availability:');
41
- }
42
- return Mage::helper('core')->jsonEncode($config);
43
- }
 
 
 
 
 
 
44
  }
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+ /**
12
+ * Attachments default helper
13
+ *
14
+ * @category Web4pro
15
+ * @package Web4pro_Stockstatus
16
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
+ */
18
+
19
+ class Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Configurable extends Mage_Catalog_Block_Product_View_Type_Configurable
20
+ {
21
+ /**
22
+ * Composes configuration for js
23
+ *
24
+ * @return string
25
+ */
26
+ public function getJsonConfig()
27
+ {
28
+ $config = parent::getJsonConfig();
29
+ $config = Mage::helper('core')->jsonDecode($config);
30
+ $stockstatuses = array();
31
+ $helper = Mage::helper('web4pro_stockstatus');
32
+ $_product = $this->getProduct();
33
+ $observer = Mage::getModel('web4pro_stockstatus/observer');
34
+ $productViewFlag = $helper->isCustomStockStatusOnProductViewPage();
35
+
36
+ $ids = Mage::getModel('catalog/product_type_configurable')->getChildrenIds($_product->getId());
37
+ $_subproducts = Mage::getModel('catalog/product')->getCollection()
38
+ ->addAttributeToFilter('entity_id', $ids)
39
+ ->addAttributeToSelect('*');
40
+
41
+ foreach ($_subproducts as $product){
42
+ $stockstatuses[$product->getId()]["stockstatus"] = $helper->getNewStockStatus($product);
43
+ $images[$product->getId()]['stock_image'] = $productViewFlag ? $observer->getStockStatusImage($product) : "";
44
+ }
45
+ $config['stockstatuses'] = $stockstatuses;
46
+ $config['stock_images'] = $images;
47
+ $config['availability'] = $helper->__('Availability:');
48
+ return Mage::helper('core')->jsonEncode($config);
49
+ }
50
  }
app/code/community/Web4pro/Stockstatus/Block/Stockstatus.php CHANGED
@@ -1,67 +1,76 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Attachments default helper
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
- */
18
-
19
- class Web4pro_Stockstatus_Block_Stockstatus extends Mage_Core_Block_Text
20
- {
21
-
22
-
23
- /**
24
- * Replace stock statuses at product list and cart pages
25
- * @param $transport
26
- * @param $stockstatuses
27
- */
28
- public function replaceStockStatuses($transport, $stockstatuses)
29
- {
30
- $script = '
31
- <script type="text/javascript">
32
- //<![CDATA[
33
- document.observe("dom:loaded", function() {
34
- if($$("h2.product-name").first()){
35
- var stockstatuses = '. Mage::helper('core')->jsonEncode($stockstatuses) . ';' .
36
- 'stockstatuses.each(function(name, index){
37
- $$("h2.product-name")[index].insert({after:name})
38
- })
39
- }
40
- });
41
- //]]>
42
- </script>
43
- ';
44
- $text = $transport . $script;
45
- $this->setData('text', $text);
46
- }
47
-
48
- /**
49
- * Replace sotck status at product view page
50
- * @param $transport
51
- * @param $stockstatus
52
- */
53
- public function replaceStockStatus($transport, $stockstatus)
54
- {
55
- $script = '<script type="text/javascript">
56
- //<![CDATA[
57
- document.observe("dom:loaded", function() {
58
- $$("p.availability").first().update("'. $stockstatus .'");
59
- Product.Config.standartStockStatus = "'.$stockstatus.'";
60
- });
61
- //]]>
62
- </script>
63
- ';
64
- $text = $transport . $script;
65
- $this->setData('text', $text);
66
- }
 
 
 
 
 
 
 
 
 
67
  }
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+ /**
12
+ * Attachments default helper
13
+ *
14
+ * @category Web4pro
15
+ * @package Web4pro_Stockstatus
16
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
+ */
18
+
19
+ class Web4pro_Stockstatus_Block_Stockstatus extends Mage_Core_Block_Text
20
+ {
21
+
22
+
23
+ /**
24
+ * Replace stock statuses at product list and cart pages
25
+ * @param $transport
26
+ * @param $stockstatuses
27
+ */
28
+ public function replaceStockStatuses($transport, $stockstatuses)
29
+ {
30
+ $script = '
31
+ <script type="text/javascript">
32
+ //<![CDATA[
33
+ document.observe("dom:loaded", function() {
34
+ if($$("h2.product-name").first()){
35
+ var stockstatuses = '. Mage::helper('core')->jsonEncode($stockstatuses) . ';' .
36
+ 'stockstatuses.each(function(name, index){
37
+ $$("h2.product-name")[index].insert({after:name})
38
+ })
39
+ }
40
+ });
41
+ //]]>
42
+ </script>
43
+ ';
44
+ $text = $transport . $script;
45
+ $this->setData('text', $text);
46
+ }
47
+
48
+ /**
49
+ * Replace sotck status at product view page
50
+ * @param $transport
51
+ * @param $stockstatus
52
+ * @param $product
53
+ */
54
+ public function replaceStockStatus($transport, $stockstatus, $product)
55
+ {
56
+ $helper = $this->helper('web4pro_stockstatus');
57
+ $stockImage = '';
58
+
59
+ if($helper->isCustomStockStatusOnProductViewPage()){
60
+ $observer = Mage::getModel('web4pro_stockstatus/observer');
61
+ $stockImage = $observer->getStockStatusImage($product);
62
+ }
63
+
64
+ $script = '<script type="text/javascript">
65
+ //<![CDATA[
66
+ document.observe("dom:loaded", function() {
67
+ $$("p.availability").first().update(\''. $stockImage . $stockstatus .'\');
68
+ Product.Config.standartStockStatus = \'' . $stockImage . $stockstatus .'\';
69
+ });
70
+ //]]>
71
+ </script>
72
+ ';
73
+ $text = $transport . $script;
74
+ $this->setData('text', $text);
75
+ }
76
  }
app/code/community/Web4pro/Stockstatus/Helper/Cms/Wysiwyg/Images.php CHANGED
@@ -1,34 +1,34 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Stockstatus images helper
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
- */
18
-
19
- class Web4pro_Stockstatus_Helper_Cms_Wysiwyg_Images extends Mage_Cms_Helper_Wysiwyg_Images
20
- {
21
-
22
- /**
23
- * Check using static urls allowed
24
- * @return bool
25
- */
26
- public function isUsingStaticUrlsAllowed()
27
- {
28
- if (Mage::getSingleton('adminhtml/session')->getStaticUrlsAllowed()) {
29
- return true;
30
- }
31
-
32
- return parent::isUsingStaticUrlsAllowed();
33
- }
34
  }
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+ /**
12
+ * Stockstatus images helper
13
+ *
14
+ * @category Web4pro
15
+ * @package Web4pro_Stockstatus
16
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
+ */
18
+
19
+ class Web4pro_Stockstatus_Helper_Cms_Wysiwyg_Images extends Mage_Cms_Helper_Wysiwyg_Images
20
+ {
21
+
22
+ /**
23
+ * Check using static urls allowed
24
+ * @return bool
25
+ */
26
+ public function isUsingStaticUrlsAllowed()
27
+ {
28
+ if (Mage::getSingleton('adminhtml/session')->getStaticUrlsAllowed()) {
29
+ return true;
30
+ }
31
+
32
+ return parent::isUsingStaticUrlsAllowed();
33
+ }
34
  }
app/code/community/Web4pro/Stockstatus/Helper/Data.php CHANGED
@@ -1,211 +1,239 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Stockstatus default helper
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
- */
18
- class Web4pro_Stockstatus_Helper_Data extends Mage_Core_Helper_Abstract
19
- {
20
- /**
21
- * Get default stock status of product
22
- * @param $product
23
- * @return string
24
- */
25
- public function getDefaultStockStatus($product)
26
- {
27
- if($product->isAvailable()){
28
- $result = $this->__('In stock');
29
- }
30
- else{
31
- $result = $this->__('Out of stock');
32
- }
33
- return $result;
34
- }
35
-
36
-
37
- /**
38
- * Get custom stock status of product
39
- * @param $product
40
- * @return string
41
- */
42
- public function getCustomStockStatus($product)
43
- {
44
- $customStockStatus = '';
45
- if (($product->isAvailable() || $this->isCustomStockStatusOnOutOfStock()) && $this->checkNumberProductsForCustomStatus($product)) {
46
- $customStockStatus = $product->getAttributeText('custom_stockstatus');
47
- }
48
- return $customStockStatus;
49
- }
50
-
51
- /**
52
- * check number of products for custom stock status (count_products field)
53
- * @param object $product
54
- * @return bool
55
- */
56
- public function checkNumberProductsForCustomStatus($product){
57
- $count = $product->getData('count_products');
58
- if(!in_array($product->getTypeID(), $this->getProductTypesForCount())) return true;
59
- $strockQty = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
60
- return $count <= $strockQty;
61
- }
62
-
63
-
64
- /**
65
- * Get new stock status based on default and custom
66
- * @param object $product
67
- * @return string
68
- */
69
- public function getNewStockStatus($product)
70
- {
71
- $defaultStockStatus = $this->getDefaultStockStatus($product);
72
- $customStockStatus = $this->getCustomStockStatus($product);
73
- if ($this->isShowStockLevel() && $product->getStockItem()->getQty() && in_array($product->getTypeID(), $this->getProductTypesForCount())) {
74
- $levelStockStatus = $this->__('%s in stock', (int)$product->getStockItem()->getQty());
75
- return $levelStockStatus . ' ' . $customStockStatus;
76
- }
77
- if(!strlen($customStockStatus)){
78
- return $defaultStockStatus;
79
- }else if ($this->isDefaultStockStatusHidden($product)){
80
- return $customStockStatus;
81
- } else {
82
- return $defaultStockStatus . ' ' . $customStockStatus;
83
- }
84
- }
85
-
86
-
87
- /**
88
- * Check whether to hide a ddefault status
89
- * @param object $product
90
- * @return mixed
91
- */
92
- public function isDefaultStockStatusHidden($product)
93
- {
94
- return $product->getData('hide_default_stockstatus');
95
- }
96
-
97
- /**
98
- * Is the custom status allowed at page of category
99
- * @return mixed
100
- */
101
- public function isCustomStockStatusOnProductListPage()
102
- {
103
- return Mage::getStoreConfig('web4pro_stockstatus/general/display_at_category');
104
- }
105
-
106
- /**
107
- * Is the custom status allowed at page of shoping cart
108
- * @return mixed
109
- */
110
- public function isCustomStockStatusInShoppingCart()
111
- {
112
- return Mage::getStoreConfig('web4pro_stockstatus/general/display_in_cart');
113
- }
114
-
115
- /**
116
- * Is the custom status allowed for Out of stock products
117
- * @return mixed
118
- */
119
- public function isCustomStockStatusOnOutOfStock()
120
- {
121
- return Mage::getStoreConfig('web4pro_stockstatus/general/outofstock');
122
- }
123
-
124
- /**
125
- * Is stock qty displayed
126
- * @return mixed
127
- */
128
- public function isShowStockLevel()
129
- {
130
- return Mage::getStoreConfig('web4pro_stockstatus/general/showstocklevel');
131
- }
132
-
133
-
134
- /**
135
- * Is show icon
136
- * @return mixed
137
- */
138
- public function isShowStockImage()
139
- {
140
- return Mage::getStoreConfig('web4pro_stockstatus/general/showimage');
141
- }
142
-
143
- /**
144
- * Is show icon only
145
- * @return mixed
146
- */
147
- public function isShowStockImageOnly()
148
- {
149
- return Mage::getStoreConfig('web4pro_stockstatus/general/showimageonly');
150
- }
151
-
152
- /**
153
- * Is the custom status allowed at page of product view
154
- * @param $product
155
- * @return string
156
- */
157
- public function showStockStatus($product)
158
- {
159
- $result = '';
160
- if ($this->isCustomStockStatusOnProductListPage()){
161
- $result = $this->getNewStockStatus($product);
162
- }
163
- return $result;
164
- }
165
-
166
-
167
- /**
168
- * Generate image url
169
- * @param $optionId
170
- * @return string
171
- */
172
- public function getAttributeOptionImage($optionId)
173
- {
174
- $images = $this->getAttributeOptionImages();
175
- $image = array_key_exists($optionId, $images) ? $images[$optionId] : '';
176
- if ($image && (strpos($image, 'http') !== 0)) {
177
- $image = Mage::getDesign()->getSkinUrl($image);
178
- }
179
- return $image;
180
- }
181
-
182
-
183
- /**
184
- * @return mixed
185
- */
186
- public function getAttributeOptionImages()
187
- {
188
- $images = Mage::getResourceModel('eav/entity_attribute_option')->getAttributeOptionImages();
189
- return $images;
190
- }
191
-
192
- /**
193
- * get product types without count products field
194
- *
195
- * @return array
196
- */
197
- public function getProductTypesForCount(){
198
- return array(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE);
199
- }
200
-
201
- /**
202
- * return custom stock status
203
- *
204
- * @param unknown $product
205
- * @return string
206
- */
207
- public function getStockStatus($product){
208
- $helper = Mage::helper("web4pro_stockstatus");
209
- return $helper->__('Availability:') ." ".$helper->getNewStockStatus($product);
210
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
  }
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+ /**
12
+ * Stockstatus default helper
13
+ *
14
+ * @category Web4pro
15
+ * @package Web4pro_Stockstatus
16
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
+ */
18
+ class Web4pro_Stockstatus_Helper_Data extends Mage_Core_Helper_Abstract
19
+ {
20
+ /**
21
+ * Get default stock status of product
22
+ * @param $product
23
+ * @return string
24
+ */
25
+ public function getDefaultStockStatus($product)
26
+ {
27
+ if($product->isAvailable()){
28
+ $result = $this->__('In stock');
29
+ }
30
+ else{
31
+ $result = $this->__('Out of stock');
32
+ }
33
+ return $result;
34
+ }
35
+
36
+
37
+ /**
38
+ * Get custom stock status of product
39
+ * @param $product
40
+ * @return string
41
+ */
42
+ public function getCustomStockStatus($product)
43
+ {
44
+ $customStockStatus = '';
45
+ if (($product->isAvailable() || $this->isCustomStockStatusOnOutOfStock()) && $this->checkNumberProductsForCustomStatus($product)) {
46
+ $customStockStatus = $product->getAttributeText('custom_stockstatus');
47
+ }
48
+ return $customStockStatus;
49
+ }
50
+
51
+ /**
52
+ * check number of products for custom stock status (count_products field)
53
+ * @param object $product
54
+ * @return bool
55
+ */
56
+ public function checkNumberProductsForCustomStatus($product){
57
+ $count = $product->getData('count_products');
58
+ if(!in_array($product->getTypeID(), $this->getProductTypesForCount())) return true;
59
+ $strockQty = (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($product)->getQty();
60
+ return $count <= $strockQty;
61
+ }
62
+
63
+
64
+ /**
65
+ * Get new stock status based on default and custom
66
+ * @param object $product
67
+ * @return string
68
+ */
69
+ public function getNewStockStatus($product)
70
+ {
71
+ $defaultStockStatus = $this->getDefaultStockStatus($product);
72
+ $customStockStatus = $this->getCustomStockStatus($product);
73
+ if ($this->isShowStockLevel() && $product->getStockItem()->getQty() && in_array($product->getTypeID(), $this->getProductTypesForCount())) {
74
+ $levelStockStatus = $this->__('%s in stock', (int)$product->getStockItem()->getQty());
75
+ return $levelStockStatus . ' ' . $customStockStatus;
76
+ }
77
+ if(!strlen($customStockStatus)){
78
+ return $defaultStockStatus;
79
+ }else if ($this->isDefaultStockStatusHidden($product)){
80
+ return $customStockStatus;
81
+ } else {
82
+ return $defaultStockStatus . ' ' . $customStockStatus;
83
+ }
84
+ }
85
+
86
+
87
+ /**
88
+ * Check whether to hide a ddefault status
89
+ * @param object $product
90
+ * @return mixed
91
+ */
92
+ public function isDefaultStockStatusHidden($product)
93
+ {
94
+ return $product->getData('hide_default_stockstatus');
95
+ }
96
+
97
+ /**
98
+ * Is the custom status allowed at page of category
99
+ * @return mixed
100
+ */
101
+ public function isCustomStockStatusOnProductListPage()
102
+ {
103
+ return Mage::getStoreConfig('web4pro_stockstatus/general/display_at_category');
104
+ }
105
+
106
+ /**
107
+ * Is the custom status allowed at product view page
108
+ * @return mixed
109
+ */
110
+ public function isCustomStockStatusOnProductViewPage()
111
+ {
112
+ return Mage::getStoreConfig('web4pro_stockstatus/general/display_at_product_page');
113
+ }
114
+
115
+ /**
116
+ * Is the custom status allowed at page of shoping cart
117
+ * @return mixed
118
+ */
119
+ public function isCustomStockStatusInShoppingCart()
120
+ {
121
+ return Mage::getStoreConfig('web4pro_stockstatus/general/display_in_cart');
122
+ }
123
+
124
+ /**
125
+ * Is the custom status allowed for Out of stock products
126
+ * @return mixed
127
+ */
128
+ public function isCustomStockStatusOnOutOfStock()
129
+ {
130
+ return Mage::getStoreConfig('web4pro_stockstatus/general/outofstock');
131
+ }
132
+
133
+ /**
134
+ * Is stock qty displayed
135
+ * @return mixed
136
+ */
137
+ public function isShowStockLevel()
138
+ {
139
+ return Mage::getStoreConfig('web4pro_stockstatus/general/showstocklevel');
140
+ }
141
+
142
+
143
+ /**
144
+ * Is show icon
145
+ * @return mixed
146
+ */
147
+ public function isShowStockImage()
148
+ {
149
+ return Mage::getStoreConfig('web4pro_stockstatus/general/showimage');
150
+ }
151
+
152
+ /**
153
+ * Is show icon only
154
+ * @return mixed
155
+ */
156
+ public function isShowStockImageOnly()
157
+ {
158
+ return Mage::getStoreConfig('web4pro_stockstatus/general/showimageonly');
159
+ }
160
+
161
+ /**
162
+ * Is the custom status allowed at page of product view
163
+ * @param $product
164
+ * @return string
165
+ */
166
+ public function showStockStatus($product)
167
+ {
168
+ $result = '';
169
+ if ($this->isCustomStockStatusOnProductListPage()){
170
+ $result = $this->getNewStockStatus($product);
171
+ }
172
+ return $result;
173
+ }
174
+
175
+
176
+ /**
177
+ * Generate image url
178
+ * @param $optionId
179
+ * @return string
180
+ */
181
+ public function getAttributeOptionImage($optionId)
182
+ {
183
+ $images = $this->getAttributeOptionImages();
184
+ $image = array_key_exists($optionId, $images) ? $images[$optionId] : '';
185
+ if ($image && (strpos($image, 'http') !== 0)) {
186
+ $image = Mage::getDesign()->getSkinUrl($image);
187
+ }
188
+ return $image;
189
+ }
190
+
191
+
192
+ /**
193
+ * @return mixed
194
+ */
195
+ public function getAttributeOptionImages()
196
+ {
197
+ $images = Mage::getResourceModel('eav/entity_attribute_option')->getAttributeOptionImages();
198
+ return $images;
199
+ }
200
+
201
+ /**
202
+ * get product types without count products field
203
+ *
204
+ * @return array
205
+ */
206
+ public function getProductTypesForCount(){
207
+ return array(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE);
208
+ }
209
+
210
+ /**
211
+ * return custom stock status
212
+ *
213
+ * @param unknown $product
214
+ * @return string
215
+ */
216
+ public function getStockStatus($product){
217
+ return $this->__('Availability:') . " " . $this->getNewStockStatus($product);
218
+ }
219
+
220
+ /**
221
+ * return custom child stock status
222
+ *
223
+ * @param $product
224
+ * @return string
225
+ */
226
+ public function getChildStockStatus($product){
227
+ if (!$this->isShowStockImage()){
228
+ return false;
229
+ }
230
+ $img = '';
231
+ $custom_stockstatus = $product->getData('custom_stockstatus');
232
+ if($custom_stockstatus && $this->isCustomStockStatusOnProductViewPage()){
233
+ $src = $this->getAttributeOptionImage($custom_stockstatus);
234
+ $img = '<img style="display:inline;" align="top" height="20px" src="' . $src . '" />';
235
+ }
236
+
237
+ return $img . $this->__('Availability:') ." ".$this->getNewStockStatus($product);
238
+ }
239
  }
app/code/community/Web4pro/Stockstatus/Model/Catalog/Resource/Eav/Mysql4/Attribute.php CHANGED
@@ -1,101 +1,101 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
-
12
- /**
13
- * Catalog resource model
14
- *
15
- * @category Web4pro
16
- * @package Web4pro_Stockstatus
17
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
18
- */
19
-
20
- class Web4pro_Stockstatus_Model_Catalog_Resource_Eav_Mysql4_Attribute extends Mage_Catalog_Model_Resource_Eav_Mysql4_Attribute
21
- {
22
- protected function _saveOption(Mage_Core_Model_Abstract $object)
23
- {
24
- $option = $object->getOption();
25
- if (is_array($option)) {
26
- $write = $this->_getWriteAdapter();
27
- $optionTable = $this->getTable('attribute_option');
28
- $optionValueTable = $this->getTable('attribute_option_value');
29
- $stores = Mage::getModel('core/store')
30
- ->getResourceCollection()
31
- ->setLoadDefault(true)
32
- ->load();
33
-
34
- if (isset($option['value'])) {
35
- $attributeDefaultValue = array();
36
- if (!is_array($object->getDefault())) {
37
- $object->setDefault(array());
38
- }
39
-
40
- foreach ($option['value'] as $optionId => $values) {
41
- $intOptionId = (int) $optionId;
42
- if (!empty($option['delete'][$optionId])) {
43
- if ($intOptionId) {
44
- $condition = $write->quoteInto('option_id=?', $intOptionId);
45
- $write->delete($optionTable, $condition);
46
- }
47
-
48
- continue;
49
- }
50
-
51
- if (!$intOptionId) {
52
- $data = array(
53
- 'attribute_id' => $object->getId(),
54
- 'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0,
55
- 'image' => isset($option['image'][$optionId]) ? $option['image'][$optionId] : '',
56
- );
57
- $write->insert($optionTable, $data);
58
- $intOptionId = $write->lastInsertId();
59
- }
60
- else {
61
- $data = array(
62
- 'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0,
63
- 'image' => isset($option['image'][$optionId]) ? $option['image'][$optionId] : '',
64
- );
65
- $write->update($optionTable, $data, $write->quoteInto('option_id=?', $intOptionId));
66
- }
67
-
68
- if (in_array($optionId, $object->getDefault())) {
69
- if ($object->getFrontendInput() == 'multiselect') {
70
- $attributeDefaultValue[] = $intOptionId;
71
- } else if ($object->getFrontendInput() == 'select') {
72
- $attributeDefaultValue = array($intOptionId);
73
- }
74
- }
75
-
76
- // Default value
77
- if (!isset($values[0])) {
78
- Mage::throwException(Mage::helper('eav')->__('Default option value is not defined.'));
79
- }
80
-
81
- $write->delete($optionValueTable, $write->quoteInto('option_id=?', $intOptionId));
82
- foreach ($stores as $store) {
83
- if (isset($values[$store->getId()]) && (!empty($values[$store->getId()]) || $values[$store->getId()] == "0")) {
84
- $data = array(
85
- 'option_id' => $intOptionId,
86
- 'store_id' => $store->getId(),
87
- 'value' => $values[$store->getId()],
88
- );
89
- $write->insert($optionValueTable, $data);
90
- }
91
- }
92
- }
93
-
94
- $write->update($this->getMainTable(), array(
95
- 'default_value' => implode(',', $attributeDefaultValue)
96
- ), $write->quoteInto($this->getIdFieldName() . '=?', $object->getId()));
97
- }
98
- }
99
- return $this;
100
- }
101
  }
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+
12
+ /**
13
+ * Catalog resource model
14
+ *
15
+ * @category Web4pro
16
+ * @package Web4pro_Stockstatus
17
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
18
+ */
19
+
20
+ class Web4pro_Stockstatus_Model_Catalog_Resource_Eav_Mysql4_Attribute extends Mage_Catalog_Model_Resource_Eav_Mysql4_Attribute
21
+ {
22
+ protected function _saveOption(Mage_Core_Model_Abstract $object)
23
+ {
24
+ $option = $object->getOption();
25
+ if (is_array($option)) {
26
+ $write = $this->_getWriteAdapter();
27
+ $optionTable = $this->getTable('attribute_option');
28
+ $optionValueTable = $this->getTable('attribute_option_value');
29
+ $stores = Mage::getModel('core/store')
30
+ ->getResourceCollection()
31
+ ->setLoadDefault(true)
32
+ ->load();
33
+
34
+ if (isset($option['value'])) {
35
+ $attributeDefaultValue = array();
36
+ if (!is_array($object->getDefault())) {
37
+ $object->setDefault(array());
38
+ }
39
+
40
+ foreach ($option['value'] as $optionId => $values) {
41
+ $intOptionId = (int) $optionId;
42
+ if (!empty($option['delete'][$optionId])) {
43
+ if ($intOptionId) {
44
+ $condition = $write->quoteInto('option_id=?', $intOptionId);
45
+ $write->delete($optionTable, $condition);
46
+ }
47
+
48
+ continue;
49
+ }
50
+
51
+ if (!$intOptionId) {
52
+ $data = array(
53
+ 'attribute_id' => $object->getId(),
54
+ 'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0,
55
+ 'image' => isset($option['image'][$optionId]) ? $option['image'][$optionId] : '',
56
+ );
57
+ $write->insert($optionTable, $data);
58
+ $intOptionId = $write->lastInsertId();
59
+ }
60
+ else {
61
+ $data = array(
62
+ 'sort_order' => isset($option['order'][$optionId]) ? $option['order'][$optionId] : 0,
63
+ 'image' => isset($option['image'][$optionId]) ? $option['image'][$optionId] : '',
64
+ );
65
+ $write->update($optionTable, $data, $write->quoteInto('option_id=?', $intOptionId));
66
+ }
67
+
68
+ if (in_array($optionId, $object->getDefault())) {
69
+ if ($object->getFrontendInput() == 'multiselect') {
70
+ $attributeDefaultValue[] = $intOptionId;
71
+ } else if ($object->getFrontendInput() == 'select') {
72
+ $attributeDefaultValue = array($intOptionId);
73
+ }
74
+ }
75
+
76
+ // Default value
77
+ if (!isset($values[0])) {
78
+ Mage::throwException(Mage::helper('eav')->__('Default option value is not defined.'));
79
+ }
80
+
81
+ $write->delete($optionValueTable, $write->quoteInto('option_id=?', $intOptionId));
82
+ foreach ($stores as $store) {
83
+ if (isset($values[$store->getId()]) && (!empty($values[$store->getId()]) || $values[$store->getId()] == "0")) {
84
+ $data = array(
85
+ 'option_id' => $intOptionId,
86
+ 'store_id' => $store->getId(),
87
+ 'value' => $values[$store->getId()],
88
+ );
89
+ $write->insert($optionValueTable, $data);
90
+ }
91
+ }
92
+ }
93
+
94
+ $write->update($this->getMainTable(), array(
95
+ 'default_value' => implode(',', $attributeDefaultValue)
96
+ ), $write->quoteInto($this->getIdFieldName() . '=?', $object->getId()));
97
+ }
98
+ }
99
+ return $this;
100
+ }
101
  }
app/code/community/Web4pro/Stockstatus/Model/Eav/Entity/Attribute/Source/Table.php CHANGED
@@ -1,36 +1,36 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
-
12
- /**
13
- * Stockstatus eav source model
14
- *
15
- * @category Web4pro
16
- * @package Web4pro_Stockstatus
17
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
18
- */
19
- class Web4pro_Stockstatus_Model_Eav_Entity_Attribute_Source_Table extends Mage_Eav_Model_Entity_Attribute_Source_Table
20
- {
21
- public function getOptionImage($value)
22
- {
23
- $options = Mage::getResourceModel('eav/entity_attribute_option_collection')
24
- ->setPositionOrder('asc')
25
- ->setAttributeFilter($this->getAttribute()->getId())
26
- ->setStoreFilter($this->getAttribute()->getStoreId())
27
- ->load()
28
- ->toArray();
29
- foreach ($options['items'] as $item) {
30
- if ($item['option_id'] == $value) {
31
- return $item['image'];
32
- }
33
- }
34
- return false;
35
- }
36
  }
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+
12
+ /**
13
+ * Stockstatus eav source model
14
+ *
15
+ * @category Web4pro
16
+ * @package Web4pro_Stockstatus
17
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
18
+ */
19
+ class Web4pro_Stockstatus_Model_Eav_Entity_Attribute_Source_Table extends Mage_Eav_Model_Entity_Attribute_Source_Table
20
+ {
21
+ public function getOptionImage($value)
22
+ {
23
+ $options = Mage::getResourceModel('eav/entity_attribute_option_collection')
24
+ ->setPositionOrder('asc')
25
+ ->setAttributeFilter($this->getAttribute()->getId())
26
+ ->setStoreFilter($this->getAttribute()->getStoreId())
27
+ ->load()
28
+ ->toArray();
29
+ foreach ($options['items'] as $item) {
30
+ if ($item['option_id'] == $value) {
31
+ return $item['image'];
32
+ }
33
+ }
34
+ return false;
35
+ }
36
  }
app/code/community/Web4pro/Stockstatus/Model/Eav/Mysql4/Entity/Attribute/Option.php CHANGED
@@ -1,30 +1,30 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
-
12
- /**
13
- * Stockstatus resource model
14
- *
15
- * @category Web4pro
16
- * @package Web4pro_Stockstatus
17
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
18
- */
19
-
20
- class Web4pro_Stockstatus_Model_Eav_Mysql4_Entity_Attribute_Option extends Mage_Eav_Model_Mysql4_Entity_Attribute_Option
21
- {
22
- public function getAttributeOptionImages()
23
- {
24
- $select = $this->getReadConnection()
25
- ->select()
26
- ->from($this->getTable('eav/attribute_option'), array('option_id', 'image'));
27
-
28
- return $this->getReadConnection()->fetchPairs($select);
29
- }
30
  }
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+
12
+ /**
13
+ * Stockstatus resource model
14
+ *
15
+ * @category Web4pro
16
+ * @package Web4pro_Stockstatus
17
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
18
+ */
19
+
20
+ class Web4pro_Stockstatus_Model_Eav_Mysql4_Entity_Attribute_Option extends Mage_Eav_Model_Mysql4_Entity_Attribute_Option
21
+ {
22
+ public function getAttributeOptionImages()
23
+ {
24
+ $select = $this->getReadConnection()
25
+ ->select()
26
+ ->from($this->getTable('eav/attribute_option'), array('option_id', 'image'));
27
+
28
+ return $this->getReadConnection()->fetchPairs($select);
29
+ }
30
  }
app/code/community/Web4pro/Stockstatus/Model/Observer.php CHANGED
@@ -1,158 +1,160 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
-
12
- class Web4pro_Stockstatus_Model_Observer
13
- {
14
- /**
15
- * web4pro stockstatus helper
16
- *
17
- */
18
- private $_helper = '';
19
-
20
- /**
21
- * constructor
22
- *
23
- * @access public
24
- * @return void
25
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
26
- */
27
- public function __construct()
28
- {
29
- $this->_helper = Mage::helper('web4pro_stockstatus');
30
- }
31
-
32
- /**
33
- * Update product sotck statuses
34
- * @access public
35
- * @param Varien_Event_Observer $observer
36
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
37
- */
38
- public function updateStockStatus($observer)
39
- {
40
- $block = $observer->getBlock();
41
- $stockstatuses = $this->_getStockStatuses($block);
42
- $isStockStatus = count($stockstatuses);
43
- if (empty($isStockStatus)){
44
- return;
45
- }
46
- $transport = $observer->getEvent()->getTransport();
47
- $block = new Web4pro_Stockstatus_Block_Stockstatus();
48
- if (isset($stockstatuses['isProductView']) && $stockstatuses['isProductView'] == 1){
49
- $stockstatus = $stockstatuses['stockstatus'];
50
- $block->replaceStockStatus($transport['html'], $stockstatus);
51
- } else {
52
- $block->replaceStockStatuses($transport['html'], $stockstatuses);
53
- }
54
- $block->toHtml();
55
- }
56
-
57
- /**
58
- * Getting statuses depending on block
59
- * @param object $block
60
- * @access private
61
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
62
- */
63
- private function _getStockStatuses($block)
64
- {
65
- $stockstatuses = array();
66
- switch(true) {
67
- case ($block instanceof Mage_Catalog_Block_Product_View && $block->getBlockAlias() == 'product.info'):
68
- $product = $block->getProduct();
69
- $stockstatuses['stockstatus'] = $this->_helper->getStockStatus($product);
70
- $stockstatuses['isProductView'] = 1;
71
- break;
72
-
73
- case $block instanceof Mage_Catalog_Block_Product_List:
74
- $collection = $block->getLoadedProductCollection();
75
- Mage::getSingleton('cataloginventory/stock')->addItemsToProducts($collection);
76
- if ($this->_helper->isCustomStockStatusOnProductListPage()){
77
- foreach ($block->getLoadedProductCollection() as $item){
78
- $img = $this->getStockStatusImage($item);
79
- $stockstatuses[] = ($this->_helper->isShowStockImageOnly()) ? $img : $img . $this->_helper->getNewStockStatus($item);
80
- }
81
- }
82
- break;
83
-
84
- case $block instanceof Mage_Checkout_Block_Cart:
85
- if ($this->_helper->isCustomStockStatusInShoppingCart()){
86
- foreach ($block->getItems() as $item){
87
- $stockstatuses[] = $this->_helper->getNewStockStatus($item->getProduct());
88
- }
89
- }
90
- break;
91
- }
92
- return $stockstatuses;
93
- }
94
-
95
- /**
96
- * Set stock status attribute
97
- * @param Varien_Event_Observer $observer
98
- * @access public
99
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
100
- */
101
- public function setStockStatusAttribute($observer)
102
- {
103
- $quoteItem = $observer->getQuoteItem();
104
- $product = $observer->getProduct();
105
- $quoteItem->setCustomStockstatus($product->getCustomStockstatus());
106
- $quoteItem->setHideDefaultStockstatus($product->getHideDefaultStockstatus());
107
- }
108
-
109
-
110
- /**
111
- * Get product custom stockstatus image
112
- * @param $product
113
- * @return string
114
- * @access public
115
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
116
- */
117
- public function getStockStatusImage($product)
118
- {
119
- $helper = Mage::helper('web4pro_stockstatus');
120
- if (!$helper->isShowStockImage()){
121
- return false;
122
- }
123
- $img = '';
124
- $custom_stockstatus = $product->getData('custom_stockstatus');
125
- if($custom_stockstatus){
126
- $src = $helper->getAttributeOptionImage($custom_stockstatus);
127
- $img = "<img style='display:inline;' align='top' height=20px src='" . $src . "'> ";
128
- }
129
- return $img;
130
- }
131
-
132
- /**
133
- * Add uploader for attribute
134
- * @param $observer
135
- * @access public
136
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
137
- */
138
- public function updateLayout($observer)
139
- {
140
- $action = $observer->getEvent()->getAction();
141
- if ($action instanceof Mage_Adminhtml_Catalog_Product_AttributeController && $action->getRequest()->getActionName() == 'edit') {
142
- if (Mage::registry('entity_attribute')->getData('attribute_code') !='custom_stockstatus'){
143
- return false;
144
- }
145
- $observer->getLayout()->getBlock('head')
146
- ->setCanLoadExtJs(true)
147
- ->addJs('mage/adminhtml/variables.js')
148
- ->addJs('mage/adminhtml/wysiwyg/widget.js')
149
- ->addJs('lib/flex.js')
150
- ->addJs('lib/FABridge.js')
151
- ->addJs('mage/adminhtml/flexuploader.js')
152
- ->addJs('mage/adminhtml/browser.js')
153
- ->addJs('prototype/window.js')
154
- ->addItem('js_css', 'prototype/windows/themes/default.css')
155
- ->addItem('skin_css', 'lib/prototype/windows/themes/magento.css');
156
- }
157
- }
158
- }
 
 
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+
12
+ class Web4pro_Stockstatus_Model_Observer
13
+ {
14
+ /**
15
+ * web4pro stockstatus helper
16
+ *
17
+ */
18
+ private $_helper = '';
19
+
20
+ /**
21
+ * constructor
22
+ *
23
+ * @access public
24
+ * @return void
25
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
26
+ */
27
+ public function __construct()
28
+ {
29
+ $this->_helper = Mage::helper('web4pro_stockstatus');
30
+ }
31
+
32
+ /**
33
+ * Update product sotck statuses
34
+ * @access public
35
+ * @param Varien_Event_Observer $observer
36
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
37
+ */
38
+ public function updateStockStatus($observer)
39
+ {
40
+ $block = $observer->getBlock();
41
+ $stockstatuses = $this->_getStockStatuses($block);
42
+ $isStockStatus = count($stockstatuses);
43
+ if (empty($isStockStatus)){
44
+ return;
45
+ }
46
+ $transport = $observer->getEvent()->getTransport();
47
+ $block = new Web4pro_Stockstatus_Block_Stockstatus();
48
+ if (isset($stockstatuses['isProductView']) && $stockstatuses['isProductView'] == 1){
49
+ $stockstatus = $stockstatuses['stockstatus'];
50
+ $product = $observer->getBlock()->getProduct();
51
+
52
+ $block->replaceStockStatus($transport['html'], $stockstatus, $product);
53
+ } else {
54
+ $block->replaceStockStatuses($transport['html'], $stockstatuses);
55
+ }
56
+ $block->toHtml();
57
+ }
58
+
59
+ /**
60
+ * Getting statuses depending on block
61
+ * @param object $block
62
+ * @access private
63
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
64
+ */
65
+ private function _getStockStatuses($block)
66
+ {
67
+ $stockstatuses = array();
68
+ switch(true) {
69
+ case ($block instanceof Mage_Catalog_Block_Product_View && $block->getBlockAlias() == 'product.info'):
70
+ $product = $block->getProduct();
71
+ $stockstatuses['stockstatus'] = $this->_helper->getStockStatus($product);
72
+ $stockstatuses['isProductView'] = 1;
73
+ break;
74
+
75
+ case $block instanceof Mage_Catalog_Block_Product_List:
76
+ $collection = $block->getLoadedProductCollection();
77
+ Mage::getSingleton('cataloginventory/stock')->addItemsToProducts($collection);
78
+ if ($this->_helper->isCustomStockStatusOnProductListPage()){
79
+ foreach ($block->getLoadedProductCollection() as $item){
80
+ $img = $this->getStockStatusImage($item);
81
+ $stockstatuses[] = ($this->_helper->isShowStockImageOnly()) ? $img : $img . $this->_helper->getNewStockStatus($item);
82
+ }
83
+ }
84
+ break;
85
+
86
+ case $block instanceof Mage_Checkout_Block_Cart:
87
+ if ($this->_helper->isCustomStockStatusInShoppingCart()){
88
+ foreach ($block->getItems() as $item){
89
+ $stockstatuses[] = $this->_helper->getNewStockStatus($item->getProduct());
90
+ }
91
+ }
92
+ break;
93
+ }
94
+ return $stockstatuses;
95
+ }
96
+
97
+ /**
98
+ * Set stock status attribute
99
+ * @param Varien_Event_Observer $observer
100
+ * @access public
101
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
102
+ */
103
+ public function setStockStatusAttribute($observer)
104
+ {
105
+ $quoteItem = $observer->getQuoteItem();
106
+ $product = $observer->getProduct();
107
+ $quoteItem->setCustomStockstatus($product->getCustomStockstatus());
108
+ $quoteItem->setHideDefaultStockstatus($product->getHideDefaultStockstatus());
109
+ }
110
+
111
+
112
+ /**
113
+ * Get product custom stockstatus image
114
+ * @param $product
115
+ * @return string
116
+ * @access public
117
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
118
+ */
119
+ public function getStockStatusImage($product)
120
+ {
121
+ $helper = Mage::helper('web4pro_stockstatus');
122
+ if (!$helper->isShowStockImage()){
123
+ return false;
124
+ }
125
+ $img = '';
126
+ $custom_stockstatus = $product->getData('custom_stockstatus');
127
+ if($custom_stockstatus){
128
+ $src = $helper->getAttributeOptionImage($custom_stockstatus);
129
+ $img = '<img style="display:inline;" align="top" height="20px" src="' . $src . '" />';
130
+ }
131
+ return $img;
132
+ }
133
+
134
+ /**
135
+ * Add uploader for attribute
136
+ * @param $observer
137
+ * @access public
138
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
139
+ */
140
+ public function updateLayout($observer)
141
+ {
142
+ $action = $observer->getEvent()->getAction();
143
+ if ($action instanceof Mage_Adminhtml_Catalog_Product_AttributeController && $action->getRequest()->getActionName() == 'edit') {
144
+ if (Mage::registry('entity_attribute')->getData('attribute_code') !='custom_stockstatus'){
145
+ return false;
146
+ }
147
+ $observer->getLayout()->getBlock('head')
148
+ ->setCanLoadExtJs(true)
149
+ ->addJs('mage/adminhtml/variables.js')
150
+ ->addJs('mage/adminhtml/wysiwyg/widget.js')
151
+ ->addJs('lib/flex.js')
152
+ ->addJs('lib/FABridge.js')
153
+ ->addJs('mage/adminhtml/flexuploader.js')
154
+ ->addJs('mage/adminhtml/browser.js')
155
+ ->addJs('prototype/window.js')
156
+ ->addItem('js_css', 'prototype/windows/themes/default.css')
157
+ ->addItem('skin_css', 'lib/prototype/windows/themes/magento.css');
158
+ }
159
+ }
160
+ }
app/code/community/Web4pro/Stockstatus/Model/Observer.php~ DELETED
@@ -1,158 +0,0 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
-
12
- class Web4pro_Stockstatus_Model_Observer
13
- {
14
- /**
15
- * web4pro stockstatus helper
16
- *
17
- */
18
- private $_helper = '';
19
-
20
- /**
21
- * constructor
22
- *
23
- * @access public
24
- * @return void
25
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
26
- */
27
- public function __construct()
28
- {
29
- $this->_helper = Mage::helper('web4pro_stockstatus');
30
- }
31
-
32
- /**
33
- * Update product sotck statuses
34
- * @access public
35
- * @param Varien_Event_Observer $observer
36
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
37
- */
38
- public function updateStockStatus($observer)
39
- {
40
- $block = $observer->getBlock();
41
- $stockstatuses = $this->_getStockStatuses($block);
42
- $isStockStatus = count($stockstatuses);
43
- if (empty($isStockStatus)){
44
- return;
45
- }
46
- $transport = $observer->getEvent()->getTransport();
47
- $block = new Web4pro_Stockstatus_Block_Stockstatus();
48
- if ($stockstatuses['isProductView'] == 1){
49
- $stockstatus = $stockstatuses['stockstatus'];
50
- $block->replaceStockStatus($transport['html'], $stockstatus);
51
- } else {
52
- $block->replaceStockStatuses($transport['html'], $stockstatuses);
53
- }
54
- $block->toHtml();
55
- }
56
-
57
- /**
58
- * Getting statuses depending on block
59
- * @param object $block
60
- * @access private
61
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
62
- */
63
- private function _getStockStatuses($block)
64
- {
65
- $stockstatuses = array();
66
- switch(true) {
67
- case ($block instanceof Mage_Catalog_Block_Product_View && $block->getBlockAlias() == 'product.info'):
68
- $product = $block->getProduct();
69
- $stockstatuses['stockstatus'] = $this->_helper->getStockStatus($product);
70
- $stockstatuses['isProductView'] = 1;
71
- break;
72
-
73
- case $block instanceof Mage_Catalog_Block_Product_List:
74
- $collection = $block->getLoadedProductCollection();
75
- Mage::getSingleton('cataloginventory/stock')->addItemsToProducts($collection);
76
- if ($this->_helper->isCustomStockStatusOnProductListPage()){
77
- foreach ($block->getLoadedProductCollection() as $item){
78
- $img = $this->getStockStatusImage($item);
79
- $stockstatuses[] = ($this->_helper->isShowStockImageOnly()) ? $img : $img . $this->_helper->getNewStockStatus($item);
80
- }
81
- }
82
- break;
83
-
84
- case $block instanceof Mage_Checkout_Block_Cart:
85
- if ($this->_helper->isCustomStockStatusInShoppingCart()){
86
- foreach ($block->getItems() as $item){
87
- $stockstatuses[] = $this->_helper->getNewStockStatus($item->getProduct());
88
- }
89
- }
90
- break;
91
- }
92
- return $stockstatuses;
93
- }
94
-
95
- /**
96
- * Set stock status attribute
97
- * @param Varien_Event_Observer $observer
98
- * @access public
99
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
100
- */
101
- public function setStockStatusAttribute($observer)
102
- {
103
- $quoteItem = $observer->getQuoteItem();
104
- $product = $observer->getProduct();
105
- $quoteItem->setCustomStockstatus($product->getCustomStockstatus());
106
- $quoteItem->setHideDefaultStockstatus($product->getHideDefaultStockstatus());
107
- }
108
-
109
-
110
- /**
111
- * Get product custom stockstatus image
112
- * @param $product
113
- * @return string
114
- * @access public
115
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
116
- */
117
- public function getStockStatusImage($product)
118
- {
119
- $helper = Mage::helper('web4pro_stockstatus');
120
- if (!$helper->isShowStockImage()){
121
- return false;
122
- }
123
- $img = '';
124
- $custom_stockstatus = $product->getData('custom_stockstatus');
125
- if($custom_stockstatus){
126
- $src = $helper->getAttributeOptionImage($custom_stockstatus);
127
- $img = "<img style='display:inline;' align='top' height=20px src='" . $src . "'> ";
128
- }
129
- return $img;
130
- }
131
-
132
- /**
133
- * Add uploader for attribute
134
- * @param $observer
135
- * @access public
136
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
137
- */
138
- public function updateLayout($observer)
139
- {
140
- $action = $observer->getEvent()->getAction();
141
- if ($action instanceof Mage_Adminhtml_Catalog_Product_AttributeController && $action->getRequest()->getActionName() == 'edit') {
142
- if (Mage::registry('entity_attribute')->getData('attribute_code') !='custom_stockstatus'){
143
- return false;
144
- }
145
- $observer->getLayout()->getBlock('head')
146
- ->setCanLoadExtJs(true)
147
- ->addJs('mage/adminhtml/variables.js')
148
- ->addJs('mage/adminhtml/wysiwyg/widget.js')
149
- ->addJs('lib/flex.js')
150
- ->addJs('lib/FABridge.js')
151
- ->addJs('mage/adminhtml/flexuploader.js')
152
- ->addJs('mage/adminhtml/browser.js')
153
- ->addJs('prototype/window.js')
154
- ->addItem('js_css', 'prototype/windows/themes/default.css')
155
- ->addItem('skin_css', 'lib/prototype/windows/themes/magento.css');
156
- }
157
- }
158
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Web4pro/Stockstatus/controllers/Cms/Wysiwyg/ImagesController.php CHANGED
@@ -1,35 +1,35 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Images admin controller
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
- */
18
- require_once 'Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php';
19
-
20
- class Web4pro_Stockstatus_Cms_Wysiwyg_ImagesController extends Mage_Adminhtml_Cms_Wysiwyg_ImagesController
21
- {
22
- public function indexAction()
23
- {
24
- if ($this->getRequest()->getParam('static_urls_allowed')) {
25
- $this->_getSession()->setStaticUrlsAllowed(true);
26
- }
27
- parent::indexAction();
28
- }
29
-
30
- public function onInsertAction()
31
- {
32
- parent::onInsertAction();
33
- $this->_getSession()->setStaticUrlsAllowed();
34
- }
35
  }
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+ /**
12
+ * Images admin controller
13
+ *
14
+ * @category Web4pro
15
+ * @package Web4pro_Stockstatus
16
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
+ */
18
+ require_once 'Mage/Adminhtml/controllers/Cms/Wysiwyg/ImagesController.php';
19
+
20
+ class Web4pro_Stockstatus_Cms_Wysiwyg_ImagesController extends Mage_Adminhtml_Cms_Wysiwyg_ImagesController
21
+ {
22
+ public function indexAction()
23
+ {
24
+ if ($this->getRequest()->getParam('static_urls_allowed')) {
25
+ $this->_getSession()->setStaticUrlsAllowed(true);
26
+ }
27
+ parent::indexAction();
28
+ }
29
+
30
+ public function onInsertAction()
31
+ {
32
+ parent::onInsertAction();
33
+ $this->_getSession()->setStaticUrlsAllowed();
34
+ }
35
  }
app/code/community/Web4pro/Stockstatus/etc/adminhtml.xml CHANGED
@@ -1,33 +1,33 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * WEB4PRO - Creating profitable online stores
5
- *
6
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
7
- * @category WEB4PRO
8
- * @package Web4pro_Stockstatus
9
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
10
- * @license http://www.web4pro.net/license.txt
11
- */
12
- -->
13
- <config>
14
- <acl>
15
- <resources>
16
- <admin>
17
- <children>
18
- <system>
19
- <children>
20
- <config>
21
- <children>
22
- <web4pro_stockstatus translate="title" module="web4pro_stockstatus">
23
- <title>Custom Stock Status</title>
24
- </web4pro_stockstatus>
25
- </children>
26
- </config>
27
- </children>
28
- </system>
29
- </children>
30
- </admin>
31
- </resources>
32
- </acl>
33
  </config>
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * WEB4PRO - Creating profitable online stores
5
+ *
6
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
7
+ * @category WEB4PRO
8
+ * @package Web4pro_Stockstatus
9
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
10
+ * @license http://www.web4pro.net/license.txt
11
+ */
12
+ -->
13
+ <config>
14
+ <acl>
15
+ <resources>
16
+ <admin>
17
+ <children>
18
+ <system>
19
+ <children>
20
+ <config>
21
+ <children>
22
+ <web4pro_stockstatus translate="title" module="web4pro_stockstatus">
23
+ <title>Custom Stock Status</title>
24
+ </web4pro_stockstatus>
25
+ </children>
26
+ </config>
27
+ </children>
28
+ </system>
29
+ </children>
30
+ </admin>
31
+ </resources>
32
+ </acl>
33
  </config>
app/code/community/Web4pro/Stockstatus/etc/config.xml CHANGED
@@ -1,211 +1,211 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * WEB4PRO - Creating profitable online stores
5
- *
6
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
7
- * @category WEB4PRO
8
- * @package Web4pro_Stockstatus
9
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
10
- * @license http://www.web4pro.net/license.txt
11
- */
12
- -->
13
- <config>
14
- <modules>
15
- <Web4pro_Stockstatus>
16
- <version>1.0.3</version>
17
- </Web4pro_Stockstatus>
18
- </modules>
19
- <global>
20
- <helpers>
21
- <web4pro_stockstatus>
22
- <class>Web4pro_Stockstatus_Helper</class>
23
- </web4pro_stockstatus>
24
- <cms>
25
- <rewrite>
26
- <wysiwyg_images>Web4pro_Stockstatus_Helper_Cms_Wysiwyg_Images</wysiwyg_images>
27
- </rewrite>
28
- </cms>
29
- </helpers>
30
- <models>
31
- <web4pro_stockstatus>
32
- <class>Web4pro_Stockstatus_Model</class>
33
- </web4pro_stockstatus>
34
- <catalog_resource_eav_mysql4>
35
- <rewrite>
36
- <attribute>Web4pro_Stockstatus_Model_Catalog_Resource_Eav_Mysql4_Attribute</attribute>
37
- </rewrite>
38
- </catalog_resource_eav_mysql4>
39
- <eav>
40
- <rewrite>
41
- <entity_attribute_source_table>Web4pro_Stockstatus_Model_Eav_Entity_Attribute_Source_Table</entity_attribute_source_table>
42
- </rewrite>
43
- </eav>
44
- <eav_mysql4>
45
- <rewrite>
46
- <entity_attribute_option>Web4pro_Stockstatus_Model_Eav_Mysql4_Entity_Attribute_Option</entity_attribute_option>
47
- </rewrite>
48
- </eav_mysql4>
49
- </models>
50
- <blocks>
51
- <adminhtml>
52
- <rewrite>
53
- <catalog_product_attribute_edit_tab_options>Web4pro_Stockstatus_Block_Adminhtml_Catalog_Product_Attribute_Options</catalog_product_attribute_edit_tab_options>
54
- </rewrite>
55
- </adminhtml>
56
- <web4pro_stockstatus>
57
- <class>Web4pro_Stockstatus_Block</class>
58
- </web4pro_stockstatus>
59
- <catalog>
60
- <rewrite>
61
- <product_view_type_configurable>Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Configurable</product_view_type_configurable>
62
- </rewrite>
63
- </catalog>
64
- <bundle>
65
- <rewrite>
66
- <catalog_product_view_type_bundle_option_radio>Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option_Radio</catalog_product_view_type_bundle_option_radio>
67
- <catalog_product_view_type_bundle_option_multi>Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option_Multi</catalog_product_view_type_bundle_option_multi>
68
- <catalog_product_view_type_bundle_option_checkbox>Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option_Checkbox</catalog_product_view_type_bundle_option_checkbox>
69
- <catalog_product_view_type_bundle_option_select>Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option_Select</catalog_product_view_type_bundle_option_select>
70
- </rewrite>
71
- </bundle>
72
- </blocks>
73
- <resources>
74
- <web4pro_stockstatus_setup>
75
- <setup>
76
- <module>Web4pro_Stockstatus</module>
77
- <class>Mage_Eav_Model_Entity_Setup</class>
78
- </setup>
79
- <connection>
80
- <use>core_setup</use>
81
- </connection>
82
- </web4pro_stockstatus_setup>
83
- <web4pro_stockstatus_write>
84
- <connection>
85
- <use>core_write</use>
86
- </connection>
87
- </web4pro_stockstatus_write>
88
- <web4pro_stockstatus_read>
89
- <connection>
90
- <use>core_read</use>
91
- </connection>
92
- </web4pro_stockstatus_read>
93
- </resources>
94
- <sales>
95
- <quote>
96
- <item>
97
- <product_attributes>
98
- <custom_stockstatus />
99
- <hide_default_stockstatus />
100
- </product_attributes>
101
- </item>
102
- </quote>
103
- </sales>
104
- <events>
105
- <sales_quote_item_set_product>
106
- <observers>
107
- <add_custom_stockstatus_to_quote>
108
- <class>web4pro_stockstatus/observer</class>
109
- <method>setStockStatusAttribute</method>
110
- </add_custom_stockstatus_to_quote>
111
- </observers>
112
- </sales_quote_item_set_product>
113
- </events>
114
- </global>
115
- <admin>
116
- <routers>
117
- <adminhtml>
118
- <args>
119
- <modules>
120
- <Web4pro_Stockstatus before="Mage_Adminhtml">Web4pro_Stockstatus</Web4pro_Stockstatus>
121
- </modules>
122
- </args>
123
- </adminhtml>
124
- </routers>
125
- </admin>
126
- <frontend>
127
- <routers>
128
- <web4pro_stockstatus>
129
- <use>standard</use>
130
- <args>
131
- <module>Web4pro_Stockstatus</module>
132
- <frontName>web4pro_stockstatus</frontName>
133
- </args>
134
- </web4pro_stockstatus>
135
- </routers>
136
- <layout>
137
- <updates>
138
- <web4pro_stockstatus>
139
- <file>web4pro_stockstatus.xml</file>
140
- </web4pro_stockstatus>
141
- </updates>
142
- </layout>
143
- <translate>
144
- <modules>
145
- <Web4pro_Stockstatus>
146
- <files>
147
- <default>Web4pro_Stockstatus.csv</default>
148
- </files>
149
- </Web4pro_Stockstatus>
150
- </modules>
151
- </translate>
152
- <events>
153
- <core_block_abstract_to_html_after>
154
- <observers>
155
- <update_stock_status>
156
- <class>web4pro_stockstatus/observer</class>
157
- <method>updateStockStatus</method>
158
- </update_stock_status>
159
- </observers>
160
- </core_block_abstract_to_html_after>
161
- </events>
162
- </frontend>
163
- <adminhtml>
164
- <layout>
165
- <updates>
166
- <web4pro_stockstatus>
167
- <file>web4pro_stockstatus.xml</file>
168
- </web4pro_stockstatus>
169
- </updates>
170
- </layout>
171
- <events>
172
- <controller_action_layout_generate_blocks_after>>
173
- <observers>
174
- <update_layout>
175
- <class>web4pro_stockstatus/observer</class>
176
- <method>updateLayout</method>
177
- </update_layout>
178
- </observers>
179
- </controller_action_layout_generate_blocks_after>
180
- </events>
181
- <translate>
182
- <modules>
183
- <Web4pro_Stockstatus>
184
- <files>
185
- <default>Web4pro_Stockstatus.csv</default>
186
- </files>
187
- </Web4pro_Stockstatus>
188
- </modules>
189
- </translate>
190
- <acl>
191
- <resources>
192
- <admin>
193
- <children>
194
- <system>
195
- <children>
196
- <config>
197
- <children>
198
- <web4pro_stockstatus translate="title" module="web4pro_stockstatus">
199
- <title>Custom Stock Status Section</title>
200
- <sort_order>50</sort_order>
201
- </web4pro_stockstatus>
202
- </children>
203
- </config>
204
- </children>
205
- </system>
206
- </children>
207
- </admin>
208
- </resources>
209
- </acl>
210
- </adminhtml>
211
  </config>
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * WEB4PRO - Creating profitable online stores
5
+ *
6
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
7
+ * @category WEB4PRO
8
+ * @package Web4pro_Stockstatus
9
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
10
+ * @license http://www.web4pro.net/license.txt
11
+ */
12
+ -->
13
+ <config>
14
+ <modules>
15
+ <Web4pro_Stockstatus>
16
+ <version>1.0.3</version>
17
+ </Web4pro_Stockstatus>
18
+ </modules>
19
+ <global>
20
+ <helpers>
21
+ <web4pro_stockstatus>
22
+ <class>Web4pro_Stockstatus_Helper</class>
23
+ </web4pro_stockstatus>
24
+ <cms>
25
+ <rewrite>
26
+ <wysiwyg_images>Web4pro_Stockstatus_Helper_Cms_Wysiwyg_Images</wysiwyg_images>
27
+ </rewrite>
28
+ </cms>
29
+ </helpers>
30
+ <models>
31
+ <web4pro_stockstatus>
32
+ <class>Web4pro_Stockstatus_Model</class>
33
+ </web4pro_stockstatus>
34
+ <catalog_resource_eav_mysql4>
35
+ <rewrite>
36
+ <attribute>Web4pro_Stockstatus_Model_Catalog_Resource_Eav_Mysql4_Attribute</attribute>
37
+ </rewrite>
38
+ </catalog_resource_eav_mysql4>
39
+ <eav>
40
+ <rewrite>
41
+ <entity_attribute_source_table>Web4pro_Stockstatus_Model_Eav_Entity_Attribute_Source_Table</entity_attribute_source_table>
42
+ </rewrite>
43
+ </eav>
44
+ <eav_mysql4>
45
+ <rewrite>
46
+ <entity_attribute_option>Web4pro_Stockstatus_Model_Eav_Mysql4_Entity_Attribute_Option</entity_attribute_option>
47
+ </rewrite>
48
+ </eav_mysql4>
49
+ </models>
50
+ <blocks>
51
+ <adminhtml>
52
+ <rewrite>
53
+ <catalog_product_attribute_edit_tab_options>Web4pro_Stockstatus_Block_Adminhtml_Catalog_Product_Attribute_Options</catalog_product_attribute_edit_tab_options>
54
+ </rewrite>
55
+ </adminhtml>
56
+ <web4pro_stockstatus>
57
+ <class>Web4pro_Stockstatus_Block</class>
58
+ </web4pro_stockstatus>
59
+ <catalog>
60
+ <rewrite>
61
+ <product_view_type_configurable>Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Configurable</product_view_type_configurable>
62
+ </rewrite>
63
+ </catalog>
64
+ <bundle>
65
+ <rewrite>
66
+ <catalog_product_view_type_bundle_option_radio>Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option_Radio</catalog_product_view_type_bundle_option_radio>
67
+ <catalog_product_view_type_bundle_option_multi>Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option_Multi</catalog_product_view_type_bundle_option_multi>
68
+ <catalog_product_view_type_bundle_option_checkbox>Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option_Checkbox</catalog_product_view_type_bundle_option_checkbox>
69
+ <catalog_product_view_type_bundle_option_select>Web4pro_Stockstatus_Block_Catalog_Product_View_Type_Bundle_Option_Select</catalog_product_view_type_bundle_option_select>
70
+ </rewrite>
71
+ </bundle>
72
+ </blocks>
73
+ <resources>
74
+ <web4pro_stockstatus_setup>
75
+ <setup>
76
+ <module>Web4pro_Stockstatus</module>
77
+ <class>Mage_Eav_Model_Entity_Setup</class>
78
+ </setup>
79
+ <connection>
80
+ <use>core_setup</use>
81
+ </connection>
82
+ </web4pro_stockstatus_setup>
83
+ <web4pro_stockstatus_write>
84
+ <connection>
85
+ <use>core_write</use>
86
+ </connection>
87
+ </web4pro_stockstatus_write>
88
+ <web4pro_stockstatus_read>
89
+ <connection>
90
+ <use>core_read</use>
91
+ </connection>
92
+ </web4pro_stockstatus_read>
93
+ </resources>
94
+ <sales>
95
+ <quote>
96
+ <item>
97
+ <product_attributes>
98
+ <custom_stockstatus />
99
+ <hide_default_stockstatus />
100
+ </product_attributes>
101
+ </item>
102
+ </quote>
103
+ </sales>
104
+ <events>
105
+ <sales_quote_item_set_product>
106
+ <observers>
107
+ <add_custom_stockstatus_to_quote>
108
+ <class>web4pro_stockstatus/observer</class>
109
+ <method>setStockStatusAttribute</method>
110
+ </add_custom_stockstatus_to_quote>
111
+ </observers>
112
+ </sales_quote_item_set_product>
113
+ </events>
114
+ </global>
115
+ <admin>
116
+ <routers>
117
+ <adminhtml>
118
+ <args>
119
+ <modules>
120
+ <Web4pro_Stockstatus before="Mage_Adminhtml">Web4pro_Stockstatus</Web4pro_Stockstatus>
121
+ </modules>
122
+ </args>
123
+ </adminhtml>
124
+ </routers>
125
+ </admin>
126
+ <frontend>
127
+ <routers>
128
+ <web4pro_stockstatus>
129
+ <use>standard</use>
130
+ <args>
131
+ <module>Web4pro_Stockstatus</module>
132
+ <frontName>web4pro_stockstatus</frontName>
133
+ </args>
134
+ </web4pro_stockstatus>
135
+ </routers>
136
+ <layout>
137
+ <updates>
138
+ <web4pro_stockstatus>
139
+ <file>web4pro_stockstatus.xml</file>
140
+ </web4pro_stockstatus>
141
+ </updates>
142
+ </layout>
143
+ <translate>
144
+ <modules>
145
+ <Web4pro_Stockstatus>
146
+ <files>
147
+ <default>Web4pro_Stockstatus.csv</default>
148
+ </files>
149
+ </Web4pro_Stockstatus>
150
+ </modules>
151
+ </translate>
152
+ <events>
153
+ <core_block_abstract_to_html_after>
154
+ <observers>
155
+ <update_stock_status>
156
+ <class>web4pro_stockstatus/observer</class>
157
+ <method>updateStockStatus</method>
158
+ </update_stock_status>
159
+ </observers>
160
+ </core_block_abstract_to_html_after>
161
+ </events>
162
+ </frontend>
163
+ <adminhtml>
164
+ <layout>
165
+ <updates>
166
+ <web4pro_stockstatus>
167
+ <file>web4pro_stockstatus.xml</file>
168
+ </web4pro_stockstatus>
169
+ </updates>
170
+ </layout>
171
+ <events>
172
+ <controller_action_layout_generate_blocks_after>>
173
+ <observers>
174
+ <update_layout>
175
+ <class>web4pro_stockstatus/observer</class>
176
+ <method>updateLayout</method>
177
+ </update_layout>
178
+ </observers>
179
+ </controller_action_layout_generate_blocks_after>
180
+ </events>
181
+ <translate>
182
+ <modules>
183
+ <Web4pro_Stockstatus>
184
+ <files>
185
+ <default>Web4pro_Stockstatus.csv</default>
186
+ </files>
187
+ </Web4pro_Stockstatus>
188
+ </modules>
189
+ </translate>
190
+ <acl>
191
+ <resources>
192
+ <admin>
193
+ <children>
194
+ <system>
195
+ <children>
196
+ <config>
197
+ <children>
198
+ <web4pro_stockstatus translate="title" module="web4pro_stockstatus">
199
+ <title>Custom Stock Status Section</title>
200
+ <sort_order>50</sort_order>
201
+ </web4pro_stockstatus>
202
+ </children>
203
+ </config>
204
+ </children>
205
+ </system>
206
+ </children>
207
+ </admin>
208
+ </resources>
209
+ </acl>
210
+ </adminhtml>
211
  </config>
app/code/community/Web4pro/Stockstatus/etc/system.xml CHANGED
@@ -1,104 +1,113 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * WEB4PRO - Creating profitable online stores
5
- *
6
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
7
- * @category WEB4PRO
8
- * @package Web4pro_Stockstatus
9
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
10
- * @license http://www.web4pro.net/license.txt
11
- */
12
- -->
13
- <config>
14
- <tabs>
15
- <web4pro translate="label" module="web4pro_stockstatus">
16
- <label>Web4pro</label>
17
- <sort_order>2000</sort_order>
18
- </web4pro>
19
- </tabs>
20
- <sections>
21
- <web4pro_stockstatus translate="label" module="web4pro_stockstatus">
22
- <class>separator-top</class>
23
- <label>Custom Stock Status</label>
24
- <tab>web4pro</tab>
25
- <frontend_type>text</frontend_type>
26
- <sort_order>100</sort_order>
27
- <show_in_default>1</show_in_default>
28
- <show_in_website>1</show_in_website>
29
- <show_in_store>1</show_in_store>
30
- <groups>
31
- <general>
32
- <label>General Options</label>
33
- <expanded>1</expanded>
34
- <frontend_type>text</frontend_type>
35
- <sort_order>2</sort_order>
36
- <show_in_default>1</show_in_default>
37
- <show_in_website>1</show_in_website>
38
- <show_in_store>1</show_in_store>
39
- <fields>
40
- <outofstock translate="label">
41
- <label>Show Stock Status When Out Of Stock</label>
42
- <frontend_type>select</frontend_type>
43
- <source_model>adminhtml/system_config_source_yesno</source_model>
44
- <sort_order>3</sort_order>
45
- <show_in_default>1</show_in_default>
46
- <show_in_website>1</show_in_website>
47
- <show_in_store>1</show_in_store>
48
- <comment>Do you want to show custom stock status instead of 'Out of stock' when product is not in stock?</comment>
49
- </outofstock>
50
- <display_at_category translate="label">
51
- <label>Display Custom Stock Status On Product List Page</label>
52
- <frontend_type>select</frontend_type>
53
- <source_model>adminhtml/system_config_source_yesno</source_model>
54
- <sort_order>1</sort_order>
55
- <show_in_default>1</show_in_default>
56
- <show_in_website>1</show_in_website>
57
- <show_in_store>1</show_in_store>
58
- </display_at_category>
59
- <display_in_cart translate="label">
60
- <label>Display Custom Stock Status in Shopping Cart</label>
61
- <comment>Will display custom stock status for items in shopping cart.</comment>
62
- <frontend_type>select</frontend_type>
63
- <source_model>adminhtml/system_config_source_yesno</source_model>
64
- <sort_order>2</sort_order>
65
- <show_in_default>1</show_in_default>
66
- <show_in_website>1</show_in_website>
67
- <show_in_store>1</show_in_store>
68
- </display_in_cart>
69
- <showstocklevel translate="label">
70
- <label>Show Stock Level?</label>
71
- <frontend_type>select</frontend_type>
72
- <source_model>adminhtml/system_config_source_yesno</source_model>
73
- <sort_order>4</sort_order>
74
- <show_in_default>1</show_in_default>
75
- <show_in_website>1</show_in_website>
76
- <show_in_store>1</show_in_store>
77
- <comment>Show the actual quantity in stock (only for simple product type)</comment>
78
- </showstocklevel>
79
- <showimage translate="label">
80
- <label>Show Icons?</label>
81
- <frontend_type>select</frontend_type>
82
- <source_model>adminhtml/system_config_source_yesno</source_model>
83
- <sort_order>5</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
- <comment>Show icon for stock status?</comment>
88
- </showimage>
89
- <showimageonly translate="label">
90
- <label>Show Only Icons?</label>
91
- <frontend_type>select</frontend_type>
92
- <source_model>adminhtml/system_config_source_yesno</source_model>
93
- <sort_order>6</sort_order>
94
- <show_in_default>1</show_in_default>
95
- <show_in_website>1</show_in_website>
96
- <show_in_store>1</show_in_store>
97
- <comment>Show only icon for stock status?</comment>
98
- </showimageonly>
99
- </fields>
100
- </general>
101
- </groups>
102
- </web4pro_stockstatus>
103
- </sections>
 
 
 
 
 
 
 
 
 
104
  </config>
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * WEB4PRO - Creating profitable online stores
5
+ *
6
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
7
+ * @category WEB4PRO
8
+ * @package Web4pro_Stockstatus
9
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
10
+ * @license http://www.web4pro.net/license.txt
11
+ */
12
+ -->
13
+ <config>
14
+ <tabs>
15
+ <web4pro translate="label" module="web4pro_stockstatus">
16
+ <label>Web4pro</label>
17
+ <sort_order>2000</sort_order>
18
+ </web4pro>
19
+ </tabs>
20
+ <sections>
21
+ <web4pro_stockstatus translate="label" module="web4pro_stockstatus">
22
+ <class>separator-top</class>
23
+ <label>Custom Stock Status</label>
24
+ <tab>web4pro</tab>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>100</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ <groups>
31
+ <general>
32
+ <label>General Options</label>
33
+ <expanded>1</expanded>
34
+ <frontend_type>text</frontend_type>
35
+ <sort_order>2</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
+ <fields>
40
+ <outofstock translate="label">
41
+ <label>Show Stock Status When Out Of Stock</label>
42
+ <frontend_type>select</frontend_type>
43
+ <source_model>adminhtml/system_config_source_yesno</source_model>
44
+ <sort_order>3</sort_order>
45
+ <show_in_default>1</show_in_default>
46
+ <show_in_website>1</show_in_website>
47
+ <show_in_store>1</show_in_store>
48
+ <comment>Do you want to show custom stock status instead of 'Out of stock' when product is not in stock?</comment>
49
+ </outofstock>
50
+ <display_at_category translate="label">
51
+ <label>Display Custom Stock Status On Product List Page</label>
52
+ <frontend_type>select</frontend_type>
53
+ <source_model>adminhtml/system_config_source_yesno</source_model>
54
+ <sort_order>1</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ </display_at_category>
59
+ <display_at_product_page translate="label">
60
+ <label>Display Custom Stock Status On Product View Page</label>
61
+ <frontend_type>select</frontend_type>
62
+ <source_model>adminhtml/system_config_source_yesno</source_model>
63
+ <sort_order>1</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>1</show_in_store>
67
+ </display_at_product_page>
68
+ <display_in_cart translate="label">
69
+ <label>Display Custom Stock Status in Shopping Cart</label>
70
+ <comment>Will display custom stock status for items in shopping cart.</comment>
71
+ <frontend_type>select</frontend_type>
72
+ <source_model>adminhtml/system_config_source_yesno</source_model>
73
+ <sort_order>2</sort_order>
74
+ <show_in_default>1</show_in_default>
75
+ <show_in_website>1</show_in_website>
76
+ <show_in_store>1</show_in_store>
77
+ </display_in_cart>
78
+ <showstocklevel translate="label">
79
+ <label>Show Stock Level?</label>
80
+ <frontend_type>select</frontend_type>
81
+ <source_model>adminhtml/system_config_source_yesno</source_model>
82
+ <sort_order>4</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>1</show_in_store>
86
+ <comment>Show the actual quantity in stock (only for simple product type)</comment>
87
+ </showstocklevel>
88
+ <showimage translate="label">
89
+ <label>Show Icons?</label>
90
+ <frontend_type>select</frontend_type>
91
+ <source_model>adminhtml/system_config_source_yesno</source_model>
92
+ <sort_order>5</sort_order>
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
+ <comment>Show icon for stock status?</comment>
97
+ </showimage>
98
+ <showimageonly translate="label">
99
+ <label>Show Only Icons?</label>
100
+ <frontend_type>select</frontend_type>
101
+ <source_model>adminhtml/system_config_source_yesno</source_model>
102
+ <sort_order>6</sort_order>
103
+ <show_in_default>1</show_in_default>
104
+ <show_in_website>1</show_in_website>
105
+ <show_in_store>1</show_in_store>
106
+ <comment>Show only icon for stock status?</comment>
107
+ </showimageonly>
108
+ </fields>
109
+ </general>
110
+ </groups>
111
+ </web4pro_stockstatus>
112
+ </sections>
113
  </config>
app/code/community/Web4pro/Stockstatus/sql/web4pro_stockstatus_setup/install-1.0.0.php CHANGED
@@ -1,65 +1,65 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Stockstatus module install script
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
- */
18
- $this->startSetup();
19
- $setup = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
20
-
21
- $setup->addAttribute('catalog_product', 'custom_stockstatus', array(
22
- 'group' => 'Custom Stock Status',
23
- 'input' => 'select',
24
- 'type' => 'text',
25
- 'label' => 'Custom Stock Status Message',
26
- 'backend' => '',
27
- 'frontend' => '',
28
- 'visible' => true,
29
- 'required' => false,
30
- 'user_defined' => true,
31
- 'searchable' => false,
32
- 'filterable' => false,
33
- 'comparable' => false,
34
- 'visible_on_front' => false,
35
- 'used_in_product_listing' => true,
36
- 'visible_in_advanced_search' => false,
37
- 'is_html_allowed_on_front' => false,
38
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
39
- 'note' => 'Add messages by going to <b>Catalog->Attributes->Manage Attributes</b> and clicking on the <b>\'custom_stockstatus\'</b> attribute.'
40
- ));
41
-
42
- $setup->addAttribute('catalog_product', 'hide_default_stockstatus', array(
43
- 'group' => 'Custom Stock Status',
44
- 'type' => 'int',
45
- 'backend' => '',
46
- 'frontend' => '',
47
- 'label' => 'Hide Default Stock Status',
48
- 'input' => 'select',
49
- 'source' => 'eav/entity_attribute_source_boolean',
50
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
51
- 'visible' => true,
52
- 'required' => false,
53
- 'user_defined' => true,
54
- 'default' => '',
55
- 'searchable' => false,
56
- 'filterable' => false,
57
- 'comparable' => false,
58
- 'visible_on_front' => false,
59
- 'unique' => false,
60
- 'is_configurable' => false,
61
- 'used_in_product_listing' => true
62
- ));
63
-
64
-
65
- $this->endSetup();
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+ /**
12
+ * Stockstatus module install script
13
+ *
14
+ * @category Web4pro
15
+ * @package Web4pro_Stockstatus
16
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
+ */
18
+ $this->startSetup();
19
+ $setup = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
20
+
21
+ $setup->addAttribute('catalog_product', 'custom_stockstatus', array(
22
+ 'group' => 'Custom Stock Status',
23
+ 'input' => 'select',
24
+ 'type' => 'text',
25
+ 'label' => 'Custom Stock Status Message',
26
+ 'backend' => '',
27
+ 'frontend' => '',
28
+ 'visible' => true,
29
+ 'required' => false,
30
+ 'user_defined' => true,
31
+ 'searchable' => false,
32
+ 'filterable' => false,
33
+ 'comparable' => false,
34
+ 'visible_on_front' => false,
35
+ 'used_in_product_listing' => true,
36
+ 'visible_in_advanced_search' => false,
37
+ 'is_html_allowed_on_front' => false,
38
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
39
+ 'note' => 'Add messages by going to <b>Catalog->Attributes->Manage Attributes</b> and clicking on the <b>\'custom_stockstatus\'</b> attribute.'
40
+ ));
41
+
42
+ $setup->addAttribute('catalog_product', 'hide_default_stockstatus', array(
43
+ 'group' => 'Custom Stock Status',
44
+ 'type' => 'int',
45
+ 'backend' => '',
46
+ 'frontend' => '',
47
+ 'label' => 'Hide Default Stock Status',
48
+ 'input' => 'select',
49
+ 'source' => 'eav/entity_attribute_source_boolean',
50
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
51
+ 'visible' => true,
52
+ 'required' => false,
53
+ 'user_defined' => true,
54
+ 'default' => '',
55
+ 'searchable' => false,
56
+ 'filterable' => false,
57
+ 'comparable' => false,
58
+ 'visible_on_front' => false,
59
+ 'unique' => false,
60
+ 'is_configurable' => false,
61
+ 'used_in_product_listing' => true
62
+ ));
63
+
64
+
65
+ $this->endSetup();
app/code/community/Web4pro/Stockstatus/sql/web4pro_stockstatus_setup/install-1.0.0.php~ DELETED
@@ -1,65 +0,0 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Stockstatus module install script
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
- */
18
- $this->startSetup();
19
- $setup = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
20
-
21
- $setup->addAttribute('catalog_product', 'custom_stockstatus', array(
22
- 'group' => 'Custom Stock Status',
23
- 'input' => 'select',
24
- 'type' => 'text',
25
- 'label' => 'Custom Stock Status Message',
26
- 'backend' => '',
27
- 'frontend' => '',
28
- 'visible' => true,
29
- 'required' => false,
30
- 'user_defined' => true,
31
- 'searchable' => false,
32
- 'filterable' => false,
33
- 'comparable' => false,
34
- 'visible_on_front' => false,
35
- 'used_in_product_listing' => true,
36
- 'visible_in_advanced_search' => false,
37
- 'is_html_allowed_on_front' => false,
38
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
39
- 'note' => 'Add messages by going to <b>Catalog->Attributes->Manage Attributes</b> and clicking on the <b>\'custom_stockstatus\'</b> attribute.'
40
- ));
41
-
42
- $setup->addAttribute('catalog_product', 'hide_default_stockstatus', array(
43
- 'group' => 'Custom Stock Status',
44
- 'type' => 'int',
45
- 'backend' => '',
46
- 'frontend' => '',
47
- 'label' => 'Hide Default Stock Status',
48
- 'input' => 'select',
49
- 'source' => 'eav/entity_attribute_source_boolean',
50
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
51
- 'visible' => true,
52
- 'required' => false,
53
- 'user_defined' => true,
54
- 'default' => '',
55
- 'searchable' => false,
56
- 'filterable' => false,
57
- 'comparable' => false,
58
- 'visible_on_front' => false,
59
- 'unique' => false,
60
- 'is_configurable' => false,
61
- 'used_in_product_listing' => true
62
- ));
63
-
64
-
65
- $this->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Web4pro/Stockstatus/sql/web4pro_stockstatus_setup/upgrade-1.0.0-1.0.2.php CHANGED
@@ -1,25 +1,25 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Stockstatus module install script add image attribute to option
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
- */
18
-
19
- $installer = $this;
20
- $installer->getConnection()->addColumn(
21
- $installer->getTable('eav_attribute_option'),
22
- 'image',
23
- 'TEXT NULL'
24
- );
25
  $installer->endSetup();
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+ /**
12
+ * Stockstatus module install script add image attribute to option
13
+ *
14
+ * @category Web4pro
15
+ * @package Web4pro_Stockstatus
16
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
17
+ */
18
+
19
+ $installer = $this;
20
+ $installer->getConnection()->addColumn(
21
+ $installer->getTable('eav_attribute_option'),
22
+ 'image',
23
+ 'TEXT NULL'
24
+ );
25
  $installer->endSetup();
app/code/community/Web4pro/Stockstatus/sql/web4pro_stockstatus_setup/upgrade-1.0.2-1.0.3.php CHANGED
@@ -1,48 +1,48 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <spoprigin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Stockstatus module install script add image attribute to option
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <spoprigin@corp.web4pro.com.ua>
17
- */
18
- $this->startSetup();
19
- $setup = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
20
-
21
- $setup->addAttribute('catalog_product', 'count_products', array(
22
- 'group' => 'Custom Stock Status',
23
- 'input' => 'text',
24
- 'type' => 'int',
25
- 'label' => 'Number of products',
26
- 'backend' => '',
27
- 'frontend' => '',
28
- 'default' => '',
29
- 'visible' => true,
30
- 'required' => false,
31
- 'user_defined' => true,
32
- 'searchable' => false,
33
- 'class' => 'validate-zero-or-greater',
34
- 'filterable' => false,
35
- 'comparable' => false,
36
- 'visible_on_front' => false,
37
- 'used_in_product_listing' => true,
38
- 'visible_in_advanced_search' => false,
39
- 'is_html_allowed_on_front' => false,
40
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
41
- 'note' => 'Minimum number of products in the stock for custom status appearance'
42
- ));
43
-
44
- $setup->updateAttribute(Mage_Catalog_Model_Product::ENTITY, 'hide_default_stockstatus', 'note', 'Hide default stock status if custom status exists');
45
-
46
- $setup->updateAttribute(Mage_Catalog_Model_Product::ENTITY, 'count_products', 'apply_to', implode(',', Mage::helper('web4pro_stockstatus')->getProductTypesForCount()));
47
-
48
- $this->endSetup();
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <spoprigin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+ /**
12
+ * Stockstatus module install script add image attribute to option
13
+ *
14
+ * @category Web4pro
15
+ * @package Web4pro_Stockstatus
16
+ * @author WEB4PRO <spoprigin@corp.web4pro.com.ua>
17
+ */
18
+ $this->startSetup();
19
+ $setup = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
20
+
21
+ $setup->addAttribute('catalog_product', 'count_products', array(
22
+ 'group' => 'Custom Stock Status',
23
+ 'input' => 'text',
24
+ 'type' => 'int',
25
+ 'label' => 'Number of products',
26
+ 'backend' => '',
27
+ 'frontend' => '',
28
+ 'default' => '',
29
+ 'visible' => true,
30
+ 'required' => false,
31
+ 'user_defined' => true,
32
+ 'searchable' => false,
33
+ 'class' => 'validate-zero-or-greater',
34
+ 'filterable' => false,
35
+ 'comparable' => false,
36
+ 'visible_on_front' => false,
37
+ 'used_in_product_listing' => true,
38
+ 'visible_in_advanced_search' => false,
39
+ 'is_html_allowed_on_front' => false,
40
+ 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
41
+ 'note' => 'Minimum number of products in the stock for custom status appearance'
42
+ ));
43
+
44
+ $setup->updateAttribute(Mage_Catalog_Model_Product::ENTITY, 'hide_default_stockstatus', 'note', 'Hide default stock status if custom status exists');
45
+
46
+ $setup->updateAttribute(Mage_Catalog_Model_Product::ENTITY, 'count_products', 'apply_to', implode(',', Mage::helper('web4pro_stockstatus')->getProductTypesForCount()));
47
+
48
+ $this->endSetup();
app/code/community/Web4pro/Stockstatus/sql/web4pro_stockstatus_setup/upgrade-1.0.2-1.0.3.php~ DELETED
@@ -1,46 +0,0 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <spoprigin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Stockstatus module install script add image attribute to option
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <spoprigin@corp.web4pro.com.ua>
17
- */
18
- $this->startSetup();
19
- $setup = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
20
-
21
- $setup->addAttribute('catalog_product', 'count_products', array(
22
- 'group' => 'Custom Stock Status',
23
- 'input' => 'text',
24
- 'type' => 'int',
25
- 'label' => 'Number of products',
26
- 'backend' => '',
27
- 'frontend' => '',
28
- 'default' => '',
29
- 'visible' => true,
30
- 'required' => false,
31
- 'user_defined' => true,
32
- 'searchable' => false,
33
- 'class' => 'validate-zero-or-greater',
34
- 'filterable' => false,
35
- 'comparable' => false,
36
- 'visible_on_front' => false,
37
- 'used_in_product_listing' => true,
38
- 'visible_in_advanced_search' => false,
39
- 'is_html_allowed_on_front' => false,
40
- 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
41
- 'note' => 'Minimum number of products in the stock for custom status appearance'
42
- ));
43
-
44
- $setup->updateAttribute(Mage_Catalog_Model_Product::ENTITY, 'hide_default_stockstatus', 'note', 'Hide default stock status if custom status exists');
45
-
46
- $this->endSetup();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Web4pro/Stockstatus/sql/web4pro_stockstatus_setup/upgrade-1.0.3-1.0.4.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <spoprigin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- /**
12
- * Stockstatus module install script add image attribute to option
13
- *
14
- * @category Web4pro
15
- * @package Web4pro_Stockstatus
16
- * @author WEB4PRO <spoprigin@corp.web4pro.com.ua>
17
- */
18
- $this->startSetup();
19
- $setup = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
20
-
21
- $setup->updateAttribute(Mage_Catalog_Model_Product::ENTITY, 'count_products', 'apply_to', implode(',', Mage::helper('web4pro_stockstatus')->getProductTypesForCount()));
22
-
23
  $this->endSetup();
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <spoprigin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+ /**
12
+ * Stockstatus module install script add image attribute to option
13
+ *
14
+ * @category Web4pro
15
+ * @package Web4pro_Stockstatus
16
+ * @author WEB4PRO <spoprigin@corp.web4pro.com.ua>
17
+ */
18
+ $this->startSetup();
19
+ $setup = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
20
+
21
+ $setup->updateAttribute(Mage_Catalog_Model_Product::ENTITY, 'count_products', 'apply_to', implode(',', Mage::helper('web4pro_stockstatus')->getProductTypesForCount()));
22
+
23
  $this->endSetup();
app/design/adminhtml/default/default/template/stockstatus/catalog/product/attribute/options.phtml CHANGED
@@ -1,199 +1,199 @@
1
- <?php
2
- /**
3
- * WEB4PRO - Creating profitable online stores
4
- *
5
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
- * @category WEB4PRO
7
- * @package Web4pro_Stockstatus
8
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
- * @license http://www.web4pro.net/license.txt
10
- */
11
- ?>
12
- <?php
13
- /**
14
- * Attribute otions control
15
- *
16
- * @see Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options
17
- */
18
- ?>
19
- <div>
20
- <ul class="messages">
21
- <li class="notice-msg">
22
- <ul>
23
- <li><?php echo Mage::helper('catalog')->__('If you do not specify an option value for a specific store view then the default (Admin) value will be used.') ?></li>
24
- </ul>
25
- </li>
26
- </ul>
27
- </div>
28
-
29
- <div class="entity-edit">
30
- <div class="entry-edit-head">
31
- <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('catalog')->__('Manage Titles (Size, Color, etc.)') ?></h4>
32
- </div>
33
- <div class="box">
34
- <div class="hor-scroll">
35
- <table class="dynamic-grid" cellspacing="0" id="attribute-labels-table">
36
- <tr>
37
- <?php foreach ($this->getStores() as $_store): ?>
38
- <th><?php echo $_store->getName() ?></th>
39
- <?php endforeach; ?>
40
- </tr>
41
- <tr>
42
- <?php $_labels = $this->getLabelValues() ?>
43
- <?php foreach ($this->getStores() as $_store): ?>
44
- <td>
45
- <input class="input-text<?php if($_store->getId()==0): ?> required-option<?php endif; ?>" type="text" name="frontend_label[<?php echo $_store->getId() ?>]" value="<?php echo $this->htmlEscape($_labels[$_store->getId()]) ?>"<?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/>
46
- </td>
47
- <?php endforeach; ?>
48
- </tr>
49
- </table>
50
- </div>
51
- </div>
52
- </div>
53
- <br/>
54
- <div class="entity-edit" id="matage-options-panel">
55
- <div class="entry-edit-head">
56
- <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('catalog')->__('Manage Options (values of your attribute)') ?></h4>
57
- </div>
58
- <div class="box">
59
- <div class="hor-scroll">
60
- <table class="dynamic-grid" cellspacing="0" cellpadding="0">
61
- <tr id="attribute-options-table">
62
- <?php foreach ($this->getStores() as $_store): ?>
63
- <th><?php echo $_store->getName() ?></th>
64
- <?php endforeach; ?>
65
- <th><?php echo Mage::helper('catalog')->__('Position') ?></th>
66
- <th class="nobr a-center"><?php echo Mage::helper('catalog')->__('Is Default') ?></th>
67
- <th class="nobr"><?php echo Mage::helper('catalog')->__('Image') ?></th>
68
- <th>
69
- <?php if (!$this->getReadOnly()):?>
70
- <?php echo $this->getAddNewButtonHtml() ?>
71
- <?php endif;?>
72
- </th>
73
- </tr>
74
- <tr class="no-display template" id="row-template">
75
- <?php foreach ($this->getStores() as $_store): ?>
76
- <td><input name="option[value][{{id}}][<?php echo $_store->getId() ?>]" value="{{store<?php echo $_store->getId() ?>}}" class="input-text<?php if($_store->getId()==0): ?> required-option<?php endif; ?>" type="text" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/></td>
77
- <?php endforeach; ?>
78
- <td class="a-center"><input class="input-text" type="text" name="option[order][{{id}}]" value="{{sort_order}}" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/></td>
79
- <td><input class="input-radio" type="radio" name="default[]" value="{{id}}" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/></td>
80
- <td class="a-left">
81
- <input type="hidden" class="delete-flag" name="option[delete][{{id}}]" value="" />
82
- <?php if (!$this->getReadOnly()):?>
83
- <?php echo $this->getDeleteButtonHtml() ?>
84
- <?php endif;?>
85
- </td>
86
- </tr>
87
- </table>
88
- </div>
89
- <input type="hidden" id="option-count-check" value="" />
90
- </div>
91
- </div>
92
- <script type="text/javascript">
93
- //<![CDATA[
94
- var optionDefaultInputType = 'radio';
95
-
96
- // IE removes quotes from element.innerHTML whenever it thinks they're not needed, which breaks html.
97
- var templateText =
98
- '<tr class="option-row">'+
99
- <?php foreach ($this->getStores() as $_store): ?>
100
- '<td><input name="option[value][{{id}}][<?php echo $_store->getId() ?>]" value="{{store<?php echo $_store->getId() ?>}}" class="input-text<?php if($_store->getId()==0): ?> required-option<?php endif; ?>" type="text" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/><\/td>'+
101
- <?php endforeach; ?>
102
- '<td><input class="input-text" type="text" name="option[order][{{id}}]" value="{{sort_order}}" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/><\/td>'+
103
- '<td class="a-center"><input class="input-radio" type="{{intype}}" name="default[]" value="{{id}}" {{checked}} <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/><\/td>'+
104
- '<td class="nobr"><input id="option_image_{{id}}" type="text" name="option[image][{{id}}]" value="{{image}}" class="attribute_option_image" style="width:300px;" /><button id="add_image_{{id}}" class="scalable" type="button" onclick="MediabrowserUtility.openDialog(\'<?php echo Mage::getSingleton('adminhtml/url')->getUrl('*/cms_wysiwyg_images/index', array('static_urls_allowed' => 1)) ?>target_element_id/option_image_{{id}}/\');"><span>...</span></button></td>'+
105
- '<td class="a-left">'+
106
- '<input type="hidden" class="delete-flag" name="option[delete][{{id}}]" value="" />'+
107
- <?php if (!$this->getReadOnly()):?>
108
- '<?php echo $this->getDeleteButtonHtml() ?>'+
109
- <?php endif;?>
110
- '<\/td>'+
111
- '<\/tr>';
112
-
113
- var attributeOption = {
114
- table : $('attribute-options-table'),
115
- templateSyntax : /(^|.|\r|\n)({{(\w+)}})/,
116
- templateText : templateText,
117
- itemCount : 0,
118
- totalItems : 0,
119
- add : function(data) {
120
- this.template = new Template(this.templateText, this.templateSyntax);
121
- if(!data.id){
122
- data = {};
123
- data.id = 'option_'+this.itemCount;
124
- }
125
- if (!data.intype)
126
- data.intype = optionDefaultInputType;
127
-
128
- Element.insert(this.table, {after: this.template.evaluate(data)});
129
- this.bindRemoveButtons();
130
- this.itemCount++;
131
- this.totalItems++;
132
- this.updateItemsCountField();
133
- },
134
- remove : function(event){
135
- var element = $(Event.findElement(event, 'tr')); // !!! Button already
136
- // have table parent in safari
137
- // Safari workaround
138
- element.ancestors().each(function(parentItem){
139
- if (parentItem.hasClassName('option-row')) {
140
- element = parentItem;
141
- throw $break;
142
- } else if (parentItem.hasClassName('box')) {
143
- throw $break;
144
- }
145
- });
146
-
147
-
148
- if(element){
149
- var elementFlags = element.getElementsByClassName('delete-flag');
150
- if(elementFlags[0]){
151
- elementFlags[0].value=1;
152
- }
153
-
154
- element.addClassName('no-display');
155
- element.addClassName('template');
156
- element.hide();
157
- this.totalItems--;
158
- this.updateItemsCountField();
159
- }
160
- },
161
- updateItemsCountField: function() {
162
- if (this.totalItems > 0) {
163
- $('option-count-check').value = '1';
164
- } else {
165
- $('option-count-check').value = '';
166
- }
167
- },
168
- bindRemoveButtons : function(){
169
- var buttons = $$('.delete-option');
170
- for(var i=0;i<buttons.length;i++){
171
- if(!$(buttons[i]).binded){
172
- $(buttons[i]).binded = true;
173
- Event.observe(buttons[i], 'click', this.remove.bind(this));
174
- }
175
- }
176
- }
177
-
178
- }
179
- if($('row-template')){
180
- $('row-template').remove();
181
- }
182
- attributeOption.bindRemoveButtons();
183
-
184
- if($('add_new_option_button')){
185
- Event.observe('add_new_option_button', 'click', attributeOption.add.bind(attributeOption));
186
- }
187
- Validation.addAllThese([
188
- ['required-option', '<?php echo Mage::helper('catalog')->__('Failed') ?>', function(v) {
189
- return !Validation.get('IsEmpty').test(v);
190
- }]]);
191
- Validation.addAllThese([
192
- ['required-options-count', '<?php echo Mage::helper('catalog')->__('Options is required') ?>', function(v) {
193
- return !Validation.get('IsEmpty').test(v);
194
- }]]);
195
- <?php foreach ($this->getOptionValues() as $_value): ?>
196
- attributeOption.add(<?php echo $_value->toJson() ?>);
197
- <?php endforeach; ?>
198
- //]]>
199
- </script>
1
+ <?php
2
+ /**
3
+ * WEB4PRO - Creating profitable online stores
4
+ *
5
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
6
+ * @category WEB4PRO
7
+ * @package Web4pro_Stockstatus
8
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
9
+ * @license http://www.web4pro.net/license.txt
10
+ */
11
+ ?>
12
+ <?php
13
+ /**
14
+ * Attribute otions control
15
+ *
16
+ * @see Mage_Adminhtml_Block_Catalog_Product_Attribute_Edit_Tab_Options
17
+ */
18
+ ?>
19
+ <div>
20
+ <ul class="messages">
21
+ <li class="notice-msg">
22
+ <ul>
23
+ <li><?php echo Mage::helper('catalog')->__('If you do not specify an option value for a specific store view then the default (Admin) value will be used.') ?></li>
24
+ </ul>
25
+ </li>
26
+ </ul>
27
+ </div>
28
+
29
+ <div class="entity-edit">
30
+ <div class="entry-edit-head">
31
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('catalog')->__('Manage Titles (Size, Color, etc.)') ?></h4>
32
+ </div>
33
+ <div class="box">
34
+ <div class="hor-scroll">
35
+ <table class="dynamic-grid" cellspacing="0" id="attribute-labels-table">
36
+ <tr>
37
+ <?php foreach ($this->getStores() as $_store): ?>
38
+ <th><?php echo $_store->getName() ?></th>
39
+ <?php endforeach; ?>
40
+ </tr>
41
+ <tr>
42
+ <?php $_labels = $this->getLabelValues() ?>
43
+ <?php foreach ($this->getStores() as $_store): ?>
44
+ <td>
45
+ <input class="input-text<?php if($_store->getId()==0): ?> required-option<?php endif; ?>" type="text" name="frontend_label[<?php echo $_store->getId() ?>]" value="<?php echo $this->htmlEscape($_labels[$_store->getId()]) ?>"<?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/>
46
+ </td>
47
+ <?php endforeach; ?>
48
+ </tr>
49
+ </table>
50
+ </div>
51
+ </div>
52
+ </div>
53
+ <br/>
54
+ <div class="entity-edit" id="matage-options-panel">
55
+ <div class="entry-edit-head">
56
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo Mage::helper('catalog')->__('Manage Options (values of your attribute)') ?></h4>
57
+ </div>
58
+ <div class="box">
59
+ <div class="hor-scroll">
60
+ <table class="dynamic-grid" cellspacing="0" cellpadding="0">
61
+ <tr id="attribute-options-table">
62
+ <?php foreach ($this->getStores() as $_store): ?>
63
+ <th><?php echo $_store->getName() ?></th>
64
+ <?php endforeach; ?>
65
+ <th><?php echo Mage::helper('catalog')->__('Position') ?></th>
66
+ <th class="nobr a-center"><?php echo Mage::helper('catalog')->__('Is Default') ?></th>
67
+ <th class="nobr"><?php echo Mage::helper('catalog')->__('Image') ?></th>
68
+ <th>
69
+ <?php if (!$this->getReadOnly()):?>
70
+ <?php echo $this->getAddNewButtonHtml() ?>
71
+ <?php endif;?>
72
+ </th>
73
+ </tr>
74
+ <tr class="no-display template" id="row-template">
75
+ <?php foreach ($this->getStores() as $_store): ?>
76
+ <td><input name="option[value][{{id}}][<?php echo $_store->getId() ?>]" value="{{store<?php echo $_store->getId() ?>}}" class="input-text<?php if($_store->getId()==0): ?> required-option<?php endif; ?>" type="text" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/></td>
77
+ <?php endforeach; ?>
78
+ <td class="a-center"><input class="input-text" type="text" name="option[order][{{id}}]" value="{{sort_order}}" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/></td>
79
+ <td><input class="input-radio" type="radio" name="default[]" value="{{id}}" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/></td>
80
+ <td class="a-left">
81
+ <input type="hidden" class="delete-flag" name="option[delete][{{id}}]" value="" />
82
+ <?php if (!$this->getReadOnly()):?>
83
+ <?php echo $this->getDeleteButtonHtml() ?>
84
+ <?php endif;?>
85
+ </td>
86
+ </tr>
87
+ </table>
88
+ </div>
89
+ <input type="hidden" id="option-count-check" value="" />
90
+ </div>
91
+ </div>
92
+ <script type="text/javascript">
93
+ //<![CDATA[
94
+ var optionDefaultInputType = 'radio';
95
+
96
+ // IE removes quotes from element.innerHTML whenever it thinks they're not needed, which breaks html.
97
+ var templateText =
98
+ '<tr class="option-row">'+
99
+ <?php foreach ($this->getStores() as $_store): ?>
100
+ '<td><input name="option[value][{{id}}][<?php echo $_store->getId() ?>]" value="{{store<?php echo $_store->getId() ?>}}" class="input-text<?php if($_store->getId()==0): ?> required-option<?php endif; ?>" type="text" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/><\/td>'+
101
+ <?php endforeach; ?>
102
+ '<td><input class="input-text" type="text" name="option[order][{{id}}]" value="{{sort_order}}" <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/><\/td>'+
103
+ '<td class="a-center"><input class="input-radio" type="{{intype}}" name="default[]" value="{{id}}" {{checked}} <?php if ($this->getReadOnly()):?> disabled="disabled"<?php endif;?>/><\/td>'+
104
+ '<td class="nobr"><input id="option_image_{{id}}" type="text" name="option[image][{{id}}]" value="{{image}}" class="attribute_option_image" style="width:300px;" /><button id="add_image_{{id}}" class="scalable" type="button" onclick="MediabrowserUtility.openDialog(\'<?php echo Mage::getSingleton('adminhtml/url')->getUrl('*/cms_wysiwyg_images/index', array('static_urls_allowed' => 1)) ?>target_element_id/option_image_{{id}}/\');"><span>...</span></button></td>'+
105
+ '<td class="a-left">'+
106
+ '<input type="hidden" class="delete-flag" name="option[delete][{{id}}]" value="" />'+
107
+ <?php if (!$this->getReadOnly()):?>
108
+ '<?php echo $this->getDeleteButtonHtml() ?>'+
109
+ <?php endif;?>
110
+ '<\/td>'+
111
+ '<\/tr>';
112
+
113
+ var attributeOption = {
114
+ table : $('attribute-options-table'),
115
+ templateSyntax : /(^|.|\r|\n)({{(\w+)}})/,
116
+ templateText : templateText,
117
+ itemCount : 0,
118
+ totalItems : 0,
119
+ add : function(data) {
120
+ this.template = new Template(this.templateText, this.templateSyntax);
121
+ if(!data.id){
122
+ data = {};
123
+ data.id = 'option_'+this.itemCount;
124
+ }
125
+ if (!data.intype)
126
+ data.intype = optionDefaultInputType;
127
+
128
+ Element.insert(this.table, {after: this.template.evaluate(data)});
129
+ this.bindRemoveButtons();
130
+ this.itemCount++;
131
+ this.totalItems++;
132
+ this.updateItemsCountField();
133
+ },
134
+ remove : function(event){
135
+ var element = $(Event.findElement(event, 'tr')); // !!! Button already
136
+ // have table parent in safari
137
+ // Safari workaround
138
+ element.ancestors().each(function(parentItem){
139
+ if (parentItem.hasClassName('option-row')) {
140
+ element = parentItem;
141
+ throw $break;
142
+ } else if (parentItem.hasClassName('box')) {
143
+ throw $break;
144
+ }
145
+ });
146
+
147
+
148
+ if(element){
149
+ var elementFlags = element.getElementsByClassName('delete-flag');
150
+ if(elementFlags[0]){
151
+ elementFlags[0].value=1;
152
+ }
153
+
154
+ element.addClassName('no-display');
155
+ element.addClassName('template');
156
+ element.hide();
157
+ this.totalItems--;
158
+ this.updateItemsCountField();
159
+ }
160
+ },
161
+ updateItemsCountField: function() {
162
+ if (this.totalItems > 0) {
163
+ $('option-count-check').value = '1';
164
+ } else {
165
+ $('option-count-check').value = '';
166
+ }
167
+ },
168
+ bindRemoveButtons : function(){
169
+ var buttons = $$('.delete-option');
170
+ for(var i=0;i<buttons.length;i++){
171
+ if(!$(buttons[i]).binded){
172
+ $(buttons[i]).binded = true;
173
+ Event.observe(buttons[i], 'click', this.remove.bind(this));
174
+ }
175
+ }
176
+ }
177
+
178
+ }
179
+ if($('row-template')){
180
+ $('row-template').remove();
181
+ }
182
+ attributeOption.bindRemoveButtons();
183
+
184
+ if($('add_new_option_button')){
185
+ Event.observe('add_new_option_button', 'click', attributeOption.add.bind(attributeOption));
186
+ }
187
+ Validation.addAllThese([
188
+ ['required-option', '<?php echo Mage::helper('catalog')->__('Failed') ?>', function(v) {
189
+ return !Validation.get('IsEmpty').test(v);
190
+ }]]);
191
+ Validation.addAllThese([
192
+ ['required-options-count', '<?php echo Mage::helper('catalog')->__('Options is required') ?>', function(v) {
193
+ return !Validation.get('IsEmpty').test(v);
194
+ }]]);
195
+ <?php foreach ($this->getOptionValues() as $_value): ?>
196
+ attributeOption.add(<?php echo $_value->toJson() ?>);
197
+ <?php endforeach; ?>
198
+ //]]>
199
+ </script>
app/design/frontend/base/default/layout/web4pro_stockstatus.xml CHANGED
@@ -1,29 +1,29 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * WEB4PRO - Creating profitable online stores
5
- *
6
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
7
- * @category WEB4PRO
8
- * @package Web4pro_Stockstatus
9
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
10
- * @license http://www.web4pro.net/license.txt
11
- */
12
- -->
13
- <layout>
14
- <PRODUCT_TYPE_configurable translate="label" module="catalog">
15
- <reference name="head">
16
- <action method="addItem"><type>skin_js</type><name>js/web4pro/stockstatus/stockstatus.js</name></action>
17
- </reference>
18
- </PRODUCT_TYPE_configurable>
19
- <PRODUCT_TYPE_bundle>
20
- <reference name="head">
21
- <action method="addItem"><type>skin_js</type><name>js/web4pro/stockstatus/stockstatus.js</name></action>
22
- </reference>
23
- </PRODUCT_TYPE_bundle>
24
- <PRODUCT_TYPE_grouped module="catalog">
25
- <reference name="product.info.grouped">
26
- <action method="setTemplate"><tempale>web4pro_stockstatus/catalog/product/view/type/grouped.phtml</tempale></action>
27
- </reference>
28
- </PRODUCT_TYPE_grouped>
29
- </layout>
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * WEB4PRO - Creating profitable online stores
5
+ *
6
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
7
+ * @category WEB4PRO
8
+ * @package Web4pro_Stockstatus
9
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
10
+ * @license http://www.web4pro.net/license.txt
11
+ */
12
+ -->
13
+ <layout>
14
+ <PRODUCT_TYPE_configurable translate="label" module="catalog">
15
+ <reference name="head">
16
+ <action method="addItem"><type>skin_js</type><name>js/web4pro/stockstatus/stockstatus.js</name></action>
17
+ </reference>
18
+ </PRODUCT_TYPE_configurable>
19
+ <PRODUCT_TYPE_bundle>
20
+ <reference name="head">
21
+ <action method="addItem"><type>skin_js</type><name>js/web4pro/stockstatus/stockstatus.js</name></action>
22
+ </reference>
23
+ </PRODUCT_TYPE_bundle>
24
+ <PRODUCT_TYPE_grouped module="catalog">
25
+ <reference name="product.info.grouped">
26
+ <action method="setTemplate"><tempale>web4pro_stockstatus/catalog/product/view/type/grouped.phtml</tempale></action>
27
+ </reference>
28
+ </PRODUCT_TYPE_grouped>
29
+ </layout>
app/design/frontend/base/default/template/web4pro_stockstatus/catalog/product/view/type/grouped.phtml CHANGED
@@ -1,93 +1,93 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Academic Free License (AFL 3.0)
8
- * that is bundled with this package in the file LICENSE_AFL.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/afl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magento.com so we can send you a copy immediately.
14
- *
15
- * DISCLAIMER
16
- *
17
- * Do not edit or add to this file if you wish to upgrade Magento to newer
18
- * versions in the future. If you wish to customize Magento for your
19
- * needs please refer to http://www.magento.com for more information.
20
- *
21
- * @category design
22
- * @package rwd_default
23
- * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
24
- * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
- */
26
-
27
- /**
28
- * Grouped product data template
29
- *
30
- * @see Mage_Catalog_Block_Product_View_Media
31
- * @see Mage_Catalog_Block_Product_View_Type_Grouped
32
- */
33
- ?>
34
- <?php $this->setPreconfiguredValue(); ?>
35
- <?php $_product = $this->getProduct(); ?>
36
- <?php $_associatedProducts = $this->getAssociatedProducts(); ?>
37
- <?php $_hasAssociatedProducts = count($_associatedProducts) > 0; ?>
38
- <?php echo $this->getChildHtml('product_type_data_extra') ?>
39
- <div class="grouped-items-table-wrapper">
40
- <table class="data-table grouped-items-table" id="super-product-table">
41
- <col />
42
- <col />
43
- <col />
44
- <tbody>
45
- <?php if ($_hasAssociatedProducts): ?>
46
- <?php foreach ($_associatedProducts as $_item): ?>
47
- <?php $_finalPriceInclTax = $this->helper('tax')->getPrice($_item, $_item->getFinalPrice(), true) ?>
48
- <tr>
49
- <td class='image'>
50
- <img class="thumbnail"
51
- src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->constrainOnly(true)->resize(105, 80); ?>"
52
- alt="<?php echo $this->escapeHtml($this->getImageLabel()) ?>"
53
- title="<?php echo $this->escapeHtml($this->getImageLabel()); ?>" />
54
- </td>
55
- <td class="name">
56
- <p class="name-wrapper">
57
- <?php echo $this->escapeHtml($_item->getName()) ?>
58
- </p>
59
- <?php if ($_product->isSaleable()): ?>
60
- <div class="qty-wrapper">
61
- <?php if ($_item->isSaleable()) : ?>
62
- <p class="availability in-stock">
63
- <?php echo $this->escapeHtml(Mage::helper("web4pro_stockstatus")->getStockStatus($_item)) ?>
64
- </p>
65
- <input id="super_group_<?php echo $_item->getId(); ?>" type="text" pattern="\d*" name="super_group[<?php echo $_item->getId() ?>]" maxlength="12" value="<?php echo $_item->getQty()*1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
66
- <label for="super_group_<?php echo $_item->getId(); ?>" class="qty-label">
67
- <?php echo $this->__('Quantity'); ?>
68
- </label>
69
- <?php else: ?>
70
- <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
71
- <?php endif; ?>
72
- </div>
73
- <?php endif; ?>
74
- </td>
75
- <?php if ($this->getCanShowProductPrice($_product)): ?>
76
- <td class="a-right">
77
- <?php if ($this->getCanShowProductPrice($_item)): ?>
78
- <?php echo $this->getPriceHtml($_item, true) ?>
79
- <?php echo $this->getTierPriceHtml($_item) ?>
80
- <?php endif; ?>
81
- </td>
82
- <?php endif; ?>
83
- </tr>
84
- <?php endforeach; ?>
85
- <?php else: ?>
86
- <tr>
87
- <td colspan="<?php if ($_product->isSaleable()): ?>4<?php else : ?>3<?php endif; ?>"><?php echo $this->__('No options of this product are available.') ?></td>
88
- </tr>
89
- <?php endif; ?>
90
- </tbody>
91
- </table>
92
- </div>
93
- <script type="text/javascript">decorateTable('super-product-table')</script>
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package rwd_default
23
+ * @copyright Copyright (c) 2006-2015 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Grouped product data template
29
+ *
30
+ * @see Mage_Catalog_Block_Product_View_Media
31
+ * @see Mage_Catalog_Block_Product_View_Type_Grouped
32
+ */
33
+ ?>
34
+ <?php $this->setPreconfiguredValue(); ?>
35
+ <?php $_product = $this->getProduct(); ?>
36
+ <?php $_associatedProducts = $this->getAssociatedProducts(); ?>
37
+ <?php $_hasAssociatedProducts = count($_associatedProducts) > 0; ?>
38
+ <?php echo $this->getChildHtml('product_type_data_extra') ?>
39
+ <div class="grouped-items-table-wrapper">
40
+ <table class="data-table grouped-items-table" id="super-product-table">
41
+ <col />
42
+ <col />
43
+ <col />
44
+ <tbody>
45
+ <?php if ($_hasAssociatedProducts): ?>
46
+ <?php foreach ($_associatedProducts as $_item): ?>
47
+ <?php $_finalPriceInclTax = $this->helper('tax')->getPrice($_item, $_item->getFinalPrice(), true) ?>
48
+ <tr>
49
+ <td class='image'>
50
+ <img class="thumbnail"
51
+ src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->constrainOnly(true)->resize(105, 80); ?>"
52
+ alt="<?php echo $this->escapeHtml($this->getImageLabel()) ?>"
53
+ title="<?php echo $this->escapeHtml($this->getImageLabel()); ?>" />
54
+ </td>
55
+ <td class="name">
56
+ <p class="name-wrapper">
57
+ <?php echo $this->escapeHtml($_item->getName()) ?>
58
+ </p>
59
+ <?php if ($_product->isSaleable()): ?>
60
+ <div class="qty-wrapper">
61
+ <?php if ($_item->isSaleable()) : ?>
62
+ <p class="availability in-stock">
63
+ <?php echo Mage::helper("web4pro_stockstatus")->getChildStockStatus($_item) ?>
64
+ </p>
65
+ <input id="super_group_<?php echo $_item->getId(); ?>" type="text" pattern="\d*" name="super_group[<?php echo $_item->getId() ?>]" maxlength="12" value="<?php echo $_item->getQty()*1 ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty" />
66
+ <label for="super_group_<?php echo $_item->getId(); ?>" class="qty-label">
67
+ <?php echo $this->__('Quantity'); ?>
68
+ </label>
69
+ <?php else: ?>
70
+ <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock') ?></span></p>
71
+ <?php endif; ?>
72
+ </div>
73
+ <?php endif; ?>
74
+ </td>
75
+ <?php if ($this->getCanShowProductPrice($_product)): ?>
76
+ <td class="a-right">
77
+ <?php if ($this->getCanShowProductPrice($_item)): ?>
78
+ <?php echo $this->getPriceHtml($_item, true) ?>
79
+ <?php echo $this->getTierPriceHtml($_item) ?>
80
+ <?php endif; ?>
81
+ </td>
82
+ <?php endif; ?>
83
+ </tr>
84
+ <?php endforeach; ?>
85
+ <?php else: ?>
86
+ <tr>
87
+ <td colspan="<?php if ($_product->isSaleable()): ?>4<?php else : ?>3<?php endif; ?>"><?php echo $this->__('No options of this product are available.') ?></td>
88
+ </tr>
89
+ <?php endif; ?>
90
+ </tbody>
91
+ </table>
92
+ </div>
93
+ <script type="text/javascript">decorateTable('super-product-table')</script>
app/etc/modules/Web4pro_Stockstatus.xml CHANGED
@@ -1,20 +1,20 @@
1
- <?xml version="1.0"?>
2
- <!--
3
- /**
4
- * WEB4PRO - Creating profitable online stores
5
- *
6
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
7
- * @category WEB4PRO
8
- * @package Web4pro_Stockstatus
9
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
10
- * @license http://www.web4pro.net/license.txt
11
- */
12
- -->
13
- <config>
14
- <modules>
15
- <Web4pro_Stockstatus>
16
- <active>true</active>
17
- <codePool>community</codePool>
18
- </Web4pro_Stockstatus>
19
- </modules>
20
- </config>
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * WEB4PRO - Creating profitable online stores
5
+ *
6
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
7
+ * @category WEB4PRO
8
+ * @package Web4pro_Stockstatus
9
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
10
+ * @license http://www.web4pro.net/license.txt
11
+ */
12
+ -->
13
+ <config>
14
+ <modules>
15
+ <Web4pro_Stockstatus>
16
+ <active>true</active>
17
+ <codePool>community</codePool>
18
+ </Web4pro_Stockstatus>
19
+ </modules>
20
+ </config>
app/locale/en_US/Web4pro_Stockstatus.csv CHANGED
@@ -1,18 +1,18 @@
1
- ,
2
- Web4pro,Web4pro
3
- General Options,General Options
4
- Show Stock Status When Out Of Stock?,Show Stock Status When Out Of Stock?
5
- Do you want to show custom stock status instead of 'Out of stock' when product is not in stock?,Do you want to show custom stock status instead of 'Out of stock' when product is not in stock?
6
- Display Custom Stock Status On Product List Page,Display Custom Stock Status On Product List Page
7
- Display Custom Stock Status in Shopping Cart,Display Custom Stock Status in Shopping Cart
8
- Will display custom stock status for items in shopping cart.,Will display custom stock status for items in shopping cart.
9
- Show Stock Level?,Show Stock Level?
10
- Show the actual quantity in stock?,Show the actual quantity in stock?
11
- Availability:,Availability:
12
- In stock,In stock
13
- Out of stock,Out of stock
14
- %s in stock,%s in stock
15
- Product Name,Product Name
16
- Price,Price
17
- Qty,Qty
18
- No options of this product are available.,No options of this product are available.
1
+ ,
2
+ Web4pro,Web4pro
3
+ General Options,General Options
4
+ Show Stock Status When Out Of Stock?,Show Stock Status When Out Of Stock?
5
+ Do you want to show custom stock status instead of 'Out of stock' when product is not in stock?,Do you want to show custom stock status instead of 'Out of stock' when product is not in stock?
6
+ Display Custom Stock Status On Product List Page,Display Custom Stock Status On Product List Page
7
+ Display Custom Stock Status in Shopping Cart,Display Custom Stock Status in Shopping Cart
8
+ Will display custom stock status for items in shopping cart.,Will display custom stock status for items in shopping cart.
9
+ Show Stock Level?,Show Stock Level?
10
+ Show the actual quantity in stock?,Show the actual quantity in stock?
11
+ Availability:,Availability:
12
+ In stock,In stock
13
+ Out of stock,Out of stock
14
+ %s in stock,%s in stock
15
+ Product Name,Product Name
16
+ Price,Price
17
+ Qty,Qty
18
+ No options of this product are available.,No options of this product are available.
package.xml CHANGED
@@ -1,24 +1,24 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Web4pro_Stockstatus</name>
4
- <version>1.0.4</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.web4pro.net/license.txt">GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Replace default stock statuses with text or configure the number of products available in stock. </summary>
10
  <description>With this module you are able to set a custom "stock status" in the products edit page for each and every simple product.</description>
11
- <notes>Version number: 1.0.1&#xD;
12
- Version number: 1.0.2&#xD;
13
- - Ability to add custom image at stockstatus&#xD;
14
- Version number: 1.0.3&#xD;
15
- - correct swatches behavior&#xD;
16
- Version number: 1.0.4&#xD;
17
  - grouped and bandle products fix</notes>
18
  <authors><author><name>Sergey Poprigin</name><user>spoprigin</user><email>spoprigin@corp.web4pro.com.ua</email></author></authors>
19
- <date>2015-09-09</date>
20
- <time>09:32:57</time>
21
- <contents><target name="magecommunity"><dir name="Web4pro"><dir name="Stockstatus"><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><dir name="Attribute"><file name="Options.php" hash="af988e8f1323b4584c881239523998d1"/><file name="Options.php~" hash="9c57b2420b522a974dcfdb209022c2b0"/></dir></dir></dir></dir><dir name="Catalog"><dir name="Product"><dir name="View"><dir name="Type"><dir name="Bundle"><dir name="Option"><file name="Checkbox.php" hash="c4099a200a945441d73bd05b6e2a380d"/><file name="Multi.php" hash="3833051ccc5e2fa8d0d889370c7e7e88"/><file name="Radio.php" hash="a84228b8ebcc1762c7ae5c10ffb2b7cb"/><file name="Select.php" hash="aa9ead2a4caca487e6a5ac8c057a2964"/></dir><file name="Option.php" hash="6f89953e7e34a048211d99b2fa935471"/></dir><file name="Configurable.php" hash="571a10f0b1daae80b058d0c187687bd9"/></dir></dir></dir></dir><file name="Stockstatus.php" hash="45aa55bb9470663949b43900a071c159"/></dir><dir name="Helper"><dir name="Cms"><dir name="Wysiwyg"><file name="Images.php" hash="dd697899de675ecc64422a24cd611e2e"/></dir></dir><file name="Data.php" hash="c4e38c567e5dba1fcacf4cf9ab0bbd0c"/></dir><dir name="Model"><dir name="Catalog"><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Attribute.php" hash="209ad55952709f7627705d2d8c963e28"/></dir></dir></dir></dir><dir name="Eav"><dir name="Entity"><dir name="Attribute"><dir name="Source"><file name="Table.php" hash="f74b63a10fc14cd49ae98bf611ca2f1e"/></dir></dir></dir><dir name="Mysql4"><dir name="Entity"><dir name="Attribute"><file name="Option.php" hash="9bdf04d8a73cd4302f698d9554446682"/></dir></dir></dir></dir><file name="Observer.php" hash="de257ab8bc202c66f94aac6e1bba8f0f"/><file name="Observer.php~" hash="47e6de47df5e2c9ac41e0d0798d6a4e1"/></dir><dir name="controllers"><dir name="Cms"><dir name="Wysiwyg"><file name="ImagesController.php" hash="1c1ee0b19ba290f0e617f8f1d79499ee"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="4483da36b754d5ffd4bcef726bff7ef1"/><file name="config.xml" hash="0a10cb3c192be3f41a16675d19f0c10d"/><file name="system.xml" hash="2e27f5f00e595991846207e625760119"/></dir><dir name="sql"><dir name="web4pro_stockstatus_setup"><file name="install-1.0.0.php" hash="84c89697aaf93884514f20ffc1816f64"/><file name="install-1.0.0.php~" hash="e3188e776007cf300b4d0b0961c17d7e"/><file name="upgrade-1.0.0-1.0.2.php" hash="edca71ac39d408c1a812cc82331ff495"/><file name="upgrade-1.0.2-1.0.3.php" hash="aac7e40fa9c4028181c39c42d9097af1"/><file name="upgrade-1.0.2-1.0.3.php~" hash="3a424db71a4f3348bbf79632cac0bf61"/><file name="upgrade-1.0.3-1.0.4.php" hash="984daab7b432e5df7a678b4f12e902df"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="stockstatus"><dir name="catalog"><dir name="product"><dir name="attribute"><file name="options.phtml" hash="66ebd7097587518e65c24ee043bee466"/></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="web4pro_stockstatus.xml" hash="192da5b539d3e68f0a4ab011b146f8a0"/></dir><dir name="template"><dir name="web4pro_stockstatus"><dir name="catalog"><dir name="product"><dir name="view"><dir name="type"><file name="grouped.phtml" hash="9867c7bb3ef4f6b0600ab17e44a8073a"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Web4pro_Stockstatus.xml" hash="c7a0ae32162bb27eed946ae5e00f6b4d"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Web4pro_Stockstatus.csv" hash="34b6e870362cfa0287921f4a4424d74c"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="js"><dir name="web4pro"><dir name="stockstatus"><file name="stockstatus.js" hash="5a849ff6b9fd89608beec4c554085cb6"/></dir></dir></dir></dir></dir></dir></target></contents>
22
  <compatible/>
23
- <dependencies><required><php><min>5.3.0</min><max>5.6.0</max></php></required></dependencies>
24
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Web4pro_Stockstatus</name>
4
+ <version>1.0.5</version>
5
  <stability>stable</stability>
6
  <license uri="http://www.web4pro.net/license.txt">GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Replace default stock statuses with text or configure the number of products available in stock.</summary>
10
  <description>With this module you are able to set a custom "stock status" in the products edit page for each and every simple product.</description>
11
+ <notes>Version number: 1.0.1;&#xD;
12
+ Version number: 1.0.2;&#xD;
13
+ - Ability to add custom image at stockstatus;&#xD;
14
+ Version number: 1.0.3;&#xD;
15
+ - correct swatches behavior;&#xD;
16
+ Version number: 1.0.4;&#xD;
17
  - grouped and bandle products fix</notes>
18
  <authors><author><name>Sergey Poprigin</name><user>spoprigin</user><email>spoprigin@corp.web4pro.com.ua</email></author></authors>
19
+ <date>2016-08-11</date>
20
+ <time>14:55:39</time>
21
+ <contents><target name="mage"><dir name="app"><dir name="code"><dir name="community"><dir name="Web4pro"><dir name="Stockstatus"><dir><dir name="Block"><dir name="Adminhtml"><dir name="Catalog"><dir name="Product"><dir name="Attribute"><file name="Options.php" hash="309269cb5ab65d8da17e66b7ac47fd61"/></dir></dir></dir></dir><dir name="Catalog"><dir name="Product"><dir name="View"><dir name="Type"><dir name="Bundle"><dir name="Option"><file name="Checkbox.php" hash="eeff94004fb5c1da8993539d7d7b44b6"/><file name="Multi.php" hash="96860127b8765d3b7a621189a38de622"/><file name="Radio.php" hash="db41ad0e693dca6b36041f1e50a8192e"/><file name="Select.php" hash="b08eb844845c7701f3dcba7a93d0e219"/></dir><file name="Option.php" hash="0f242b145e41bedc62c81854b7b10edf"/></dir><file name="Configurable.php" hash="0e1c84aa6cb29c75a6ec24dc9291fa2f"/></dir></dir></dir></dir><file name="Stockstatus.php" hash="87f17774ddd57cd2ada7af665fe2c2ef"/></dir><dir name="Helper"><dir name="Cms"><dir name="Wysiwyg"><file name="Images.php" hash="01df7f921d8375c5a323a270419eea76"/></dir></dir><file name="Data.php" hash="408c472bca066499671874f76accca23"/></dir><dir name="Model"><dir name="Catalog"><dir name="Resource"><dir name="Eav"><dir name="Mysql4"><file name="Attribute.php" hash="a412d649d2f0d5a96b0e34d6453ada4a"/></dir></dir></dir></dir><dir name="Eav"><dir name="Entity"><dir name="Attribute"><dir name="Source"><file name="Table.php" hash="e9403dce98c60acc91055cc029ed29c2"/></dir></dir></dir><dir name="Mysql4"><dir name="Entity"><dir name="Attribute"><file name="Option.php" hash="1db9301e5aad5f1a647623b9e90f7e2a"/></dir></dir></dir></dir><file name="Observer.php" hash="a68db167f9ff4a205c585fa55ebf764e"/></dir><dir name="controllers"><dir name="Cms"><dir name="Wysiwyg"><file name="ImagesController.php" hash="58c309e20b93dbf7959953f732b4b6a8"/></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="f66f6015906312a84a21e75048c2967a"/><file name="config.xml" hash="3d896629baf5409d33997420ae2187ca"/><file name="system.xml" hash="f9735ef03de4cbb12af627711d2bd5b8"/></dir><dir name="sql"><dir name="web4pro_stockstatus_setup"><file name="install-1.0.0.php" hash="cfbe8f9dfa9a357a253b988845428674"/><file name="upgrade-1.0.0-1.0.2.php" hash="10a4434cd60a5cf4b83f03800b0b15bc"/><file name="upgrade-1.0.2-1.0.3.php" hash="a06641cc3ad6dfa2fe0b8906695f9677"/><file name="upgrade-1.0.3-1.0.4.php" hash="8a1567ff650bee09a0bcc1a8ec56d7cd"/></dir></dir></dir></dir></dir></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="stockstatus"><dir><dir name="catalog"><dir name="product"><dir name="attribute"><file name="options.phtml" hash="4cb26b145c0a82bbe52d9c227dd561d2"/></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="web4pro_stockstatus.xml" hash="e1d63a48ceb64e715db882d4a1e9eaeb"/></dir><dir name="template"><dir name="web4pro_stockstatus"><dir name="catalog"><dir name="product"><dir name="view"><dir name="type"><file name="grouped.phtml" hash="0fb5f63f11da283ba536137b2edca9f5"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir><dir name="etc"><dir name="modules"><file name="Web4pro_Stockstatus.xml" hash="a4edacd65d809924fc9e0d1ed46af2b8"/></dir></dir><dir name="locale"><dir name="en_US"><file name="Web4pro_Stockstatus.csv" hash="ca6312fa4686fe79cd8033ebc4e49fd4"/></dir></dir></dir><dir name="skin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="js"><dir name="web4pro"><dir name="stockstatus"><file name="stockstatus.js" hash="ed9f8cadf4d3b0dd017f905618eaf717"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
22
  <compatible/>
23
+ <dependencies><required><php><min>5.3.0</min><max>5.6.25</max></php></required></dependencies>
24
  </package>
skin/frontend/base/default/js/web4pro/stockstatus/stockstatus.js CHANGED
@@ -1,159 +1,159 @@
1
- /**
2
- * WEB4PRO - Creating profitable online stores
3
- *
4
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
5
- * @category WEB4PRO
6
- * @package Web4pro_Stockstatus
7
- * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
8
- * @license http://www.web4pro.net/license.txt
9
- */
10
- /**
11
- * Attachments default helper
12
- *
13
- * @category Web4pro
14
- * @package Web4pro_Stockstatus
15
- * @author WEB4PRO <srepin@corp.web4pro.com.ua>
16
- */
17
-
18
- Product.Config.prototype.getOptionLabel_base = Product.Config.prototype.getOptionLabel;
19
- Product.Config.prototype.getOptionLabel = function(option, price) {
20
- var str = Product.Config.prototype.getOptionLabel_base.call(this, option, price);
21
- if(option._f != undefined && !option._f.isSwatch){
22
- if(option.allowedProducts.size() == 1){
23
- var status = this.config.stockstatuses[option.allowedProducts].stockstatus;
24
- str+= ' (' + status + ')';
25
- }
26
- }
27
- return str;
28
- };
29
-
30
- Product.Config.prototype.getIdOfSelectedProduct = function() {
31
- var status = '';
32
- var existingProducts = new Object();
33
-
34
- for (var i = this.settings.length - 1; i >= 0; i--) {
35
- var selected = this.settings[i].options[this.settings[i].selectedIndex];
36
- if (selected.config) {
37
- for (var iproducts = 0; iproducts < selected.config.products.length; iproducts++) {
38
- var usedAsKey = selected.config.products[iproducts] + "";
39
- if (existingProducts[usedAsKey] == undefined) {
40
- existingProducts[usedAsKey] = 1;
41
- }
42
- else {
43
- existingProducts[usedAsKey] = existingProducts[usedAsKey] + 1;
44
- }
45
- }
46
- }
47
- }
48
-
49
- for (var keyValue in existingProducts) {
50
- for (var keyValueInner in existingProducts) {
51
- if (Number(existingProducts[keyValueInner]) < Number(existingProducts[keyValue])) {
52
- delete existingProducts[keyValueInner];
53
- }
54
- }
55
- }
56
-
57
- var sizeOfExistingProducts = 0;
58
- var currentSimpleProductId = "";
59
- for (var keyValue in existingProducts) {
60
- currentSimpleProductId = keyValue;
61
- sizeOfExistingProducts = sizeOfExistingProducts + 1
62
- }
63
-
64
- if (sizeOfExistingProducts == 1) {
65
- return currentSimpleProductId;
66
- }
67
-
68
- };
69
- if(Product.ConfigurableSwatches != undefined){
70
- Product.ConfigurableSwatches.prototype.getProductByOption = function(option, options){
71
- try{
72
- var arr = [];
73
- var productCode = '';
74
- if(option != null){
75
- productCode = option.attr.code;
76
- arr.push(option.allowedProducts);
77
- }
78
- for (var i in options) {
79
- if(options[i].code == productCode) continue;
80
- arr.push(options[i]._e.selectedOption.allowedProducts);
81
- }
82
- arr = this._u.intersectAll(arr);
83
- if(arr.length > 1) return false;
84
- return arr[0];
85
- } catch(e){
86
- return false;
87
- }
88
-
89
- };
90
-
91
- Product.ConfigurableSwatches.prototype.checkStockStatus = function() {
92
- var inStock = true;
93
- var checkOptions = arguments.length ? arguments[0] : this._E.activeConfigurableOptions;
94
- var arr = {};
95
- // Set out of stock if any selected item is not enabled
96
- checkOptions.each( function(selectedOpt) {
97
- arr[selectedOpt.id] = selectedOpt.attr;
98
- if (!selectedOpt._f.enabled) {
99
- inStock = false;
100
- }
101
- });
102
- var option = (this._F.currentAction == 'over-swatch' || this._F.currentAction == 'out-swatch') ? this._E.optionOver : null;
103
- var productId = this.getProductByOption(option, arr);
104
- var stockStatus = (checkOptions.size() > 1) && productId ? getFormatStockStatus(Translator.translate(spConfig.config.stockstatuses[productId].stockstatus)): Product.Config.standartStockStatus;
105
- this.setStockStatus( inStock, stockStatus);
106
- };
107
-
108
- Product.ConfigurableSwatches.prototype.setStockStatus = function(inStock, stockStatus) {
109
- if (inStock) {
110
- this._E.availability.each(function(el) {
111
- var el = $(el);
112
- el.addClassName('in-stock').removeClassName('out-of-stock');
113
- el.textContent = stockStatus;
114
- });
115
-
116
- this._E.cartBtn.btn.each(function(el, index) {
117
- var el = $(el);
118
- el.disabled = false;
119
- el.removeClassName('out-of-stock');
120
- el.writeAttribute('onclick', this._E.cartBtn.onclick);
121
- el.title = '' + Translator.translate(this._E.cartBtn.txt[index]);
122
- el.select('span span').invoke('update', Translator.translate(this._E.cartBtn.txt[index]));
123
- }.bind(this));
124
- } else {
125
- this._E.availability.each(function(el) {
126
- var el = $(el);
127
- el.addClassName('out-of-stock').removeClassName('in-stock');
128
- el.textContent = Translator.translate('Out of stock');
129
- });
130
- this._E.cartBtn.btn.each(function(el) {
131
- var el = $(el);
132
- el.addClassName('out-of-stock');
133
- el.disabled = true;
134
- el.removeAttribute('onclick');
135
- el.observe('click', function(event) {
136
- Event.stop(event);
137
- return false;
138
- });
139
- el.writeAttribute('title', Translator.translate('Out of Stock'));
140
- el.select('span span').invoke('update', Translator.translate('Out of Stock'));
141
- });
142
- }
143
- };
144
- }
145
-
146
- function getFormatStockStatus(status){
147
- var availabilityText = spConfig.config.availability;
148
- return status != '' ? availabilityText + ' ' + status : '';
149
- }
150
-
151
- document.observe("dom:loaded", function() {
152
- $$('.product-options .input-box select').last().observe('change', function () {
153
- if(typeof spConfig.getIdOfSelectedProduct() != 'undefined') {
154
- var productId = spConfig.getIdOfSelectedProduct();
155
- var status = getFormatStockStatus(spConfig.config.stockstatuses[productId].stockstatus);
156
- $$('p.availability').invoke('update', status);
157
- }
158
- });
159
  });
1
+ /**
2
+ * WEB4PRO - Creating profitable online stores
3
+ *
4
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
5
+ * @category WEB4PRO
6
+ * @package Web4pro_Stockstatus
7
+ * @copyright Copyright (c) 2015 WEB4PRO (http://www.web4pro.net)
8
+ * @license http://www.web4pro.net/license.txt
9
+ */
10
+ /**
11
+ * Attachments default helper
12
+ *
13
+ * @category Web4pro
14
+ * @package Web4pro_Stockstatus
15
+ * @author WEB4PRO <srepin@corp.web4pro.com.ua>
16
+ */
17
+
18
+ Product.Config.prototype.getOptionLabel_base = Product.Config.prototype.getOptionLabel;
19
+ Product.Config.prototype.getOptionLabel = function(option, price) {
20
+ var str = Product.Config.prototype.getOptionLabel_base.call(this, option, price);
21
+ if(option._f != undefined && !option._f.isSwatch){
22
+ if(option.allowedProducts.size() == 1){
23
+ var status = this.config.stockstatuses[option.allowedProducts].stockstatus;
24
+ str+= ' (' + status + ')';
25
+ }
26
+ }
27
+ return str;
28
+ };
29
+
30
+ Product.Config.prototype.getIdOfSelectedProduct = function() {
31
+ var status = '';
32
+ var existingProducts = new Object();
33
+
34
+ for (var i = this.settings.length - 1; i >= 0; i--) {
35
+ var selected = this.settings[i].options[this.settings[i].selectedIndex];
36
+ if (selected.config) {
37
+ for (var iproducts = 0; iproducts < selected.config.products.length; iproducts++) {
38
+ var usedAsKey = selected.config.products[iproducts] + "";
39
+ if (existingProducts[usedAsKey] == undefined) {
40
+ existingProducts[usedAsKey] = 1;
41
+ }
42
+ else {
43
+ existingProducts[usedAsKey] = existingProducts[usedAsKey] + 1;
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+ for (var keyValue in existingProducts) {
50
+ for (var keyValueInner in existingProducts) {
51
+ if (Number(existingProducts[keyValueInner]) < Number(existingProducts[keyValue])) {
52
+ delete existingProducts[keyValueInner];
53
+ }
54
+ }
55
+ }
56
+
57
+ var sizeOfExistingProducts = 0;
58
+ var currentSimpleProductId = "";
59
+ for (var keyValue in existingProducts) {
60
+ currentSimpleProductId = keyValue;
61
+ sizeOfExistingProducts = sizeOfExistingProducts + 1
62
+ }
63
+
64
+ if (sizeOfExistingProducts == 1) {
65
+ return currentSimpleProductId;
66
+ }
67
+
68
+ };
69
+ if(Product.ConfigurableSwatches != undefined){
70
+ Product.ConfigurableSwatches.prototype.getProductByOption = function(option, options){
71
+ try{
72
+ var arr = [];
73
+ var productCode = '';
74
+ if(option != null){
75
+ productCode = option.attr.code;
76
+ arr.push(option.allowedProducts);
77
+ }
78
+ for (var i in options) {
79
+ if(options[i].code == productCode) continue;
80
+ arr.push(options[i]._e.selectedOption.allowedProducts);
81
+ }
82
+ arr = this._u.intersectAll(arr);
83
+ if(arr.length > 1) return false;
84
+ return arr[0];
85
+ } catch(e){
86
+ return false;
87
+ }
88
+
89
+ };
90
+
91
+ Product.ConfigurableSwatches.prototype.checkStockStatus = function() {
92
+ var inStock = true;
93
+ var checkOptions = arguments.length ? arguments[0] : this._E.activeConfigurableOptions;
94
+ var arr = {};
95
+ // Set out of stock if any selected item is not enabled
96
+ checkOptions.each( function(selectedOpt) {
97
+ arr[selectedOpt.id] = selectedOpt.attr;
98
+ if (!selectedOpt._f.enabled) {
99
+ inStock = false;
100
+ }
101
+ });
102
+ var option = (this._F.currentAction == 'over-swatch' || this._F.currentAction == 'out-swatch') ? this._E.optionOver : null;
103
+ var productId = this.getProductByOption(option, arr);
104
+ var stockStatus = (checkOptions.size() > 1) && productId ? getFormatStockStatus(Translator.translate(spConfig.config.stockstatuses[productId].stockstatus), spConfig.config.stock_images[productId].stock_image): Product.Config.standartStockStatus;
105
+ this.setStockStatus( inStock, stockStatus );
106
+ };
107
+
108
+ Product.ConfigurableSwatches.prototype.setStockStatus = function(inStock, stockStatus) {
109
+ if (inStock) {
110
+ this._E.availability.each(function(el) {
111
+ var el = $(el);
112
+ el.addClassName('in-stock').removeClassName('out-of-stock');
113
+ el.update(stockStatus);
114
+ });
115
+
116
+ this._E.cartBtn.btn.each(function(el, index) {
117
+ var el = $(el);
118
+ el.disabled = false;
119
+ el.removeClassName('out-of-stock');
120
+ el.writeAttribute('onclick', this._E.cartBtn.onclick);
121
+ el.title = '' + Translator.translate(this._E.cartBtn.txt[index]);
122
+ el.select('span span').invoke('update', Translator.translate(this._E.cartBtn.txt[index]));
123
+ }.bind(this));
124
+ } else {
125
+ this._E.availability.each(function(el) {
126
+ var el = $(el);
127
+ el.addClassName('out-of-stock').removeClassName('in-stock');
128
+ el.textContent = Translator.translate('Out of stock');
129
+ });
130
+ this._E.cartBtn.btn.each(function(el) {
131
+ var el = $(el);
132
+ el.addClassName('out-of-stock');
133
+ el.disabled = true;
134
+ el.removeAttribute('onclick');
135
+ el.observe('click', function(event) {
136
+ Event.stop(event);
137
+ return false;
138
+ });
139
+ el.writeAttribute('title', Translator.translate('Out of Stock'));
140
+ el.select('span span').invoke('update', Translator.translate('Out of Stock'));
141
+ });
142
+ }
143
+ };
144
+ }
145
+
146
+ function getFormatStockStatus(status, stockImage){
147
+ var availabilityText = spConfig.config.availability;
148
+ return status != '' ? stockImage + availabilityText + ' ' + status : '';
149
+ }
150
+
151
+ document.observe("dom:loaded", function() {
152
+ $$('.product-options .input-box select').last().observe('change', function () {
153
+ if(typeof spConfig.getIdOfSelectedProduct() != 'undefined') {
154
+ var productId = spConfig.getIdOfSelectedProduct();
155
+ var status = getFormatStockStatus(spConfig.config.stockstatuses[productId].stockstatus, spConfig.config.stock_images[productId].stock_image);
156
+ $$('p.availability').invoke('update', status);
157
+ }
158
+ });
159
  });