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