當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Varien_Data_Form::getDataObject方法代碼示例

本文整理匯總了PHP中Varien_Data_Form::getDataObject方法的典型用法代碼示例。如果您正苦於以下問題:PHP Varien_Data_Form::getDataObject方法的具體用法?PHP Varien_Data_Form::getDataObject怎麽用?PHP Varien_Data_Form::getDataObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Varien_Data_Form的用法示例。


在下文中一共展示了Varien_Data_Form::getDataObject方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _prepareForm

 /**
  * Prepare attributes form
  *
  * @return null
  */
 protected function _prepareForm()
 {
     $group = $this->getGroup();
     if ($group) {
         $form = new Varien_Data_Form();
         // Initialize product object as form property to use it during elements generation
         $form->setDataObject(Mage::registry('product'));
         $fieldset = $form->addFieldset('group_fields' . $group->getId(), array('legend' => Mage::helper('catalog')->__($group->getAttributeGroupName()), 'class' => 'fieldset-wide'));
         $attributes = $this->getGroupAttributes();
         $this->_setFieldset($attributes, $fieldset, array('gallery'));
         $urlKey = $form->getElement('url_key');
         if ($urlKey) {
             $urlKey->setRenderer($this->getLayout()->createBlock('adminhtml/catalog_form_renderer_attribute_urlkey'));
         }
         $tierPrice = $form->getElement('tier_price');
         if ($tierPrice) {
             $tierPrice->setRenderer($this->getLayout()->createBlock('marketplace/adminhtml_catalog_product_edit_tab_price_tier'));
         }
         $groupPrice = $form->getElement('group_price');
         if ($groupPrice) {
             $groupPrice->setRenderer($this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_price_group'));
         }
         // $recurringProfile = $form->getElement('recurring_profile');
         // if ($recurringProfile) {
         //     $recurringProfile->setRenderer(
         //         $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_price_recurring')
         //     );
         // }
         // Add new attribute button if it is not an image tab
         if (!$form->getElement('media_gallery') && Mage::getSingleton('admin/session')->isAllowed('catalog/attributes/attributes')) {
             $headerBar = $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_attributes_create');
             $headerBar->getConfig()->setTabId('group_' . $group->getId())->setGroupId($group->getId())->setStoreId($form->getDataObject()->getStoreId())->setAttributeSetId($form->getDataObject()->getAttributeSetId())->setTypeId($form->getDataObject()->getTypeId())->setProductId($form->getDataObject()->getId());
             $fieldset->setHeaderBar($headerBar->toHtml());
         }
         if ($form->getElement('meta_description')) {
             $form->getElement('meta_description')->setOnkeyup('checkMaxLength(this, 255);');
         }
         $values = Mage::registry('product')->getData();
         // Set default attribute values for new product
         if (!Mage::registry('product')->getId()) {
             foreach ($attributes as $attribute) {
                 if (!isset($values[$attribute->getAttributeCode()])) {
                     $values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();
                 }
             }
         }
         if (Mage::registry('product')->hasLockedAttributes()) {
             foreach (Mage::registry('product')->getLockedAttributes() as $attribute) {
                 $element = $form->getElement($attribute);
                 if ($element) {
                     $element->setReadonly(true, true);
                 }
             }
         }
         $form->addValues($values);
         $form->setFieldNameSuffix('product');
         Mage::dispatchEvent('adminhtml_catalog_product_edit_prepare_form', array('form' => $form));
         $this->setForm($form);
     }
 }
開發者ID:andrebellafronte,項目名稱:MM_Marketplace,代碼行數:65,代碼來源:Attributes.php

示例2: _prepareForm

 protected function _prepareForm()
 {
     if ($group = $this->getGroup()) {
         $form = new Varien_Data_Form();
         /**
          * Initialize product object as form property
          * for using it in elements generation
          */
         $form->setDataObject(Mage::registry('product'));
         $fieldset = $form->addFieldset('group_fields' . $group->getId(), array('legend' => Mage::helper('Mage_Catalog_Helper_Data')->__($group->getAttributeGroupName()), 'class' => 'fieldset-wide'));
         $attributes = $this->getGroupAttributes();
         $this->_setFieldset($attributes, $fieldset, array('gallery'));
         if ($urlKey = $form->getElement('url_key')) {
             $urlKey->setRenderer($this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Form_Renderer_Attribute_Urlkey'));
         }
         if ($tierPrice = $form->getElement('tier_price')) {
             $tierPrice->setRenderer($this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Tier'));
         }
         if ($recurringProfile = $form->getElement('recurring_profile')) {
             $recurringProfile->setRenderer($this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Price_Recurring'));
         }
         /**
          * Add new attribute button if not image tab
          */
         if (!$form->getElement('media_gallery') && Mage::getSingleton('Mage_Admin_Model_Session')->isAllowed('catalog/attributes/attributes')) {
             $headerBar = $this->getLayout()->createBlock('Mage_Adminhtml_Block_Catalog_Product_Edit_Tab_Attributes_Create');
             $headerBar->getConfig()->setTabId('group_' . $group->getId())->setGroupId($group->getId())->setStoreId($form->getDataObject()->getStoreId())->setAttributeSetId($form->getDataObject()->getAttributeSetId())->setTypeId($form->getDataObject()->getTypeId())->setProductId($form->getDataObject()->getId());
             $fieldset->setHeaderBar($headerBar->toHtml());
         }
         if ($form->getElement('meta_description')) {
             $form->getElement('meta_description')->setOnkeyup('checkMaxLength(this, 255);');
         }
         $values = Mage::registry('product')->getData();
         /**
          * Set attribute default values for new product
          */
         if (!Mage::registry('product')->getId()) {
             foreach ($attributes as $attribute) {
                 if (!isset($values[$attribute->getAttributeCode()])) {
                     $values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();
                 }
             }
         }
         if (Mage::registry('product')->hasLockedAttributes()) {
             foreach (Mage::registry('product')->getLockedAttributes() as $attribute) {
                 if ($element = $form->getElement($attribute)) {
                     $element->setReadonly(true, true);
                 }
             }
         }
         $form->addValues($values);
         $form->setFieldNameSuffix('product');
         Mage::dispatchEvent('adminhtml_catalog_product_edit_prepare_form', array('form' => $form));
         $this->setForm($form);
     }
 }
開發者ID:relue,項目名稱:magento2,代碼行數:56,代碼來源:Attributes.php

示例3: _prepareForm

 protected function _prepareForm()
 {
     if ($group = $this->getGroup()) {
         $form = new Varien_Data_Form();
         /**
          * Initialize product object as form property
          * for using it in elements generation
          */
         $form->setDataObject(Mage::registry('product'));
         $fieldset = $form->addFieldset('group_fields' . $group->getId(), array('legend' => Mage::helper('catalog')->__($group->getAttributeGroupName())));
         $attributes = $this->getGroupAttributes();
         $this->_setFieldset($attributes, $fieldset, array('gallery'));
         if ($tierPrice = $form->getElement('tier_price')) {
             $tierPrice->setRenderer($this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_price_tier'));
         }
         /**
          * Add new attribute button if not image tab
          */
         if (!$form->getElement('media_gallery') && Mage::getSingleton('admin/session')->isAllowed('catalog/attributes/attributes')) {
             $headerBar = $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_attributes_create');
             $headerBar->getConfig()->setTabId('group_' . $group->getId())->setGroupId($group->getId())->setStoreId($form->getDataObject()->getStoreId())->setAttributeSetId($form->getDataObject()->getAttributeSetId())->setTypeId($form->getDataObject()->getTypeId())->setProductId($form->getDataObject()->getId());
             $fieldset->setHeaderBar($headerBar->toHtml());
         }
         if ($form->getElement('meta_description')) {
             $form->getElement('meta_description')->setOnkeyup('checkMaxLength(this, 255);');
         }
         $values = Mage::registry('product')->getData();
         /**
          * Set attribute default values for new product
          */
         if (!Mage::registry('product')->getId()) {
             foreach ($attributes as $attribute) {
                 if (!isset($values[$attribute->getAttributeCode()])) {
                     $values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();
                 }
             }
         }
         Mage::dispatchEvent('adminhtml_catalog_product_edit_prepare_form', array('form' => $form));
         $form->addValues($values);
         $form->setFieldNameSuffix('product');
         $this->setForm($form);
     }
 }
開發者ID:HelioFreitas,項目名稱:magento-pt_br,代碼行數:43,代碼來源:Attributes.php

示例4: _prepareForm

 protected function _prepareForm()
 {
     $product = $this->getProduct();
     if (!($setId = $product->getAttributeSetId())) {
         $setId = $this->getRequest()->getParam('set', null);
     }
     if ($setId) {
         $attributeGroupId = Mage::getConfig()->getNode(Faett_Package_Helper_Data::FAETT_PACKAGE_LINK_GROUP_ID, 'default', 0);
         $group = Mage::getModel('eav/entity_attribute_group')->load($attributeGroupId);
         $attributes = $product->getAttributes($group->getId(), true);
         // do not add groups without attributes
         foreach ($attributes as $key => $attribute) {
             if (!$attribute->getIsVisible()) {
                 unset($attributes[$key]);
             }
         }
         // sort the attributes after their position
         usort($attributes, array($this, '_cmp'));
         if (count($attributes) == 0) {
             return;
         }
         $form = new Varien_Data_Form();
         // initialize product object as form property for using it in elements generation
         $form->setDataObject(Mage::registry('product'));
         $fieldset = $form->addFieldset('group_fields' . $group->getId(), array('legend' => Mage::helper('catalog')->__($group->getAttributeGroupName())));
         $this->_setFieldset($attributes, $fieldset, array('gallery'));
         if (!$form->getElement('media_gallery') && Mage::getSingleton('admin/session')->isAllowed('catalog/attributes/attributes')) {
             $headerBar = $this->getLayout()->createBlock('adminhtml/catalog_product_edit_tab_attributes_create');
             $headerBar->getConfig()->setTabId('group_' . $group->getId())->setGroupId($group->getId())->setStoreId($form->getDataObject()->getStoreId())->setAttributeSetId($form->getDataObject()->getAttributeSetId())->setTypeId($form->getDataObject()->getTypeId())->setProductId($form->getDataObject()->getId());
             $fieldset->setHeaderBar($headerBar->toHtml());
         }
         $values = Mage::registry('product')->getData();
         if (!Mage::registry('product')->getId()) {
             foreach ($attributes as $attribute) {
                 if (!isset($values[$attribute->getAttributeCode()])) {
                     $values[$attribute->getAttributeCode()] = $attribute->getDefaultValue();
                 }
             }
         }
         if (Mage::registry('product')->hasLockedAttributes()) {
             foreach (Mage::registry('product')->getLockedAttributes() as $attribute) {
                 if ($element = $form->getElement($attribute)) {
                     $element->setReadonly(true, true);
                 }
             }
         }
         $form->addValues($values);
         $form->setFieldNameSuffix('product');
         $this->setForm($form);
     }
     return parent::_prepareForm();
 }
開發者ID:BGCX067,項目名稱:faett-package-svn-to-git,代碼行數:52,代碼來源:Package.php


注:本文中的Varien_Data_Form::getDataObject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。