Version Notes
Version number: 1.0.1
Version number: 1.0.2
- Ability to add custom image at stockstatus
Download this release
Release Info
Developer | Sergey Repin |
Extension | Web4pro_Stockstatus |
Version | 1.0.2 |
Comparing to | |
See all releases |
Code changes from version 1.0.1 to 1.0.2
- app/code/community/Web4pro/Stockstatus/Block/Adminhtml/Catalog/Product/Attribute/Options.php +75 -0
- app/code/community/Web4pro/Stockstatus/Helper/Cms/Wysiwyg/Images.php +34 -0
- app/code/community/Web4pro/Stockstatus/Helper/Data.php +48 -3
- app/code/community/Web4pro/Stockstatus/Model/Catalog/Resource/Eav/Mysql4/Attribute.php +101 -0
- app/code/community/Web4pro/Stockstatus/Model/Eav/Entity/Attribute/Source/Table.php +36 -0
- app/code/community/Web4pro/Stockstatus/Model/Eav/Mysql4/Entity/Attribute/Option.php +30 -0
- app/code/community/Web4pro/Stockstatus/Model/Observer.php +52 -1
- app/code/community/Web4pro/Stockstatus/controllers/Cms/Wysiwyg/ImagesController.php +35 -0
- app/code/community/Web4pro/Stockstatus/etc/config.xml +48 -1
- app/code/community/Web4pro/Stockstatus/etc/system.xml +26 -6
- app/code/community/Web4pro/Stockstatus/sql/web4pro_stockstatus_setup/install-1.0.0.php +1 -1
- app/code/community/Web4pro/Stockstatus/sql/web4pro_stockstatus_setup/upgrade-1.0.0-1.0.2.php +25 -0
- app/design/adminhtml/default/default/template/stockstatus/catalog/product/attribute/options.phtml +199 -0
- package.xml +7 -5
app/code/community/Web4pro/Stockstatus/Block/Adminhtml/Catalog/Product/Attribute/Options.php
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class Web4pro_Stockstatus_Block_Adminhtml_Catalog_Product_Attribute_Options extends Mage_Eav_Block_Adminhtml_Attribute_Edit_Options_Abstract
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
parent::__construct();
|
7 |
+
if (Mage::registry('entity_attribute')->getData('attribute_code') == 'custom_stockstatus') {
|
8 |
+
$this->setTemplate('stockstatus/catalog/product/attribute/options.phtml');
|
9 |
+
}
|
10 |
+
}
|
11 |
+
|
12 |
+
public function getOptionValues()
|
13 |
+
{
|
14 |
+
if (Mage::registry('entity_attribute')->getData('attribute_code') != 'custom_stockstatus') {
|
15 |
+
return parent::getOptionValues();
|
16 |
+
}
|
17 |
+
|
18 |
+
$attributeType = $this->getAttributeObject()->getFrontendInput();
|
19 |
+
$defaultValues = $this->getAttributeObject()->getDefaultValue();
|
20 |
+
if ($attributeType == 'select' || $attributeType == 'multiselect') {
|
21 |
+
$defaultValues = explode(',', $defaultValues);
|
22 |
+
} else {
|
23 |
+
$defaultValues = array();
|
24 |
+
}
|
25 |
+
|
26 |
+
switch ($attributeType) {
|
27 |
+
case 'select':
|
28 |
+
$inputType = 'radio';
|
29 |
+
break;
|
30 |
+
case 'multiselect':
|
31 |
+
$inputType = 'checkbox';
|
32 |
+
break;
|
33 |
+
default:
|
34 |
+
$inputType = '';
|
35 |
+
break;
|
36 |
+
}
|
37 |
+
|
38 |
+
$values = $this->getData('option_values');
|
39 |
+
if (is_null($values)) {
|
40 |
+
$values = array();
|
41 |
+
$optionCollection = Mage::getResourceModel('eav/entity_attribute_option_collection')
|
42 |
+
->setAttributeFilter($this->getAttributeObject()->getId())
|
43 |
+
->setPositionOrder('desc', true)
|
44 |
+
->load();
|
45 |
+
|
46 |
+
foreach ($optionCollection as $option) {
|
47 |
+
$value = array();
|
48 |
+
if (in_array($option->getId(), $defaultValues)) {
|
49 |
+
$value['checked'] = 'checked="checked"';
|
50 |
+
} else {
|
51 |
+
$value['checked'] = '';
|
52 |
+
}
|
53 |
+
|
54 |
+
$value['intype'] = $inputType;
|
55 |
+
$value['id'] = $option->getId();
|
56 |
+
$value['sort_order'] = $option->getSortOrder();
|
57 |
+
$value['image'] = $option->getImage();
|
58 |
+
foreach ($this->getStores() as $store) {
|
59 |
+
$storeValues = $this->getStoreOptionValues($store->getId());
|
60 |
+
if (isset($storeValues[$option->getId()])) {
|
61 |
+
$value['store'.$store->getId()] = htmlspecialchars($storeValues[$option->getId()]);
|
62 |
+
}
|
63 |
+
else {
|
64 |
+
$value['store'.$store->getId()] = '';
|
65 |
+
}
|
66 |
+
}
|
67 |
+
$values[] = new Varien_Object($value);
|
68 |
+
}
|
69 |
+
$this->setData('option_values', $values);
|
70 |
+
}
|
71 |
+
|
72 |
+
return $values;
|
73 |
+
}
|
74 |
+
|
75 |
+
}
|
app/code/community/Web4pro/Stockstatus/Helper/Cms/Wysiwyg/Images.php
ADDED
@@ -0,0 +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 |
+
}
|
app/code/community/Web4pro/Stockstatus/Helper/Data.php
CHANGED
@@ -9,7 +9,7 @@
|
|
9 |
* @license http://www.web4pro.net/license.txt
|
10 |
*/
|
11 |
/**
|
12 |
-
*
|
13 |
*
|
14 |
* @category Web4pro
|
15 |
* @package Web4pro_Stockstatus
|
@@ -87,7 +87,7 @@ class Web4pro_Stockstatus_Helper_Data extends Mage_Core_Helper_Abstract
|
|
87 |
*/
|
88 |
public function isCustomStockStatusOnProductListPage()
|
89 |
{
|
90 |
-
return Mage::getStoreConfig('web4pro_stockstatus/general/
|
91 |
}
|
92 |
|
93 |
/**
|
@@ -109,7 +109,7 @@ class Web4pro_Stockstatus_Helper_Data extends Mage_Core_Helper_Abstract
|
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
-
*
|
113 |
* @return mixed
|
114 |
*/
|
115 |
public function isShowStockLevel()
|
@@ -117,6 +117,25 @@ class Web4pro_Stockstatus_Helper_Data extends Mage_Core_Helper_Abstract
|
|
117 |
return Mage::getStoreConfig('web4pro_stockstatus/general/showstocklevel');
|
118 |
}
|
119 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
/**
|
121 |
* Is the custom status allowed at page of product view
|
122 |
* @param $product
|
@@ -130,4 +149,30 @@ class Web4pro_Stockstatus_Helper_Data extends Mage_Core_Helper_Abstract
|
|
130 |
}
|
131 |
return $result;
|
132 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
133 |
}
|
9 |
* @license http://www.web4pro.net/license.txt
|
10 |
*/
|
11 |
/**
|
12 |
+
* Stockstatus default helper
|
13 |
*
|
14 |
* @category Web4pro
|
15 |
* @package Web4pro_Stockstatus
|
87 |
*/
|
88 |
public function isCustomStockStatusOnProductListPage()
|
89 |
{
|
90 |
+
return Mage::getStoreConfig('web4pro_stockstatus/general/display_at_category');
|
91 |
}
|
92 |
|
93 |
/**
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
+
* Is stock qty displayed
|
113 |
* @return mixed
|
114 |
*/
|
115 |
public function isShowStockLevel()
|
117 |
return Mage::getStoreConfig('web4pro_stockstatus/general/showstocklevel');
|
118 |
}
|
119 |
|
120 |
+
|
121 |
+
/**
|
122 |
+
* Is show icon
|
123 |
+
* @return mixed
|
124 |
+
*/
|
125 |
+
public function isShowStockImage()
|
126 |
+
{
|
127 |
+
return Mage::getStoreConfig('web4pro_stockstatus/general/showimage');
|
128 |
+
}
|
129 |
+
|
130 |
+
/**
|
131 |
+
* Is show icon only
|
132 |
+
* @return mixed
|
133 |
+
*/
|
134 |
+
public function isShowStockImageOnly()
|
135 |
+
{
|
136 |
+
return Mage::getStoreConfig('web4pro_stockstatus/general/showimageonly');
|
137 |
+
}
|
138 |
+
|
139 |
/**
|
140 |
* Is the custom status allowed at page of product view
|
141 |
* @param $product
|
149 |
}
|
150 |
return $result;
|
151 |
}
|
152 |
+
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Generate image url
|
156 |
+
* @param $optionId
|
157 |
+
* @return string
|
158 |
+
*/
|
159 |
+
public function getAttributeOptionImage($optionId)
|
160 |
+
{
|
161 |
+
$images = $this->getAttributeOptionImages();
|
162 |
+
$image = array_key_exists($optionId, $images) ? $images[$optionId] : '';
|
163 |
+
if ($image && (strpos($image, 'http') !== 0)) {
|
164 |
+
$image = Mage::getDesign()->getSkinUrl($image);
|
165 |
+
}
|
166 |
+
return $image;
|
167 |
+
}
|
168 |
+
|
169 |
+
|
170 |
+
/**
|
171 |
+
* @return mixed
|
172 |
+
*/
|
173 |
+
public function getAttributeOptionImages()
|
174 |
+
{
|
175 |
+
$images = Mage::getResourceModel('eav/entity_attribute_option')->getAttributeOptionImages();
|
176 |
+
return $images;
|
177 |
+
}
|
178 |
}
|
app/code/community/Web4pro/Stockstatus/Model/Catalog/Resource/Eav/Mysql4/Attribute.php
ADDED
@@ -0,0 +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 |
+
}
|
app/code/community/Web4pro/Stockstatus/Model/Eav/Entity/Attribute/Source/Table.php
ADDED
@@ -0,0 +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 |
+
}
|
app/code/community/Web4pro/Stockstatus/Model/Eav/Mysql4/Entity/Attribute/Option.php
ADDED
@@ -0,0 +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 |
+
}
|
app/code/community/Web4pro/Stockstatus/Model/Observer.php
CHANGED
@@ -75,7 +75,8 @@ class Web4pro_Stockstatus_Model_Observer
|
|
75 |
Mage::getSingleton('cataloginventory/stock')->addItemsToProducts($collection);
|
76 |
if ($this->_helper->isCustomStockStatusOnProductListPage()){
|
77 |
foreach ($block->getLoadedProductCollection() as $item){
|
78 |
-
$
|
|
|
79 |
}
|
80 |
}
|
81 |
break;
|
@@ -104,4 +105,54 @@ class Web4pro_Stockstatus_Model_Observer
|
|
104 |
$quoteItem->setCustomStockstatus($product->getCustomStockstatus());
|
105 |
$quoteItem->setHideDefaultStockstatus($product->getHideDefaultStockstatus());
|
106 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
}
|
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;
|
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
ADDED
@@ -0,0 +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 |
+
}
|
app/code/community/Web4pro/Stockstatus/etc/config.xml
CHANGED
@@ -13,7 +13,7 @@
|
|
13 |
<config>
|
14 |
<modules>
|
15 |
<Web4pro_Stockstatus>
|
16 |
-
<version>1.0.
|
17 |
</Web4pro_Stockstatus>
|
18 |
</modules>
|
19 |
<global>
|
@@ -21,13 +21,38 @@
|
|
21 |
<web4pro_stockstatus>
|
22 |
<class>Web4pro_Stockstatus_Helper</class>
|
23 |
</web4pro_stockstatus>
|
|
|
|
|
|
|
|
|
|
|
24 |
</helpers>
|
25 |
<models>
|
26 |
<web4pro_stockstatus>
|
27 |
<class>Web4pro_Stockstatus_Model</class>
|
28 |
</web4pro_stockstatus>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
</models>
|
30 |
<blocks>
|
|
|
|
|
|
|
|
|
|
|
31 |
<web4pro_stockstatus>
|
32 |
<class>Web4pro_Stockstatus_Block</class>
|
33 |
</web4pro_stockstatus>
|
@@ -49,6 +74,7 @@
|
|
49 |
<web4pro_stockstatus_setup>
|
50 |
<setup>
|
51 |
<module>Web4pro_Stockstatus</module>
|
|
|
52 |
</setup>
|
53 |
<connection>
|
54 |
<use>core_setup</use>
|
@@ -86,6 +112,17 @@
|
|
86 |
</sales_quote_item_set_product>
|
87 |
</events>
|
88 |
</global>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
<frontend>
|
90 |
<routers>
|
91 |
<web4pro_stockstatus>
|
@@ -131,6 +168,16 @@
|
|
131 |
</web4pro_stockstatus>
|
132 |
</updates>
|
133 |
</layout>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
134 |
<translate>
|
135 |
<modules>
|
136 |
<Web4pro_Stockstatus>
|
13 |
<config>
|
14 |
<modules>
|
15 |
<Web4pro_Stockstatus>
|
16 |
+
<version>1.0.2</version>
|
17 |
</Web4pro_Stockstatus>
|
18 |
</modules>
|
19 |
<global>
|
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>
|
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>
|
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>
|
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>
|
app/code/community/Web4pro/Stockstatus/etc/system.xml
CHANGED
@@ -41,27 +41,27 @@
|
|
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>
|
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 |
-
<
|
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>
|
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 |
-
</
|
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>
|
65 |
<show_in_default>1</show_in_default>
|
66 |
<show_in_website>1</show_in_website>
|
67 |
<show_in_store>1</show_in_store>
|
@@ -70,12 +70,32 @@
|
|
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>
|
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?</comment>
|
78 |
</showstocklevel>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
</fields>
|
80 |
</general>
|
81 |
</groups>
|
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>
|
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?</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>
|
app/code/community/Web4pro/Stockstatus/sql/web4pro_stockstatus_setup/install-1.0.0.php
CHANGED
@@ -16,7 +16,7 @@
|
|
16 |
* @author WEB4PRO <srepin@corp.web4pro.com.ua>
|
17 |
*/
|
18 |
$this->startSetup();
|
19 |
-
$setup = new
|
20 |
|
21 |
$setup->addAttribute('catalog_product', 'custom_stockstatus', array(
|
22 |
'group' => 'Custom Stock Status',
|
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',
|
app/code/community/Web4pro/Stockstatus/sql/web4pro_stockstatus_setup/upgrade-1.0.0-1.0.2.php
ADDED
@@ -0,0 +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();
|
app/design/adminhtml/default/default/template/stockstatus/catalog/product/attribute/options.phtml
ADDED
@@ -0,0 +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>
|
package.xml
CHANGED
@@ -1,18 +1,20 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Web4pro_Stockstatus</name>
|
4 |
-
<version>1.0.
|
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
|
|
|
|
|
12 |
<authors><author><name>Sergey Repin</name><user>srepin</user><email>srepin@corp.web4pro.com.ua</email></author></authors>
|
13 |
-
<date>2015-04-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magecommunity"><dir name="Web4pro"><dir name="Stockstatus"><dir name="Block"><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="617ab7df4874c3e1c84bb7f7f4d40ab8"/></dir><dir name="Helper"><file name="Data.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.3.0</min><max>5.6.7</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Web4pro_Stockstatus</name>
|
4 |
+
<version>1.0.2</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
|
12 |
+
Version number: 1.0.2
|
13 |
+
- Ability to add custom image at stockstatus</notes>
|
14 |
<authors><author><name>Sergey Repin</name><user>srepin</user><email>srepin@corp.web4pro.com.ua</email></author></authors>
|
15 |
+
<date>2015-04-23</date>
|
16 |
+
<time>14:20:01</time>
|
17 |
+
<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="5b77963e42a4a0ada2c52dbd7cd75192"/></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="617ab7df4874c3e1c84bb7f7f4d40ab8"/></dir><dir name="Helper"><dir name="Cms"><dir name="Wysiwyg"><file name="Images.php" hash="dd697899de675ecc64422a24cd611e2e"/></dir></dir><file name="Data.php" hash="b1b82c341804cd1dd7a36be5d9e0ec51"/></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="361c2927d62aafa81dc5f11adb511e9e"/></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="3e8eb8f7201f32dc045a66effbf7a1fd"/><file name="system.xml" hash="20fb3cafa4fe2aa5f113af2fbe151a89"/></dir><dir name="sql"><dir name="web4pro_stockstatus_setup"><file name="install-1.0.0.php" hash="e3188e776007cf300b4d0b0961c17d7e"/><file name="upgrade-1.0.0-1.0.2.php" hash="edca71ac39d408c1a812cc82331ff495"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="web4pro_stockstatus.xml" hash="73954398b61e7bb2fd93a998b43b5a77"/></dir></dir></dir></dir><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></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="ef575ef3b7764b8e9d4ef163b248e9b5"/></dir></target><target name="mage"><dir name="js"><dir name="web4pro"><dir name="stockstatus"><file name="stockstatus.js" hash="45816dd271c1bf2fdb4ac9159062c645"/></dir></dir></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.3.0</min><max>5.6.7</max></php></required></dependencies>
|
20 |
</package>
|