当前位置: 首页>>代码示例>>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;未经允许,请勿转载。