Public Member Functions | |
getAttributeSetsSelectElement ($targetCountry) | |
getItemTypesSelectElement ($targetCountry) | |
getItemType () | |
getSaveUrl () | |
Protected Member Functions | |
_prepareForm () | |
_getCountriesArray () | |
_getAttributeSetsArray ($targetCountry) | |
_getGbaseItemTypesArray ($targetCountry) |
Definition at line 35 of file Form.php.
_getAttributeSetsArray | ( | $ | targetCountry | ) | [protected] |
Definition at line 146 of file Form.php.
00147 { 00148 $entityType = Mage::getModel('catalog/product')->getResource()->getEntityType(); 00149 $collection = Mage::getResourceModel('eav/entity_attribute_set_collection') 00150 ->setEntityTypeFilter($entityType->getId()); 00151 00152 $ids = array(); 00153 $itemType = $this->getItemType(); 00154 if ( !($itemType instanceof Varien_Object && $itemType->getId()) ) { 00155 $typesCollection = Mage::getResourceModel('googlebase/type_collection') 00156 ->addCountryFilter($targetCountry) 00157 ->load(); 00158 foreach ($typesCollection as $type) { 00159 $ids[] = $type->getAttributeSetId(); 00160 } 00161 } 00162 00163 $result = array('' => ''); 00164 foreach ($collection as $attributeSet) { 00165 if (!in_array($attributeSet->getId(), $ids)) { 00166 $result[$attributeSet->getId()] = $attributeSet->getAttributeSetName(); 00167 } 00168 } 00169 return $result; 00170 }
_getCountriesArray | ( | ) | [protected] |
_getGbaseItemTypesArray | ( | $ | targetCountry | ) | [protected] |
_prepareForm | ( | ) | [protected] |
Prepare form before rendering HTML
Reimplemented from Mage_Adminhtml_Block_Widget_Form.
Definition at line 37 of file Form.php.
00038 { 00039 $form = new Varien_Data_Form(); 00040 00041 $itemType = $this->getItemType(); 00042 00043 $fieldset = $form->addFieldset('base_fieldset', array( 00044 'legend' => $this->__('Attribute Set and Item Type') 00045 )); 00046 00047 if ( !($targetCountry = $itemType->getTargetCountry()) ) { 00048 $isoKeys = array_keys($this->_getCountriesArray()); 00049 $targetCountry = isset($isoKeys[0]) ? $isoKeys[0] : null; 00050 } 00051 $countrySelect = $fieldset->addField('select_target_country', 'select', array( 00052 'label' => $this->__('Target Country'), 00053 'title' => $this->__('Target Country'), 00054 'name' => 'target_country', 00055 'required' => true, 00056 'options' => $this->_getCountriesArray(), 00057 'value' => $targetCountry, 00058 )); 00059 if ($itemType->getTargetCountry()) { 00060 $countrySelect->setDisabled(true); 00061 } 00062 00063 $attributeSetsSelect = $this->getAttributeSetsSelectElement($targetCountry)->setValue($itemType->getAttributeSetId()); 00064 if ($itemType->getAttributeSetId()) { 00065 $attributeSetsSelect->setDisabled(true); 00066 } 00067 00068 $fieldset->addField('attribute_set', 'note', array( 00069 'label' => $this->__('Attribute Set'), 00070 'title' => $this->__('Attribute Set'), 00071 'required' => true, 00072 'text' => '<div id="attribute_set_select">' . $attributeSetsSelect->toHtml() . '</div>', 00073 )); 00074 00075 $itemTypesSelect = $this->getItemTypesSelectElement($targetCountry)->setValue($itemType->getGbaseItemtype()); 00076 if ($itemType->getGbaseItemtype()) { 00077 $itemTypesSelect->setDisabled(true); 00078 } 00079 00080 $fieldset->addField('itemtype', 'note', array( 00081 'label' => $this->__('Google Base Item Type'), 00082 'title' => $this->__('Google Base Item Type'), 00083 'required' => true, 00084 'text' => '<div id="gbase_itemtype_select">' . $itemTypesSelect->toHtml() . '</div>', 00085 )); 00086 00087 $attributesBlock = $this->getLayout() 00088 ->createBlock('googlebase/adminhtml_types_edit_attributes') 00089 ->setTargetCountry($targetCountry); 00090 if ($itemType->getId()) { 00091 $attributesBlock->setAttributeSetId($itemType->getAttributeSetId()) 00092 ->setGbaseItemtype($itemType->getGbaseItemtype()) 00093 ->setAttributeSetSelected(true); 00094 } 00095 00096 $attributes = Mage::registry('attributes'); 00097 if (is_array($attributes) && count($attributes) > 0) { 00098 $attributesBlock->setAttributesData($attributes); 00099 } 00100 00101 $fieldset->addField('attributes_box', 'note', array( 00102 'label' => $this->__('Attributes mapping'), 00103 'text' => '<div id="attributes_details">' . $attributesBlock->toHtml() . '</div>', 00104 )); 00105 00106 $form->addValues($itemType->getData()); 00107 $form->setUseContainer(true); 00108 $form->setId('edit_form'); 00109 $form->setMethod('post'); 00110 $form->setAction($this->getSaveUrl()); 00111 $this->setForm($form); 00112 }
getAttributeSetsSelectElement | ( | $ | targetCountry | ) |
Definition at line 114 of file Form.php.
00115 { 00116 $field = new Varien_Data_Form_Element_Select(); 00117 $field->setName('attribute_set_id') 00118 ->setId('select_attribute_set') 00119 ->setForm(new Varien_Data_Form()) 00120 ->addClass('required-entry') 00121 ->setValues($this->_getAttributeSetsArray($targetCountry)); 00122 return $field; 00123 }
getItemType | ( | ) |
Definition at line 182 of file Form.php.
00183 { 00184 return Mage::registry('current_item_type'); 00185 }
getItemTypesSelectElement | ( | $ | targetCountry | ) |
Definition at line 125 of file Form.php.
00126 { 00127 $field = new Varien_Data_Form_Element_Select(); 00128 $field->setName('gbase_itemtype') 00129 ->setId('select_itemtype') 00130 ->setForm(new Varien_Data_Form()) 00131 ->addClass('required-entry') 00132 ->setValues($this->_getGbaseItemTypesArray($targetCountry)); 00133 return $field; 00134 }
getSaveUrl | ( | ) |