Version Notes
tested and working with 1.7.0.2.
Community will be happy for reviews on other version tests.
Download this release
Release Info
Developer | Thomas Klosinsky |
Extension | Designcomplex_Hiddencomponents |
Version | 1.0.0 |
Comparing to | |
See all releases |
Version 1.0.0
- app/code/local/Designcomplex/HiddenComponents/Block/System/Config/Form/Apply.php +33 -0
- app/code/local/Designcomplex/HiddenComponents/Helper/Data.php +6 -0
- app/code/local/Designcomplex/HiddenComponents/Model/Components.php +48 -0
- app/code/local/Designcomplex/HiddenComponents/Model/Observer.php +10 -0
- app/code/local/Designcomplex/HiddenComponents/Model/System/Config/Source/ComponentVisibility.php +15 -0
- app/code/local/Designcomplex/HiddenComponents/controllers/Adminhtml/HiddencomponentsController.php +16 -0
- app/code/local/Designcomplex/HiddenComponents/etc/adminhtml.xml +3 -0
- app/code/local/Designcomplex/HiddenComponents/etc/config.xml +57 -0
- app/code/local/Designcomplex/HiddenComponents/etc/system.xml +56 -0
- app/etc/modules/Designcomplex_HiddenComponents.xml +12 -0
- app/locale/de_DE/Designcomplex_HiddenComponents.csv +6 -0
- package.xml +20 -0
app/code/local/Designcomplex/HiddenComponents/Block/System/Config/Form/Apply.php
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Designcomplex_HiddenComponents_Block_System_Config_Form_Apply
|
4 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Field
|
5 |
+
{
|
6 |
+
/**
|
7 |
+
* Set template to itself
|
8 |
+
*/
|
9 |
+
protected function _prepareLayout()
|
10 |
+
{
|
11 |
+
parent::_prepareLayout();
|
12 |
+
$this->setTemplate('hiddencomponents/system/config/apply.phtml');
|
13 |
+
return $this;
|
14 |
+
}
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Get the button and scripts contents
|
18 |
+
*
|
19 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
23 |
+
{
|
24 |
+
$originalData = $element->getOriginalData();
|
25 |
+
$this->addData(array(
|
26 |
+
'button_label' => Mage::helper('hiddencomponents')->__($originalData['button_label']),
|
27 |
+
'html_id' => $element->getHtmlId(),
|
28 |
+
'submit_url' => Mage::getSingleton('adminhtml/url')->getUrl('adminhtml/hiddencomponents/apply')
|
29 |
+
));
|
30 |
+
|
31 |
+
return $this->_toHtml();
|
32 |
+
}
|
33 |
+
}
|
app/code/local/Designcomplex/HiddenComponents/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Designcomplex_HiddenComponents_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/local/Designcomplex/HiddenComponents/Model/Components.php
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Designcomplex_HiddenComponents_Model_Components
|
4 |
+
{
|
5 |
+
const XML_PATH_COMPONENTS_VISIBILITY = 'catalog/components_visibility/%s';
|
6 |
+
|
7 |
+
protected $_comopsites = array('configurable', 'bundle', 'grouped');
|
8 |
+
|
9 |
+
|
10 |
+
public function hide(Mage_Catalog_Model_Product $product)
|
11 |
+
{
|
12 |
+
$typeId = $product->getTypeId();
|
13 |
+
if (in_array($typeId, $this->_comopsites)) {
|
14 |
+
$visibility = $this->_getVisibilitySetting($product);
|
15 |
+
if ($visibility) {
|
16 |
+
$children = $product->getTypeInstance(false)->getChildrenIds($product->getId(), false);
|
17 |
+
foreach ($children as $components) {
|
18 |
+
foreach ($components as $childId) {
|
19 |
+
Mage::getModel('catalog/product')->setStoreId($product->getStoreId())->load($childId)
|
20 |
+
->setVisibility($visibility)->save();
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
protected function _getVisibilitySetting(Mage_Catalog_Model_Product $product)
|
28 |
+
{
|
29 |
+
return Mage::getStoreConfig(sprintf(self::XML_PATH_COMPONENTS_VISIBILITY, $product->getTypeId()),
|
30 |
+
$product->getStoreId());
|
31 |
+
}
|
32 |
+
|
33 |
+
public function traverseCatalog()
|
34 |
+
{
|
35 |
+
foreach ($this->_comopsites as $productType) {
|
36 |
+
$visibility = Mage::getStoreConfig(sprintf(self::XML_PATH_COMPONENTS_VISIBILITY, $productType),
|
37 |
+
Mage::app()->getStore()->getId());
|
38 |
+
if ($visibility) {
|
39 |
+
/** @var Mage_Catalog_Model_Resource_Product_Collection $productCollection */
|
40 |
+
$productCollection = Mage::getModel('catalog/product')->getResourceCollection();
|
41 |
+
$productCollection->addAttributeToFilter('type_id', $productType);
|
42 |
+
foreach ($productCollection as $product) {
|
43 |
+
$this->hide($product);
|
44 |
+
}
|
45 |
+
}
|
46 |
+
}
|
47 |
+
}
|
48 |
+
}
|
app/code/local/Designcomplex/HiddenComponents/Model/Observer.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Designcomplex_HiddenComponents_Model_Observer
|
4 |
+
{
|
5 |
+
public function productSaveListener(Varien_Event_Observer $observer)
|
6 |
+
{
|
7 |
+
$product = $observer->getProduct();
|
8 |
+
Mage::getModel('hiddencomponents/components')->hide($product);
|
9 |
+
}
|
10 |
+
}
|
app/code/local/Designcomplex/HiddenComponents/Model/System/Config/Source/ComponentVisibility.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
|
4 |
+
class Designcomplex_HiddenComponents_Model_System_Config_Source_ComponentVisibility
|
5 |
+
{
|
6 |
+
public function toOptionArray()
|
7 |
+
{
|
8 |
+
$options = Mage::getModel('catalog/product_visibility')->getAllOptions();
|
9 |
+
if ($options[0]['value'] != '') {
|
10 |
+
throw new Exception('Unexpected default value of product visibility');
|
11 |
+
}
|
12 |
+
$options[0]['label'] = 'Leave As Is';
|
13 |
+
return $options;
|
14 |
+
}
|
15 |
+
}
|
app/code/local/Designcomplex/HiddenComponents/controllers/Adminhtml/HiddencomponentsController.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Designcomplex_HiddenComponents_Adminhtml_HiddencomponentsController extends Mage_Adminhtml_Controller_Action
|
4 |
+
{
|
5 |
+
public function applyAction()
|
6 |
+
{
|
7 |
+
try {
|
8 |
+
Mage::getModel('hiddencomponents/components')->traverseCatalog();
|
9 |
+
$this->_getSession()->addSuccess('Products\'s visibility has been changed.');
|
10 |
+
} catch (Exception $e) {
|
11 |
+
Mage::logException($e);
|
12 |
+
$this->_getSession()->addError($e->getMessage());
|
13 |
+
}
|
14 |
+
$this->_redirectUrl($this->getUrl('adminhtml/system_config/edit', array('section' => 'catalog')));
|
15 |
+
}
|
16 |
+
}
|
app/code/local/Designcomplex/HiddenComponents/etc/adminhtml.xml
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
</config>
|
app/code/local/Designcomplex/HiddenComponents/etc/config.xml
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Designcomplex_HiddenComponents>
|
5 |
+
<version>1.0</version>
|
6 |
+
</Designcomplex_HiddenComponents>
|
7 |
+
</modules>
|
8 |
+
<global>
|
9 |
+
<models>
|
10 |
+
<hiddencomponents>
|
11 |
+
<class>Designcomplex_HiddenComponents_Model</class>
|
12 |
+
</hiddencomponents>
|
13 |
+
</models>
|
14 |
+
<blocks>
|
15 |
+
<hiddencomponents>
|
16 |
+
<class>Designcomplex_HiddenComponents_Block</class>
|
17 |
+
</hiddencomponents>
|
18 |
+
</blocks>
|
19 |
+
<helpers>
|
20 |
+
<hiddencomponents>
|
21 |
+
<class>Designcomplex_HiddenComponents_Helper</class>
|
22 |
+
</hiddencomponents>
|
23 |
+
</helpers>
|
24 |
+
<events>
|
25 |
+
<catalog_product_save_after>
|
26 |
+
<observers>
|
27 |
+
<hiddencomponents>
|
28 |
+
<class>Designcomplex_HiddenComponents_Model_Observer</class>
|
29 |
+
<method>productSaveListener</method>
|
30 |
+
</hiddencomponents>
|
31 |
+
</observers>
|
32 |
+
</catalog_product_save_after>
|
33 |
+
</events>
|
34 |
+
</global>
|
35 |
+
<admin>
|
36 |
+
<routers>
|
37 |
+
<adminhtml>
|
38 |
+
<args>
|
39 |
+
<modules>
|
40 |
+
<Designcomplex_HiddenComponents before="Mage_Adminhtml">Designcomplex_HiddenComponents_Adminhtml</Designcomplex_HiddenComponents>
|
41 |
+
</modules>
|
42 |
+
</args>
|
43 |
+
</adminhtml>
|
44 |
+
</routers>
|
45 |
+
</admin>
|
46 |
+
<adminhtml>
|
47 |
+
<translate>
|
48 |
+
<modules>
|
49 |
+
<Designcomplex_HiddenComponents>
|
50 |
+
<files>
|
51 |
+
<default>Designcomplex_HiddenComponents.csv</default>
|
52 |
+
</files>
|
53 |
+
</Designcomplex_HiddenComponents>
|
54 |
+
</modules>
|
55 |
+
</translate>
|
56 |
+
</adminhtml>
|
57 |
+
</config>
|
app/code/local/Designcomplex/HiddenComponents/etc/system.xml
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<catalog>
|
5 |
+
<groups>
|
6 |
+
<components_visibility translate="label">
|
7 |
+
<label>Visibility of Complex Products</label>
|
8 |
+
<frontend_type>text</frontend_type>
|
9 |
+
<sort_order>1000</sort_order>
|
10 |
+
<show_in_default>1</show_in_default>
|
11 |
+
<show_in_website>0</show_in_website>
|
12 |
+
<show_in_store>0</show_in_store>
|
13 |
+
<fields>
|
14 |
+
<configurable translate="label">
|
15 |
+
<label>Configurables children</label>
|
16 |
+
<frontend_type>select</frontend_type>
|
17 |
+
<source_model>hiddencomponents/system_config_source_componentVisibility</source_model>
|
18 |
+
<sort_order>10</sort_order>
|
19 |
+
<show_in_default>1</show_in_default>
|
20 |
+
<show_in_website>0</show_in_website>
|
21 |
+
<show_in_store>0</show_in_store>
|
22 |
+
</configurable>
|
23 |
+
<bundle translate="label">
|
24 |
+
<label>Bundles children</label>
|
25 |
+
<frontend_type>select</frontend_type>
|
26 |
+
<source_model>hiddencomponents/system_config_source_componentVisibility</source_model>
|
27 |
+
<sort_order>20</sort_order>
|
28 |
+
<show_in_default>1</show_in_default>
|
29 |
+
<show_in_website>0</show_in_website>
|
30 |
+
<show_in_store>0</show_in_store>
|
31 |
+
</bundle>
|
32 |
+
<grouped translate="label">
|
33 |
+
<label>Groupeds children</label>
|
34 |
+
<frontend_type>select</frontend_type>
|
35 |
+
<source_model>hiddencomponents/system_config_source_componentVisibility</source_model>
|
36 |
+
<sort_order>30</sort_order>
|
37 |
+
<show_in_default>1</show_in_default>
|
38 |
+
<show_in_website>0</show_in_website>
|
39 |
+
<show_in_store>0</show_in_store>
|
40 |
+
</grouped>
|
41 |
+
<apply_button translate="comment">
|
42 |
+
<label></label>
|
43 |
+
<button_label>Apply</button_label>
|
44 |
+
<frontend_model>hiddencomponents/system_config_form_apply</frontend_model>
|
45 |
+
<sort_order>100</sort_order>
|
46 |
+
<show_in_default>1</show_in_default>
|
47 |
+
<show_in_website>0</show_in_website>
|
48 |
+
<show_in_store>0</show_in_store>
|
49 |
+
<comment>Don't forget to save the configuration if changed before hitting this button.</comment>
|
50 |
+
</apply_button>
|
51 |
+
</fields>
|
52 |
+
</components_visibility>
|
53 |
+
</groups>
|
54 |
+
</catalog>
|
55 |
+
</sections>
|
56 |
+
</config>
|
app/etc/modules/Designcomplex_HiddenComponents.xml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Designcomplex_HiddenComponents>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
<depends>
|
8 |
+
<Mage_Catalog />
|
9 |
+
</depends>
|
10 |
+
</Designcomplex_HiddenComponents>
|
11 |
+
</modules>
|
12 |
+
</config>
|
app/locale/de_DE/Designcomplex_HiddenComponents.csv
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"Visibility of Complex Products","Sichtbarkeit bei komplexen Produkten"
|
2 |
+
"Configurables children","Einfache Produkte in Konfigurierbaren Produkten"
|
3 |
+
"Bundles children","Einfache Produkte in Bundle Produkten"
|
4 |
+
"Groupeds children","Einfache Produkte in Gruppenprodukten"
|
5 |
+
"Don't forget to save the configuration if changed before hitting this button.","Vor dem Anwenden auf den gesamten Katalog bitte die Konfiguration speichern."
|
6 |
+
"Leave As Is","wie zuvor"
|
package.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Designcomplex_Hiddencomponents</name>
|
4 |
+
<version>1.0.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license>OSL</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>Automatically hide all sub-products of grouped, bundled or configurable product with this extension.</summary>
|
10 |
+
<description>Automatically hide all sub-products of grouped, bundled or configurable product with this extension.
|
11 |
+
The sub-products will be hidden from catalog (visibility) when saving the main product (grouped, bundle, configurable).</description>
|
12 |
+
<notes>tested and working with 1.7.0.2.
|
13 |
+
Community will be happy for reviews on other version tests.</notes>
|
14 |
+
<authors><author><name>Thomas Klosinsky</name><user>thomasklosinsky</user><email>thomas@designcomplex.de</email></author></authors>
|
15 |
+
<date>2014-09-22</date>
|
16 |
+
<time>20:32:09</time>
|
17 |
+
<contents><target name="magelocal"><dir name="Designcomplex"><dir name="HiddenComponents"><dir name="Block"><dir name="System"><dir name="Config"><dir name="Form"><file name="Apply.php" hash="1b8fbe869b288ba56feba046ad97057c"/></dir></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="5123c641ad07b784b052e5bcc399dd10"/></dir><dir name="Model"><file name="Components.php" hash="8c65196b1dc8e76aa583aeb7d119374c"/><file name="Observer.php" hash="d0af3b019a64c331e7858fff7b7298c7"/><dir name="System"><dir name="Config"><dir name="Source"><file name="ComponentVisibility.php" hash="bab4b500fde42e0414e56369b0a98649"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="HiddencomponentsController.php" hash="dd0ec1d4985405ecb9c540630e80e7aa"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="e04929738101399bf8310fdbeebb7698"/><file name="config.xml" hash="615729b70d0c313c981cafed3ea1c794"/><file name="system.xml" hash="b347ceeb04b0e78130bcffef127a69e3"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Designcomplex_HiddenComponents.xml" hash="e6348eccb98b48558605d568523ebddc"/></dir></target><target name="magelocale"><dir><dir name="de_DE"><file name="Designcomplex_HiddenComponents.csv" hash="2bd98a02486e943214c464d91091c740"/></dir></dir></target></contents>
|
18 |
+
<compatible/>
|
19 |
+
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
20 |
+
</package>
|