Version Notes
Ignore file attribute in mass edit screens
Download this release
Release Info
Developer | Javier Villanueva |
Extension | fileuploadattribute |
Version | 1.1.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 1.1.0
- app/code/community/Jvs/FileAttribute/Model/Observer.php +24 -0
- app/code/community/Jvs/FileAttribute/etc/config.xml +8 -0
- app/code/community/Jvs/MinTotalQty/Helper/Data.php +0 -71
- app/code/community/Jvs/MinTotalQty/Model/Observer.php +0 -45
- app/code/community/Jvs/MinTotalQty/etc/config.xml +0 -32
- app/code/community/Jvs/MinTotalQty/etc/system.xml +0 -22
- package.xml +5 -5
app/code/community/Jvs/FileAttribute/Model/Observer.php
CHANGED
@@ -16,6 +16,7 @@ class Jvs_FileAttribute_Model_Observer
|
|
16 |
public function addFileAttributeType(Varien_Event_Observer $observer)
|
17 |
{
|
18 |
$response = $observer->getEvent()->getResponse();
|
|
|
19 |
$types = $response->getTypes();
|
20 |
$types[] = array(
|
21 |
'value' => 'jvs_file',
|
@@ -53,6 +54,7 @@ class Jvs_FileAttribute_Model_Observer
|
|
53 |
public function assignBackendModelToAttribute(Varien_Event_Observer $observer)
|
54 |
{
|
55 |
$backendModel = 'jvs_fileattribute/attribute_backend_file';
|
|
|
56 |
/** @var $object Mage_Eav_Model_Entity_Attribute_Abstract */
|
57 |
$object = $observer->getEvent()->getAttribute();
|
58 |
|
@@ -64,6 +66,25 @@ class Jvs_FileAttribute_Model_Observer
|
|
64 |
return $this;
|
65 |
}
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
/**
|
68 |
* Assign frontend model to file upload input type
|
69 |
*
|
@@ -73,9 +94,12 @@ class Jvs_FileAttribute_Model_Observer
|
|
73 |
public function updateElementTypes(Varien_Event_Observer $observer)
|
74 |
{
|
75 |
$response = $observer->getEvent()->getResponse();
|
|
|
76 |
$types = $response->getTypes();
|
77 |
$types['jvs_file'] = Mage::getConfig()->getBlockClassName('jvs_fileattribute/element_file');
|
|
|
78 |
$response->setTypes($types);
|
|
|
79 |
return $this;
|
80 |
}
|
81 |
}
|
16 |
public function addFileAttributeType(Varien_Event_Observer $observer)
|
17 |
{
|
18 |
$response = $observer->getEvent()->getResponse();
|
19 |
+
|
20 |
$types = $response->getTypes();
|
21 |
$types[] = array(
|
22 |
'value' => 'jvs_file',
|
54 |
public function assignBackendModelToAttribute(Varien_Event_Observer $observer)
|
55 |
{
|
56 |
$backendModel = 'jvs_fileattribute/attribute_backend_file';
|
57 |
+
|
58 |
/** @var $object Mage_Eav_Model_Entity_Attribute_Abstract */
|
59 |
$object = $observer->getEvent()->getAttribute();
|
60 |
|
66 |
return $this;
|
67 |
}
|
68 |
|
69 |
+
/**
|
70 |
+
* Exclude 'jvs_file' attributes from standard form generation
|
71 |
+
*
|
72 |
+
* @param Varien_Event_Observer $observer
|
73 |
+
* @return Jvs_FileAttribute_Model_Observer
|
74 |
+
*/
|
75 |
+
public function updateExcludedFieldList(Varien_Event_Observer $observer)
|
76 |
+
{
|
77 |
+
$block = $observer->getEvent()->getObject();
|
78 |
+
$list = $block->getFormExcludedFieldList();
|
79 |
+
|
80 |
+
$attributes = Mage::getModel('eav/entity_attribute')->getAttributeCodesByFrontendType('jvs_file');
|
81 |
+
$list = array_merge($list, array_values($attributes));
|
82 |
+
|
83 |
+
$block->setFormExcludedFieldList($list);
|
84 |
+
|
85 |
+
return $this;
|
86 |
+
}
|
87 |
+
|
88 |
/**
|
89 |
* Assign frontend model to file upload input type
|
90 |
*
|
94 |
public function updateElementTypes(Varien_Event_Observer $observer)
|
95 |
{
|
96 |
$response = $observer->getEvent()->getResponse();
|
97 |
+
|
98 |
$types = $response->getTypes();
|
99 |
$types['jvs_file'] = Mage::getConfig()->getBlockClassName('jvs_fileattribute/element_file');
|
100 |
+
|
101 |
$response->setTypes($types);
|
102 |
+
|
103 |
return $this;
|
104 |
}
|
105 |
}
|
app/code/community/Jvs/FileAttribute/etc/config.xml
CHANGED
@@ -57,6 +57,14 @@
|
|
57 |
</jvs_fileattribute>
|
58 |
</observers>
|
59 |
</adminhtml_catalog_product_edit_element_types>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
</events>
|
61 |
</adminhtml>
|
62 |
<default>
|
57 |
</jvs_fileattribute>
|
58 |
</observers>
|
59 |
</adminhtml_catalog_product_edit_element_types>
|
60 |
+
<adminhtml_catalog_product_form_prepare_excluded_field_list>
|
61 |
+
<observers>
|
62 |
+
<jvs_fileattribute>
|
63 |
+
<class>jvs_fileattribute/observer</class>
|
64 |
+
<method>updateExcludedFieldList</method>
|
65 |
+
</jvs_fileattribute>
|
66 |
+
</observers>
|
67 |
+
</adminhtml_catalog_product_form_prepare_excluded_field_list>
|
68 |
</events>
|
69 |
</adminhtml>
|
70 |
<default>
|
app/code/community/Jvs/MinTotalQty/Helper/Data.php
DELETED
@@ -1,71 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* MinTotalQty data helper
|
4 |
-
*
|
5 |
-
* @category Jvs
|
6 |
-
* @package Jvs_MinTotalQty
|
7 |
-
* @author Javier Villanueva <javiervd@gmail.com>
|
8 |
-
*/
|
9 |
-
class Jvs_MinTotalQty_Helper_Data extends Mage_CatalogInventory_Helper_Minsaleqty
|
10 |
-
{
|
11 |
-
const XML_PATH_MIN_TOTAL_QTY = 'cataloginventory/options/min_total_qty';
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Retrieve min_total_qty value from config
|
15 |
-
*
|
16 |
-
* @param int $customerGroupId
|
17 |
-
* @param mixed $store
|
18 |
-
* @return float|null
|
19 |
-
*/
|
20 |
-
public function getConfigValue($customerGroupId, $store = null)
|
21 |
-
{
|
22 |
-
$value = Mage::getStoreConfig(self::XML_PATH_MIN_TOTAL_QTY, $store);
|
23 |
-
$value = $this->_unserializeValue($value);
|
24 |
-
if ($this->_isEncodedArrayFieldValue($value)) {
|
25 |
-
$value = $this->_decodeArrayFieldValue($value);
|
26 |
-
}
|
27 |
-
$result = null;
|
28 |
-
foreach ($value as $groupId => $qty) {
|
29 |
-
if ($groupId == $customerGroupId) {
|
30 |
-
$result = $qty;
|
31 |
-
break;
|
32 |
-
} else if ($groupId == Mage_Customer_Model_Group::CUST_GROUP_ALL) {
|
33 |
-
$result = $qty;
|
34 |
-
}
|
35 |
-
}
|
36 |
-
return $this->_fixQty($result);
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Check if quote meets the minimun quantity
|
41 |
-
* of total items for a specific customer
|
42 |
-
*
|
43 |
-
* @todo Change to more meaningful name
|
44 |
-
*
|
45 |
-
* @param Mage_Sales_Model_Quote $quote
|
46 |
-
* @param Mage_Customer_Model_Customer $customer
|
47 |
-
* @return int|false
|
48 |
-
*/
|
49 |
-
public function minimunOrderQty(Mage_Sales_Model_Quote $quote, Mage_Customer_Model_Customer $customer)
|
50 |
-
{
|
51 |
-
$minQtyForCustomer = $this->getConfigValue($customer->getGroupId());
|
52 |
-
|
53 |
-
if ($quote->getItemsQty() < $minQtyForCustomer && $quote->getItemsQty() !== 0) {
|
54 |
-
return $minQtyForCustomer;
|
55 |
-
}
|
56 |
-
|
57 |
-
return false;
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* Check if current page is shopping cart
|
62 |
-
*
|
63 |
-
* @return boolean
|
64 |
-
*/
|
65 |
-
public function isCartPage()
|
66 |
-
{
|
67 |
-
$frontController = Mage::app()->getFrontController();
|
68 |
-
|
69 |
-
return ($frontController->getAction()->getFullActionName() === 'checkout_cart_index');
|
70 |
-
}
|
71 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Jvs/MinTotalQty/Model/Observer.php
DELETED
@@ -1,45 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* MinTotalQty observer model
|
4 |
-
*
|
5 |
-
* @category Jvs
|
6 |
-
* @package Jvs_MinTotalQty
|
7 |
-
* @author Javier Villanueva <javiervd@gmail.com>
|
8 |
-
*/
|
9 |
-
class Jvs_MinTotalQty_Model_Observer
|
10 |
-
{
|
11 |
-
/**
|
12 |
-
* Check minimun order totals
|
13 |
-
*
|
14 |
-
* @param Varien_Event_Observer $observer
|
15 |
-
* @return void
|
16 |
-
*/
|
17 |
-
public function checkTotalQtyBeforeCheckout(Varien_Event_Observer $observer)
|
18 |
-
{
|
19 |
-
$quote = $observer->getDataObject();
|
20 |
-
$customer = Mage::helper('customer')->getCustomer();
|
21 |
-
|
22 |
-
// If the minimun total quantity is not met
|
23 |
-
// redirect to cart page with error message
|
24 |
-
if ($minQty = Mage::helper('jvs_mintotalqty')->minimunOrderQty($quote, $customer)) {
|
25 |
-
Mage::getSingleton('checkout/session')->addUniqueMessages(
|
26 |
-
Mage::getSingleton('core/message')
|
27 |
-
->error(
|
28 |
-
Mage::helper('cataloginventory')
|
29 |
-
->__(
|
30 |
-
'The minimum quantity allowed for purchase is %s.',
|
31 |
-
$minQty
|
32 |
-
)
|
33 |
-
)
|
34 |
-
);
|
35 |
-
|
36 |
-
// Check if we are not already on the cart page
|
37 |
-
if (!Mage::helper('jvs_mintotalqty')->isCartPage()) {
|
38 |
-
Mage::app()->getFrontController()->getResponse()
|
39 |
-
->setRedirect(Mage::getUrl('checkout/cart'));
|
40 |
-
|
41 |
-
Mage::app()->getRequest()->setDispatched(true);
|
42 |
-
}
|
43 |
-
}
|
44 |
-
}
|
45 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Jvs/MinTotalQty/etc/config.xml
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<modules>
|
4 |
-
<Jvs_MinTotalQty>
|
5 |
-
<version>1.0.0</version>
|
6 |
-
</Jvs_MinTotalQty>
|
7 |
-
</modules>
|
8 |
-
<global>
|
9 |
-
<models>
|
10 |
-
<jvs_mintotalqty>
|
11 |
-
<class>Jvs_MinTotalQty_Model</class>
|
12 |
-
</jvs_mintotalqty>
|
13 |
-
</models>
|
14 |
-
<helpers>
|
15 |
-
<jvs_mintotalqty>
|
16 |
-
<class>Jvs_MinTotalQty_Helper</class>
|
17 |
-
</jvs_mintotalqty>
|
18 |
-
</helpers>
|
19 |
-
</global>
|
20 |
-
<frontend>
|
21 |
-
<events>
|
22 |
-
<sales_quote_save_after>
|
23 |
-
<observers>
|
24 |
-
<jvs_mintotalqty_checkqty>
|
25 |
-
<class>jvs_mintotalqty/observer</class>
|
26 |
-
<method>checkTotalQtyBeforeCheckout</method>
|
27 |
-
</jvs_mintotalqty_checkqty>
|
28 |
-
</observers>
|
29 |
-
</sales_quote_save_after>
|
30 |
-
</events>
|
31 |
-
</frontend>
|
32 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Jvs/MinTotalQty/etc/system.xml
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<sections>
|
4 |
-
<cataloginventory>
|
5 |
-
<groups>
|
6 |
-
<options>
|
7 |
-
<fields>
|
8 |
-
<min_total_qty translate="label">
|
9 |
-
<label>Minimum Qty Allowed in Shopping Cart</label>
|
10 |
-
<frontend_model>cataloginventory/adminhtml_form_field_minsaleqty</frontend_model>
|
11 |
-
<backend_model>cataloginventory/system_config_backend_minsaleqty</backend_model>
|
12 |
-
<sort_order>60</sort_order>
|
13 |
-
<show_in_default>1</show_in_default>
|
14 |
-
<show_in_website>0</show_in_website>
|
15 |
-
<show_in_store>0</show_in_store>
|
16 |
-
</min_total_qty>
|
17 |
-
</fields>
|
18 |
-
</options>
|
19 |
-
</groups>
|
20 |
-
</cataloginventory>
|
21 |
-
</sections>
|
22 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>fileuploadattribute</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="https://opensource.org/licenses/MIT">MIT</license>
|
7 |
<channel>community</channel>
|
@@ -10,11 +10,11 @@
|
|
10 |
<description>This extension allows you to create file upload attributes for your products by adding a new input type to the attribute creation form.
|
11 |

|
12 |
You will be able to assign multiple file upload attributes to your products, restrict allowed file extensions and choose to display them automatically on your product pages or display it by yourself however you want to.</description>
|
13 |
-
<notes>
|
14 |
<authors><author><name>Javier Villanueva</name><user>javiervd</user><email>javiervd@gmail.com</email></author></authors>
|
15 |
-
<date>2015-11-
|
16 |
-
<time>
|
17 |
-
<contents><target name="magecommunity"><dir name="Jvs"><dir name="FileAttribute"><dir name="Block"><dir name="Element"><file name="File.php" hash="3cc11497c90e17d239a56474e13d0b08"/></dir><dir name="Product"><dir name="View"><file name="Attributes.php" hash="23804c6ac14597db3147ce47c2b58131"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="fad835c3b52c614614eedd1bdeab633f"/></dir><dir name="Model"><dir name="Attribute"><dir name="Backend"><file name="File.php" hash="b91adc1758e024f248938844103f51da"/></dir></dir><file name="Observer.php" hash="
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.3.0</min><max>5.6.14</max></php></required></dependencies>
|
20 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>fileuploadattribute</name>
|
4 |
+
<version>1.1.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="https://opensource.org/licenses/MIT">MIT</license>
|
7 |
<channel>community</channel>
|
10 |
<description>This extension allows you to create file upload attributes for your products by adding a new input type to the attribute creation form.
|
11 |

|
12 |
You will be able to assign multiple file upload attributes to your products, restrict allowed file extensions and choose to display them automatically on your product pages or display it by yourself however you want to.</description>
|
13 |
+
<notes>Ignore file attribute in mass edit screens</notes>
|
14 |
<authors><author><name>Javier Villanueva</name><user>javiervd</user><email>javiervd@gmail.com</email></author></authors>
|
15 |
+
<date>2015-11-21</date>
|
16 |
+
<time>14:55:27</time>
|
17 |
+
<contents><target name="magecommunity"><dir name="Jvs"><dir name="FileAttribute"><dir name="Block"><dir name="Element"><file name="File.php" hash="3cc11497c90e17d239a56474e13d0b08"/></dir><dir name="Product"><dir name="View"><file name="Attributes.php" hash="23804c6ac14597db3147ce47c2b58131"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="fad835c3b52c614614eedd1bdeab633f"/></dir><dir name="Model"><dir name="Attribute"><dir name="Backend"><file name="File.php" hash="b91adc1758e024f248938844103f51da"/></dir></dir><file name="Observer.php" hash="04c446dacc6c760454d6d33acd607ba1"/></dir><dir name="etc"><file name="config.xml" hash="5c5593331b1be697c818eaebf758857b"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Jvs_FileAttribute.xml" hash="23788d82b953b31264288716e8536ba9"/></dir></target></contents>
|
18 |
<compatible/>
|
19 |
<dependencies><required><php><min>5.3.0</min><max>5.6.14</max></php></required></dependencies>
|
20 |
</package>
|