mirror of
https://github.com/bdnugget/magento2.git
synced 2026-11-08 01:37:36 +00:00
56 lines
1.3 KiB
PHP
56 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* Copyright © Magento, Inc. All rights reserved.
|
|
* See COPYING.txt for license details.
|
|
*/
|
|
namespace Magento\Sales\Model\ResourceModel\Order;
|
|
|
|
use Magento\Framework\App\ResourceConnection;
|
|
use Magento\Sales\Model\ResourceModel\EntityAbstract as SalesResource;
|
|
|
|
/**
|
|
* Flat sales order payment resource
|
|
*/
|
|
class Payment extends SalesResource
|
|
{
|
|
/**
|
|
* Serializable field: additional_information
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $_serializableFields = ['additional_information' => [null, []]];
|
|
|
|
/**
|
|
* Event prefix
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $_eventPrefix = 'sales_order_payment_resource';
|
|
|
|
/**
|
|
* Model initialization
|
|
*
|
|
* @return void
|
|
*/
|
|
protected function _construct()
|
|
{
|
|
$this->_init('sales_order_payment', 'entity_id');
|
|
}
|
|
|
|
/**
|
|
* Perform actions before object save
|
|
*
|
|
* @param \Magento\Framework\Model\AbstractModel|\Magento\Framework\DataObject $object
|
|
* @return $this
|
|
*/
|
|
protected function _beforeSave(\Magento\Framework\Model\AbstractModel $object)
|
|
{
|
|
/**@var $object \Magento\Sales\Model\Order\Payment */
|
|
parent::_beforeSave($object);
|
|
if (!$object->getParentId() && $object->getOrder()) {
|
|
$object->setParentId($object->getOrder()->getId());
|
|
}
|
|
return $this;
|
|
}
|
|
}
|