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


PHP AbstractModel::getSortOrder方法代码示例

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


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

示例1: _beforeSave

 /**
  * Perform actions before object save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return \Magento\Framework\Model\Resource\Db\AbstractDb
  */
 protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
 {
     if (!$object->getSortOrder()) {
         $object->setSortOrder($this->_getMaxSortOrder($object) + 1);
     }
     return parent::_beforeSave($object);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:13,代码来源:Group.php

示例2: saveInSetIncluding

 /**
  * Save in set including
  *
  * @param AbstractModel $object
  * @param null $attributeEntityId
  * @param null $attributeSetId
  * @param null $attributeGroupId
  * @param null $attributeSortOrder
  * @return $this
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function saveInSetIncluding(AbstractModel $object, $attributeEntityId = null, $attributeSetId = null, $attributeGroupId = null, $attributeSortOrder = null)
 {
     $attributeId = $attributeEntityId === null ? (int) $object->getId() : (int) $attributeEntityId;
     $setId = $attributeSetId === null ? (int) $object->getAttributeSetId() : (int) $attributeSetId;
     $groupId = $attributeGroupId === null ? (int) $object->getAttributeGroupId() : (int) $attributeGroupId;
     $attributeSortOrder = $attributeSortOrder === null ? (int) $object->getSortOrder() : (int) $attributeSortOrder;
     if ($setId && $groupId && $object->getEntityTypeId()) {
         $connection = $this->getConnection();
         $table = $this->getTable('eav_entity_attribute');
         $sortOrder = $attributeSortOrder ?: $this->_getMaxSortOrder($object) + 1;
         $data = ['entity_type_id' => $object->getEntityTypeId(), 'attribute_set_id' => $setId, 'attribute_group_id' => $groupId, 'attribute_id' => $attributeId, 'sort_order' => $sortOrder];
         $where = ['attribute_id =?' => $attributeId, 'attribute_set_id =?' => $setId];
         $connection->delete($table, $where);
         $connection->insert($table, $data);
     }
     return $this;
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:28,代码来源:Attribute.php

示例3: _afterSave

 /**
  * Save attribute/form relations after attribute save
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  */
 protected function _afterSave(AbstractModel $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:aiesh,项目名称:magento2,代码行数:49,代码来源:Attribute.php

示例4: saveInSetIncluding

 /**
  * Save in set including
  *
  * @param AbstractModel $object
  * @return $this
  */
 public function saveInSetIncluding(AbstractModel $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:pavelnovitsky,项目名称:magento2,代码行数:22,代码来源:Attribute.php


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