本文整理汇总了PHP中Magento\Framework\Event\Observer::getDataObject方法的典型用法代码示例。如果您正苦于以下问题:PHP Observer::getDataObject方法的具体用法?PHP Observer::getDataObject怎么用?PHP Observer::getDataObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Event\Observer
的用法示例。
在下文中一共展示了Observer::getDataObject方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Update transaction with HTML representation of txn_id
*
* @param EventObserver $observer
* @return void
*/
public function execute(EventObserver $observer)
{
/** @var \Magento\Sales\Model\Order\Payment\Transaction $transaction */
$transaction = $observer->getDataObject();
$order = $transaction->getOrder();
$payment = $order->getPayment();
$methodInstance = $payment->getMethodInstance();
$paymentCode = $methodInstance->getCode();
$transactionLink = $this->paypalData->getHtmlTransactionId($paymentCode, $transaction->getTxnId());
$transaction->setData('html_txn_id', $transactionLink);
}
示例2: syncRemove
/**
* Handles synchronous removing of the entity from
* corresponding grid on certain events.
*
* Used in the next events:
*
* - sales_order_delete_after
* - sales_order_invoice_delete_after
* - sales_order_shipment_delete_after
* - sales_order_creditmemo_delete_after
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
*/
public function syncRemove(\Magento\Framework\Event\Observer $observer)
{
$this->entityGrid->purge($observer->getDataObject()->getId());
}
示例3: saveChangeTime
/**
* Save time stamp of last change
*
* @param EventObserver $event
* @return void
*/
public function saveChangeTime($event)
{
/** @var $theme \Magento\Theme\Model\Theme|null */
$theme = $event->getTheme() ?: $event->getDataObject()->getTheme();
/** @var $change \Magento\DesignEditor\Model\Theme\Change */
$change = $this->objectManager->create('Magento\\DesignEditor\\Model\\Theme\\Change');
if ($theme && $theme->getId()) {
$change->loadByThemeId($theme->getId());
$change->setThemeId($theme->getId())->setChangeTime(null);
$change->save();
}
}