function _prepareLayout() { if (Mage::getModel('colorswatch/swatch_images')->getCollection()->getSize() == 0) { Mage::getSingleton('adminhtml/session')->addNotice("Please save the ColorSwatch Attribute Settings to enable color swatches on your products"); } $this->setHeaderText(Mage::helper('colorswatch')->__('SMDesign ColorSwatch Attribute Settings')); $this->attributePerPage = (int) Mage::app()->getStore()->getConfig('smdesign_colorswatch/general/adminhtml_attribute_per_page'); $this->attributePerPage = $this->attributePerPage > 0 ? $this->attributePerPage : 20; $this->currentPage = max($this->getRequest()->getParam('page_id', 1), 1); $this->searchTream = strtolower($this->getRequest()->getParam('search', '')); $block = $this->getLayout()->createBlock('adminhtml/widget_accordion', 'colorswatch_attribute_accordion'); $resetToFirstPage = true; $isDead = false; while ($resetToFirstPage) { foreach (Mage::getResourceModel('catalog/product_attribute_collection')->setFrontendInputTypeFilter('select') as $model) { if ($model->getIsConfigurable() && $model->getIsUserDefined() && ($this->searchTream == '' || $this->searchTream != '' && (preg_match("@{$this->searchTream}@", strtolower($model->getFrontendLabel())) || preg_match("@{$this->searchTream}@", strtolower($model->getAttributeCode()))))) { if ($this->attributePerPage * $this->currentPage - $this->attributePerPage <= $this->attributeCounter && $this->attributeCounter < $this->attributePerPage * $this->currentPage) { $block->addItem($model->getAttributeCode(), array('title' => $model->getData('frontend_label') . " ({$model->getAttributeCode()})", 'content' => $this->getLayout()->createBlock('colorswatch/adminhtml_attribute_accordion_content', 'colorswatch_attribute_accordion')->setModel($model)->toHtml(), 'open' => false)); } $this->attributeCounter++; } } if ($isDead || $this->attributePerPage * $this->currentPage <= $this->attributeCounter || $this->attributeCounter == 0 || $this->currentPage == 1) { $resetToFirstPage = false; } else { $this->attributeCounter = 0; $this->currentPage = 1; $isDead = true; } } $this->setChild('colorswatch_attribute_accordion', $block); $this->addButton('save', array('label' => 'save', 'onclick' => "\ncolorswatchForm = \$('colorswatch-attribute-form');\nfor (k in colorswatchForm) {\n if (colorswatchForm[k]) {\n var currentNodeName = colorswatchForm[k].nodeName;\n if (currentNodeName && currentNodeName.toLowerCase() == 'input') {\n if (colorswatchForm[k].type.toLowerCase() == 'file') {\n if (colorswatchForm[k].value == '') {\n \n\t\t for (childIndex=0; childIndex < colorswatchForm[k].parentNode.childNodes.length; childIndex++) {\n\t\t \tif (colorswatchForm[k].parentNode.childNodes[childIndex].className == 'fakefile' ) {\n \t\t\tcolorswatchForm[k].parentNode.style.position = 'relative';\n \t\t\tcolorswatchForm[k].parentNode.childNodes[childIndex].style.position = 'static';\n\t\t \t}\n\t\t }\n\t\t colorswatchForm[k].parentNode.removeChild(colorswatchForm[k]);\n }\n }\n }\n }\n}\n\$('colorswatch-attribute-form').submit();\n\t\t\t ", 'class' => 'save')); return parent::_prepareLayout(); }
protected function _construct() { parent::_construct(); }