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


PHP AbstractModel::getAttributeSetId方法代码示例

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


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

示例1: _getMaxSortOrder

 /**
  * Retrieve max sort order
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return int
  */
 protected function _getMaxSortOrder($object)
 {
     $adapter = $this->_getReadAdapter();
     $bind = [':attribute_set_id' => $object->getAttributeSetId()];
     $select = $adapter->select()->from($this->getMainTable(), new \Zend_Db_Expr("MAX(sort_order)"))->where('attribute_set_id = :attribute_set_id');
     return $adapter->fetchOne($select, $bind);
 }
开发者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: _beforeDelete

 /**
  * Perform actions before object delete
  *
  * @param \Magento\Framework\Model\AbstractModel $object
  * @return $this
  * @throws \Magento\Framework\Exception\StateException
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _beforeDelete(\Magento\Framework\Model\AbstractModel $object)
 {
     /** @var \Magento\Eav\Api\Data\AttributeSetInterface $object */
     $defaultAttributeSetId = $this->eavConfig->getEntityType($object->getEntityTypeId())->getDefaultAttributeSetId();
     if ($object->getAttributeSetId() == $defaultAttributeSetId) {
         throw new \Magento\Framework\Exception\StateException(__('Default attribute set can not be deleted'));
     }
     return parent::_beforeDelete($object);
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:17,代码来源:Set.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::getAttributeSetId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。