本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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;
}