本文整理汇总了PHP中Magento\Framework\Event\Observer::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP Observer::getData方法的具体用法?PHP Observer::getData怎么用?PHP Observer::getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\Event\Observer
的用法示例。
在下文中一共展示了Observer::getData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* Save order into registry to use it in the overloaded controller.
*
* @param \Magento\Framework\Event\Observer $observer
* @return $this
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
/* @var $order Order */
$order = $this->coreRegistry->registry('directpost_order');
if (!$order || !$order->getId()) {
return $this;
}
$payment = $order->getPayment();
if (!$payment || $payment->getMethod() != $this->payment->getCode()) {
return $this;
}
$result = $observer->getData('result')->getData();
if (!empty($result['error'])) {
return $this;
}
// if success, then set order to session and add new fields
$this->session->addCheckoutOrderIncrementId($order->getIncrementId());
$this->session->setLastOrderIncrementId($order->getIncrementId());
$requestToAuthorizenet = $payment->getMethodInstance()->generateRequestFromOrder($order);
$requestToAuthorizenet->setControllerActionName($observer->getData('action')->getRequest()->getControllerName());
$requestToAuthorizenet->setIsSecure((string) $this->storeManager->getStore()->isCurrentlySecure());
$result[$this->payment->getCode()] = ['fields' => $requestToAuthorizenet->getData()];
$observer->getData('result')->setData($result);
return $this;
}
示例2: testSetEvent
public function testSetEvent()
{
$event = 'someEvent';
$this->observer->setEvent($event);
$result = $this->observer->getData('event');
$this->assertEquals($result, $this->observer->getEvent($event));
}
示例3: execute
/**
* @param Observer $observer
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$dirtyRules = $observer->getData('dirty_rules');
if (!empty($dirtyRules)) {
if ($dirtyRules->getState()) {
$this->messageManager->addNotice($observer->getData('message'));
}
}
}
示例4: customerLoggedIn
/**
* @param \Magento\Framework\Event\Observer $observer
* @return void
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function customerLoggedIn(\Magento\Framework\Event\Observer $observer)
{
if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && $this->weeeHelper->isEnabled()) {
/** @var \Magento\Customer\Model\Data\Customer $customer */
$customer = $observer->getData('customer');
/** @var \Magento\Customer\Api\Data\AddressInterface[] $addresses */
$addresses = $customer->getAddresses();
if (isset($addresses)) {
$defaultShippingFound = false;
$defaultBillingFound = false;
foreach ($addresses as $address) {
if ($address->isDefaultBilling()) {
$defaultBillingFound = true;
$this->customerSession->setDefaultTaxBillingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegion()->getRegionId() : null, 'postcode' => $address->getPostcode()]);
}
if ($address->isDefaultShipping()) {
$defaultShippingFound = true;
$this->customerSession->setDefaultTaxShippingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegion()->getRegionId() : null, 'postcode' => $address->getPostcode()]);
}
if ($defaultShippingFound && $defaultBillingFound) {
break;
}
}
}
}
}
示例5: execute
/**
* @param Observer $observer
* @return void
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function execute(Observer $observer)
{
if ($this->moduleManager->isEnabled('Magento_PageCache') && $this->cacheConfig->isEnabled() && $this->taxHelper->isCatalogPriceDisplayAffectedByTax()) {
/** @var \Magento\Customer\Model\Data\Customer $customer */
$customer = $observer->getData('customer');
$customerGroupId = $customer->getGroupId();
$customerGroup = $this->groupRepository->getById($customerGroupId);
$customerTaxClassId = $customerGroup->getTaxClassId();
$this->customerSession->setCustomerTaxClassId($customerTaxClassId);
/** @var \Magento\Customer\Api\Data\AddressInterface[] $addresses */
$addresses = $customer->getAddresses();
if (isset($addresses)) {
$defaultShippingFound = false;
$defaultBillingFound = false;
foreach ($addresses as $address) {
if ($address->isDefaultBilling()) {
$defaultBillingFound = true;
$this->customerSession->setDefaultTaxBillingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegion()->getRegionId() : null, 'postcode' => $address->getPostcode()]);
}
if ($address->isDefaultShipping()) {
$defaultShippingFound = true;
$this->customerSession->setDefaultTaxShippingAddress(['country_id' => $address->getCountryId(), 'region_id' => $address->getRegion() ? $address->getRegion()->getRegionId() : null, 'postcode' => $address->getPostcode()]);
}
if ($defaultShippingFound && $defaultBillingFound) {
break;
}
}
}
}
}
示例6: execute
public function execute(\Magento\Framework\Event\Observer $observer)
{
/** @var \Magento\Sales\Model\Order $order */
$order = $observer->getData(self::DATA_ORDER);
$this->_subRegister->savePv($order);
$this->_subRegister->accountPv($order);
}
示例7: saveQuickStyles
/**
* Save quick styles
*
* @param EventObserver $event
* @return void
*/
public function saveQuickStyles($event)
{
/** @var $configuration \Magento\DesignEditor\Model\Editor\Tools\Controls\Configuration */
$configuration = $event->getData('configuration');
/** @var $theme \Magento\Framework\View\Design\ThemeInterface */
$theme = $event->getData('theme');
if ($configuration->getControlConfig() instanceof \Magento\DesignEditor\Model\Config\Control\QuickStyles) {
/** @var $renderer \Magento\DesignEditor\Model\Editor\Tools\QuickStyles\Renderer */
$renderer = $this->objectManager->create('Magento\\DesignEditor\\Model\\Editor\\Tools\\QuickStyles\\Renderer');
$content = $renderer->render($configuration->getAllControlsData());
/** @var $cssService \Magento\DesignEditor\Model\Theme\Customization\File\QuickStyleCss */
$cssService = $this->objectManager->create('Magento\\DesignEditor\\Model\\Theme\\Customization\\File\\QuickStyleCss');
/** @var $singleFile \Magento\Theme\Model\Theme\SingleFile */
$singleFile = $this->objectManager->create('Magento\\Theme\\Model\\Theme\\SingleFile', ['fileService' => $cssService]);
$singleFile->update($theme, $content);
}
}
示例8: execute
/**
* @param EventObserver $observer
* @return $this
*/
public function execute(EventObserver $observer)
{
$storeId = $observer->getData('store')->getId();
foreach ($this->entityPool->getEntities() as $entityType) {
$this->sequenceBuilder->setPrefix($storeId)->setSuffix($this->sequenceConfig->get('suffix'))->setStartValue($this->sequenceConfig->get('startValue'))->setStoreId($storeId)->setStep($this->sequenceConfig->get('step'))->setWarningValue($this->sequenceConfig->get('warningValue'))->setMaxValue($this->sequenceConfig->get('maxValue'))->setEntityType($entityType)->create();
}
return $this;
}
示例9: execute
public function execute(\Magento\Framework\Event\Observer $observer)
{
/** @var \Magento\Framework\DataObject $input */
$input = $observer->getData(self::DATA_INPUT);
/** @var \Magento\Quote\Model\Quote\Payment $payment */
$payment = $observer->getData(self::DATA_PAYMENT);
assert($payment instanceof \Magento\Quote\Model\Quote\Payment);
$quote = $payment->getQuote();
/* see ./src/view/frontend/web/js/view/payment/method/partial.js */
$usePartial = $input->getDataByPath('additional_data/use_partial');
if (!is_null($usePartial)) {
/* if JSON marker is set, we need set partial payment marker in quote */
$quote->setData(\Praxigento\Wallet\Model\Quote\Address\Total\Partial::ATTR_QUOTE_SWITCH_PARTIAL_PAYMENT, (bool) $usePartial);
} else {
/* clear marker in quote */
$quote->unsetData(\Praxigento\Wallet\Model\Quote\Address\Total\Partial::ATTR_QUOTE_SWITCH_PARTIAL_PAYMENT);
}
}
示例10: execute
/**
* {@inheritdoc}
*/
public function execute(EventObserver $observer)
{
$action = $observer->getData('controller_action');
if (is_object($action)) {
$this->licenseFactory->create()->getStatus();
}
$feedModel = $this->feedFactory->create();
$feedModel->checkUpdate();
}
示例11: execute
public function execute(\Magento\Framework\Event\Observer $observer)
{
/** @var \Magento\Customer\Model\Data\Customer $beforeSave */
$beforeSave = $observer->getData('orig_customer_data_object');
/** @var \Magento\Customer\Model\Data\Customer $afterSave */
$afterSave = $observer->getData('customer_data_object');
$idBefore = $beforeSave->getId();
$idAfter = $afterSave->getId();
if ($idBefore != $idAfter) {
/* this is newly saved customer, register it into downline */
$req = new \Praxigento\Downline\Service\Customer\Request\Add();
$req->setCustomerId($idAfter);
/* TODO: reference should be generated */
$req->setReference($idAfter);
$this->_callCustomer->add($req);
}
return;
}
示例12: execute
/**
* Set data for response of frontend saveOrder action
*
* @param EventObserver $observer
* @return void
*/
public function execute(EventObserver $observer)
{
/* @var $order \Magento\Sales\Model\Order */
$order = $this->_coreRegistry->registry('hss_order');
if ($order && $order->getId()) {
$payment = $order->getPayment();
if ($payment && in_array($payment->getMethod(), $this->_paypalHss->getHssMethods())) {
$result = $observer->getData('result')->getData();
if (empty($result['error'])) {
$this->_view->loadLayout('checkout_onepage_review', true, true, false);
$html = $this->_view->getLayout()->getBlock('paypal.iframe')->toHtml();
$result['update_section'] = ['name' => 'paypaliframe', 'html' => $html];
$result['redirect'] = false;
$result['success'] = false;
$observer->getData('result')->setData($result);
}
}
}
}
示例13: onAdminhtmlBlockHtmlBefore
/**
* Extend UI blocks.
* @param Varien_Event_Observer $observer
*/
public function onAdminhtmlBlockHtmlBefore(\Magento\Framework\Event\Observer $observer)
{
if (Praxigento_LoginAs_Config::cfgGeneralEnabled()) {
$block = $observer->getData('block');
if ($block instanceof Mage_Adminhtml_Block_Customer_Grid) {
$this->doCustomerGridActionAdd($block);
} elseif ($block instanceof Mage_Adminhtml_Block_Sales_Order_Grid) {
$this->doOrderGridColumnAdd($block);
}
}
}
示例14: execute
public function execute(\Magento\Framework\Event\Observer $observer)
{
/* Get base amount for partial payment from quote totals */
/** @var \Magento\Quote\Model\Quote $quote */
$quote = $observer->getData(self::DATA_QUOTE);
$basePartialAmount = $quote->getShippingAddress()->getData(\Praxigento\Wallet\Model\Quote\Address\Total\Partial::CODE_BASE_TOTAL);
if ($basePartialAmount) {
/* save amounts into order registry */
$partialAmount = $quote->getShippingAddress()->getData(\Praxigento\Wallet\Model\Quote\Address\Total\Partial::CODE_TOTAL);
/** @var \Magento\Sales\Model\Order $order */
$order = $observer->getData(self::DATA_ORDER);
$orderId = $order->getId();
$data = new \Praxigento\Wallet\Data\Entity\Partial\Sale();
$data->setPartialAmount($partialAmount);
$data->setBasePartialAmount($basePartialAmount);
$data->setSaleOrderRef($orderId);
$this->_repoPartialSale->create($data);
$this->_logger->debug("New partial payment by eWallet is registered for order #{$orderId} " . "(base: '{$basePartialAmount}', amount: '{$partialAmount}').");
}
}
示例15: execute
/**
* Add Braintree PayPal shortcut buttons
*
* @param Observer $observer
* @return void
*/
public function execute(Observer $observer)
{
// Remove button from catalog pages
if ($observer->getData('is_catalog_product')) {
return;
}
/** @var ShortcutButtons $shortcutButtons */
$shortcutButtons = $observer->getEvent()->getContainer();
$shortcut = $shortcutButtons->getLayout()->createBlock(self::PAYPAL_SHORTCUT_BLOCK);
$shortcutButtons->addShortcut($shortcut);
}