本文整理汇总了PHP中Mage_Core_Model_Abstract类的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Abstract类的具体用法?PHP Mage_Core_Model_Abstract怎么用?PHP Mage_Core_Model_Abstract使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mage_Core_Model_Abstract类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _beforeSave
/**
* Action before save
*
* @param Mage_Core_Model_Abstract $object
* @return Mage_Api_Model_Resource_Acl_Role
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getId()) {
$this->setCreated(Mage::getSingleton('core/date')->gmtDate());
}
return $this;
}
示例2: _afterLoad
/**
* @param Mage_Core_Model_Abstract $object
* @return Mage_Core_Model_Resource_Db_Abstract
*/
protected function _afterLoad(Mage_Core_Model_Abstract $object)
{
if ($object->getData('additional')) {
$object->setData('additional', Mage::helper('core')->jsonDecode($object->getData('additional')));
}
return parent::_afterLoad($object);
}
示例3: _beforeSave
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if ($object->getData('condition_note') === '') {
$object->setData('condition_note', new Zend_Db_Expr("''"));
}
return $this;
}
示例4: prepareLineItems
public function prepareLineItems(Mage_Core_Model_Abstract $salesEntity, $discountTotalAsItem = true, $shippingTotalAsItem = false)
{
$items = array();
foreach ($salesEntity->getAllItems() as $item) {
if (!$item->getParentItem()) {
$items[] = new Varien_Object($this->_prepareLineItemFields($salesEntity, $item));
}
}
$discountAmount = 0;
// this amount always includes the shipping discount
$shippingDescription = '';
if ($salesEntity instanceof Mage_Sales_Model_Order) {
$discountAmount = abs(1 * $salesEntity->getBaseDiscountAmount() + Mage::getSingleton('checkout/session')->getDiscount());
$shippingDescription = $salesEntity->getShippingDescription();
$totals = array('subtotal' => $salesEntity->getBaseSubtotal() - $discountAmount, 'tax' => $salesEntity->getBaseTaxAmount(), 'shipping' => $salesEntity->getBaseShippingAmount());
} else {
$address = $salesEntity->getIsVirtual() ? $salesEntity->getBillingAddress() : $salesEntity->getShippingAddress();
$discountAmount = abs(1 * $address->getBaseDiscountAmount() + Mage::getSingleton('checkout/session')->getDiscount());
$shippingDescription = $address->getShippingDescription();
$totals = array('subtotal' => $salesEntity->getBaseSubtotal() - $discountAmount, 'tax' => $address->getBaseTaxAmount(), 'shipping' => $address->getBaseShippingAmount(), 'discount' => $discountAmount);
}
// discount total as line item (negative)
if ($discountTotalAsItem && $discountAmount) {
$items[] = new Varien_Object(array('name' => Mage::helper('paypal')->__('Discount'), 'qty' => 1, 'amount' => -1.0 * $discountAmount));
}
Mage::log($discountAmount . "|" . Mage::getSingleton('checkout/session')->getDiscount());
// shipping total as line item
if ($shippingTotalAsItem && !$salesEntity->getIsVirtual() && (double) $totals['shipping']) {
$items[] = new Varien_Object(array('id' => Mage::helper('paypal')->__('Shipping'), 'name' => $shippingDescription, 'qty' => 1, 'amount' => (double) $totals['shipping']));
}
return array($items, $totals, $discountAmount, $totals['shipping']);
}
示例5: _afterDelete
protected function _afterDelete(Mage_Core_Model_Abstract $object)
{
//delete values
$this->_getReadAdapter()->delete($this->getTable('webforms/results_values'), 'field_id =' . $object->getId());
Mage::dispatchEvent('webforms_field_delete', array('field' => $object));
return parent::_afterDelete($object);
}
示例6: isVersionHasPublishedRevision
/**
* Checking if Version does not contain published revision
*
* @param Mage_Core_Model_Abstract $object
* @return bool
*/
public function isVersionHasPublishedRevision(Mage_Core_Model_Abstract $object)
{
$select = $this->_getReadAdapter()->select();
$select->from(array('p' => $this->getTable('cms/page')), array())->where('p.page_id = ?', (int) $object->getPageId())->join(array('r' => $this->getTable('enterprise_cms/page_revision')), 'r.revision_id = p.published_revision_id', 'r.version_id');
$result = $this->_getReadAdapter()->fetchOne($select);
return $result == $object->getVersionId();
}
示例7: _afterSave
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
/** @var Mirasvit_Helpdesk_Model_Status $object */
if (!$object->getIsMassStatus()) {
}
return parent::_afterSave($object);
}
示例8: _beforeDelete
protected function _beforeDelete(Mage_Core_Model_Abstract $object)
{
// Cleanup stats on slideshow delete
$adapter = $this->_getWriteAdapter();
// 1. Delete slideshow/store
$adapter->delete($this->getTable('mp_slideshow/store'), 'slideshow_id=' . $object->getId());
}
示例9: _afterSave
/**
* Save entity types after save form type
*
* @param Mage_Eav_Model_Form_Type $object
* @see Mage_Core_Model_Mysql4_Abstract#_afterSave($object)
* @return Mage_Eav_Model_Mysql4_Form_Type
*/
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
if ($object->hasEntityTypes()) {
$new = $object->getEntityTypes();
$old = $this->getEntityTypes($object);
$insert = array_diff($new, $old);
$delete = array_diff($old, $new);
$write = $this->_getWriteAdapter();
if (!empty($insert)) {
$data = array();
foreach ($insert as $entityId) {
if (empty($entityId)) {
continue;
}
$data[] = array('entity_type_id' => (int) $entityId, 'type_id' => $object->getId());
}
if ($data) {
$write->insertMultiple($this->getTable('eav/form_type_entity'), $data);
}
}
if (!empty($delete)) {
$where = join(' AND ', array($write->quoteInto('type_id=?', $object->getId()), $write->quoteInto('entity_type_id IN(?)', $delete)));
$write->delete($this->getTable('eav/form_type_entity'), $where);
}
}
return parent::_afterSave($object);
}
示例10: setProgramIsProcessed
public function setProgramIsProcessed(Mage_Core_Model_Abstract $object)
{
if (!$object->getId()) {
return $this;
}
return $this->save($object->setIsProcess('1'));
}
示例11: getChildren
public function getChildren(Mage_Core_Model_Abstract $object)
{
/** @var Magpleasure_Common_Model_Resource_Treeview_Collection_Abstract $collection */
$collection = $object->getCollection();
$collection->addFieldToFilter($this->getParentIdField(), $object->getData($this->getParentIdField()))->setOrder($this->getPositionField(), 'ASC');
return $collection;
}
示例12: _syncStore
protected function _syncStore(Mage_Core_Model_Abstract $object)
{
$collection = Mage::getModel('menu/item')->getCollection()->addFieldToFilter('menu_id', $object->getId());
foreach ($collection as $item) {
$item->setStoreIds($object->getStoreIds())->save();
}
}
示例13: _beforeSave
/**
* Perform operations before object save
*
* @param Mage_Cms_Model_Block $object
* @return Creativestyle_CheckoutByAmazon_Model_Mysql4_Log_Abstract
*/
protected function _beforeSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getId()) {
$object->setCreationTime(Mage::getSingleton('core/date')->gmtDate());
}
return parent::_beforeSave($object);
}
示例14: _afterSave
/**
* Call-back function
*/
protected function _afterSave(Mage_Core_Model_Abstract $object)
{
if (!$object->getIsMassStatus()) {
$this->_saveToStoreTable($object);
}
return parent::_afterSave($object);
}
示例15: extractEavAttributeValue
/**
* @param string $attributeCode
* @param Mage_Core_Model_Abstract $object
*
* @return null|string
*/
public function extractEavAttributeValue($attributeCode = null, Mage_Core_Model_Abstract $object)
{
if (!empty($attributeCode) && $object->hasData($attributeCode)) {
return $object->getData($attributeCode);
}
return null;
}