当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Core_Model_Abstract::getSortOrder方法代码示例

本文整理汇总了PHP中Mage_Core_Model_Abstract::getSortOrder方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Abstract::getSortOrder方法的具体用法?PHP Mage_Core_Model_Abstract::getSortOrder怎么用?PHP Mage_Core_Model_Abstract::getSortOrder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Core_Model_Abstract的用法示例。


在下文中一共展示了Mage_Core_Model_Abstract::getSortOrder方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 public function save(Mage_Core_Model_Abstract $object)
 {
     $write = $this->_getWriteAdapter();
     $groupId = $object->getId();
     $data = array('attribute_set_id' => $object->getAttributeSetId(), 'attribute_group_name' => $object->getAttributeGroupName(), 'sort_order' => $object->getSortOrder() > 0 ? $object->getSortOrder() : $this->_getMaxSortOrder($object) + 1);
     try {
         if ($groupId > 0) {
             $condition = $write->quoteInto("{$this->getMainTable()}.{$this->getIdFieldName()} = ?", $groupId);
             $write->update($this->getMainTable(), $data, $condition);
         } else {
             $write->insert($this->getMainTable(), $data);
             $object->setId($write->lastInsertId());
         }
         if ($object->getAttributes()) {
             $insertId = $write->lastInsertId();
             foreach ($object->getAttributes() as $attribute) {
                 if ($insertId > 0) {
                     $attribute->setAttributeGroupId($insertId);
                 }
                 $attribute->save();
             }
         }
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
     return $this;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:27,代码来源:Group.php

示例2: _beforeSave

 /**
  * Perform actions before object save
  *
  * @param Mage_Core_Model_Abstract $object
  * @return Mage_Core_Model_Resource_Db_Abstract
  */
 protected function _beforeSave(Mage_Core_Model_Abstract $object)
 {
     if (!$object->getSortOrder()) {
         $object->setSortOrder($this->_getMaxSortOrder($object) + 1);
     }
     return parent::_beforeSave($object);
 }
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:13,代码来源:Group.php

示例3: _beforeSave

 /**
  * Before model save
  *
  * @param Mage_Core_Model_Abstract $object
  * @return Enterprise_CatalogEvent_Model_Mysql4_Event
  */
 protected function _beforeSave(Mage_Core_Model_Abstract $object)
 {
     if (strlen($object->getSortOrder()) === 0) {
         $object->setSortOrder(null);
     }
     return parent::_beforeSave($object);
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:13,代码来源:Event.php

示例4: _afterSave

 /**
  * Save attribute/form relations after attribute save
  *
  * @param Mage_Core_Model_Abstract $object
  * @return Mage_Eav_Model_Resource_Attribute
  */
 protected function _afterSave(Mage_Core_Model_Abstract $object)
 {
     $forms = $object->getData('used_in_forms');
     $adapter = $this->_getWriteAdapter();
     if (is_array($forms)) {
         $where = array('attribute_id=?' => $object->getId());
         $adapter->delete($this->_getFormAttributeTable(), $where);
         $data = array();
         foreach ($forms as $formCode) {
             $data[] = array('form_code' => $formCode, 'attribute_id' => (int) $object->getId());
         }
         if ($data) {
             $adapter->insertMultiple($this->_getFormAttributeTable(), $data);
         }
     }
     // update sort order
     if (!$object->isObjectNew() && $object->dataHasChangedFor('sort_order')) {
         $data = array('sort_order' => $object->getSortOrder());
         $where = array('attribute_id=?' => (int) $object->getId());
         $adapter->update($this->getTable('eav/entity_attribute'), $data, $where);
     }
     // save scope attributes
     $websiteId = (int) $object->getWebsite()->getId();
     if ($websiteId) {
         $table = $this->_getEavWebsiteTable();
         $describe = $this->_getReadAdapter()->describeTable($table);
         $data = array();
         if (!$object->getScopeWebsiteId() || $object->getScopeWebsiteId() != $websiteId) {
             $data = $this->getScopeValues($object);
         }
         $data['attribute_id'] = (int) $object->getId();
         $data['website_id'] = (int) $websiteId;
         unset($describe['attribute_id']);
         unset($describe['website_id']);
         $updateColumns = array();
         foreach (array_keys($describe) as $columnName) {
             $data[$columnName] = $object->getData('scope_' . $columnName);
             $updateColumns[] = $columnName;
         }
         $adapter->insertOnDuplicate($table, $data, $updateColumns);
     }
     return parent::_afterSave($object);
 }
开发者ID:ravi2jdesign,项目名称:solvingmagento_1.7.0,代码行数:49,代码来源:Attribute.php

示例5: saveInSetIncluding

 /**
  * Save in set including
  *
  * @param Mage_Core_Model_Abstract $object
  * @return Mage_Eav_Model_Resource_Entity_Attribute
  */
 public function saveInSetIncluding(Mage_Core_Model_Abstract $object)
 {
     $attributeId = (int) $object->getId();
     $setId = (int) $object->getAttributeSetId();
     $groupId = (int) $object->getAttributeGroupId();
     if ($setId && $groupId && $object->getEntityTypeId()) {
         $adapter = $this->_getWriteAdapter();
         $table = $this->getTable('eav_entity_attribute');
         $sortOrder = $object->getSortOrder() ?: $this->_getMaxSortOrder($object) + 1;
         $data = array('entity_type_id' => $object->getEntityTypeId(), 'attribute_set_id' => $setId, 'attribute_group_id' => $groupId, 'attribute_id' => $attributeId, 'sort_order' => $sortOrder);
         $where = array('attribute_id =?' => $attributeId, 'attribute_set_id =?' => $setId);
         $adapter->delete($table, $where);
         $adapter->insert($table, $data);
     }
     return $this;
 }
开发者ID:natxetee,项目名称:magento2,代码行数:22,代码来源:Attribute.php

示例6: saveInSetIncluding

 /**
  * Enter description here...
  *
  * @param Mage_Core_Model_Abstract $object
  * @return Mage_Eav_Model_Mysql4_Entity_Attribute
  */
 public function saveInSetIncluding(Mage_Core_Model_Abstract $object)
 {
     $attrId = $object->getId();
     $setId = (int) $object->getAttributeSetId();
     $groupId = (int) $object->getAttributeGroupId();
     if ($setId && $groupId && $object->getEntityTypeId()) {
         $write = $this->_getWriteAdapter();
         $table = $this->getTable('entity_attribute');
         $data = array('entity_type_id' => $object->getEntityTypeId(), 'attribute_set_id' => $setId, 'attribute_group_id' => $groupId, 'attribute_id' => $attrId, 'sort_order' => $object->getSortOrder() ? $object->getSortOrder() : $this->_getMaxSortOrder($object) + 1);
         $condition = "{$table}.attribute_id = '{$attrId}'\n                AND {$table}.attribute_set_id = '{$setId}'";
         $write->delete($table, $condition);
         $write->insert($table, $data);
     }
     return $this;
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:21,代码来源:Attribute.php


注:本文中的Mage_Core_Model_Abstract::getSortOrder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。