/**
  * Refresh sales order report statistics for last day
  *
  * @return void
  */
 public function execute()
 {
     $this->localeResolver->emulate(0);
     $currentDate = $this->localeDate->date();
     $date = $currentDate->sub(new \DateInterval('PT25H'));
     $this->orderFactory->create()->aggregate($date);
     $this->localeResolver->revert();
 }
 /**
  * Refresh sales refunded report statistics for last day
  *
  * @return void
  */
 public function execute()
 {
     $this->localeResolver->emulate(0);
     $currentDate = $this->localeDate->date();
     $date = $currentDate->subHour(25);
     $this->refundedFactory->create()->aggregate($date);
     $this->localeResolver->revert();
 }
 /**
  * Refresh sales coupons report statistics for last day
  *
  * @return $this
  */
 public function execute()
 {
     $this->_localeResolver->emulate(0);
     $currentDate = $this->_localeDate->date();
     $date = $currentDate->modify('-25 hours');
     $this->_reportRule->aggregate($date);
     $this->_localeResolver->revert();
     return $this;
 }
Ejemplo n.º 4
0
 /**
  * Refresh sales shipment report statistics for last day
  *
  * @return $this
  */
 public function aggregateSalesReportShipmentData()
 {
     $this->_localeResolver->emulate(0);
     $currentDate = new \DateTime();
     $date = $currentDate->modify('-25 hours');
     $this->_shippingFactory->create()->aggregate($date);
     $this->_localeResolver->revert();
     return $this;
 }
Ejemplo n.º 5
0
 /**
  * Refresh sales shipment report statistics for last day
  *
  * @return $this
  */
 public function aggregateSalesReportShipmentData()
 {
     $this->_localeResolver->emulate(0);
     $currentDate = $this->_coreLocale->date();
     $date = $currentDate->subHour(25);
     $this->_shippingFactory->create()->aggregate($date);
     $this->_localeResolver->revert();
     return $this;
 }
 /**
  * Refresh sales tax report statistics for last day
  *
  * @return $this
  */
 public function invoke()
 {
     $this->localeResolver->emulate(0);
     $currentDate = $this->localeDate->date();
     $date = $currentDate->modify('-25 hours');
     /** @var $reportTax \Magento\Tax\Model\ResourceModel\Report\Tax */
     $reportTax = $this->reportTaxFactory->create();
     $reportTax->aggregate($date);
     $this->localeResolver->revert();
     return $this;
 }
Ejemplo n.º 7
0
 /**
  * Refresh sales coupons report statistics for last day
  *
  * @return $this
  */
 public function aggregateSalesReportCouponsData()
 {
     $this->_localeResolver->emulate(0);
     $currentDate = $this->_localeDate->date();
     $date = $currentDate->subHour(25);
     $this->_reportRule->aggregate($date);
     $this->_localeResolver->revert();
     return $this;
 }
Ejemplo n.º 8
0
 /**
  * Get prices javascript format json
  *
  * @param  null|int|string|Store $store
  * @return string
  */
 public function getPriceFormat($store = null)
 {
     $this->_localeResolver->emulate($store);
     $priceFormat = $this->_localeFormat->getPriceFormat();
     $this->_localeResolver->revert();
     if ($store) {
         $priceFormat['pattern'] = $this->_storeManager->getStore($store)->getCurrentCurrency()->getOutputFormat();
     }
     return $this->jsonHelper->jsonEncode($priceFormat);
 }
Ejemplo n.º 9
0
 /**
  * Refresh sales tax report statistics for last day
  *
  * @param \Magento\Cron\Model\Schedule $schedule
  * @return $this
  */
 public function aggregateSalesReportTaxData($schedule)
 {
     $this->_localeResolver->emulate(0);
     $currentDate = $this->_localeDate->date();
     $date = $currentDate->subHour(25);
     /** @var $reportTax \Magento\Tax\Model\Resource\Report\Tax */
     $reportTax = $this->_reportTaxFactory->create();
     $reportTax->aggregate($date);
     $this->_localeResolver->revert();
     return $this;
 }
Ejemplo n.º 10
0
 /**
  * Format pdf file
  *
  * @param  null $shipment
  * @return \Zend_Pdf
  */
 public function getPdf($shipment = null)
 {
     $this->_beforeGetPdf();
     $this->_initRenderer('shipment');
     $pdf = new \Zend_Pdf();
     $this->_setPdf($pdf);
     $page = $this->newPage();
     if ($shipment->getStoreId()) {
         $this->_localeResolver->emulate($shipment->getStoreId());
         $this->_storeManager->setCurrentStore($shipment->getStoreId());
     }
     $this->_setFontRegular($page);
     $this->_drawHeaderBlock($page);
     $this->y = 740;
     $this->_drawPackageBlock($page);
     $page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
     $this->_afterGetPdf();
     if ($shipment->getStoreId()) {
         $this->_localeResolver->revert();
     }
     return $pdf;
 }
Ejemplo n.º 11
0
 /**
  * Return PDF document
  *
  * @param  array $invoices
  * @return \Zend_Pdf
  */
 public function getPdf($invoices = [])
 {
     $this->_beforeGetPdf();
     $this->_initRenderer('invoice');
     $pdf = new \Zend_Pdf();
     $this->_setPdf($pdf);
     $style = new \Zend_Pdf_Style();
     $this->_setFontBold($style, 10);
     foreach ($invoices as $invoice) {
         if ($invoice->getStoreId()) {
             $this->_localeResolver->emulate($invoice->getStoreId());
             $this->_storeManager->setCurrentStore($invoice->getStoreId());
         }
         $page = $this->newPage();
         $order = $invoice->getOrder();
         /* Add image */
         $this->insertLogo($page, $invoice->getStore());
         /* Add address */
         $this->insertAddress($page, $invoice->getStore());
         /* Add head */
         $this->insertOrder($page, $order, $this->_scopeConfig->isSetFlag(self::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $order->getStoreId()));
         /* Add document text and number */
         $this->insertDocumentNumber($page, __('Invoice # ') . $invoice->getIncrementId());
         /* Add table */
         $this->_drawHeader($page);
         /* Add body */
         foreach ($invoice->getAllItems() as $item) {
             if ($item->getOrderItem()->getParentItem()) {
                 continue;
             }
             /* Draw item */
             $this->_drawItem($item, $page, $order);
             $page = end($pdf->pages);
         }
         /* Add totals */
         $this->insertTotals($page, $invoice);
         if ($invoice->getStoreId()) {
             $this->_localeResolver->revert();
         }
     }
     $this->_afterGetPdf();
     return $pdf;
 }
Ejemplo n.º 12
0
 /**
  * Retrieve Date value for store
  *
  * @param int $storeId
  * @param string $date
  * @return string|null
  */
 protected function getStoreDate($storeId, $date = null)
 {
     if (!isset($this->dates[$storeId])) {
         $timezone = $this->scopeConfig->getValue($this->localeDate->getDefaultTimezonePath(), \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $storeId);
         $this->localeResolver->emulate($storeId);
         $dateObj = new \DateTime();
         $dateObj->setTimezone(new \DateTimeZone($timezone));
         $this->dates[$storeId] = $dateObj;
         $this->localeResolver->revert();
     }
     if (!$this->dateTime->isEmptyDate($date)) {
         /** @var \DateTime $dateObj */
         $dateObj = $this->dates[$storeId];
         return $this->localeDate->formatDateTime($dateObj, \IntlDateFormatter::MEDIUM, \IntlDateFormatter::NONE);
     }
     return null;
 }
Ejemplo n.º 13
0
 /**
  * Get "What Is PayPal" localized URL
  * Supposed to be used with "mark" as popup window
  *
  * @param \Magento\Framework\Locale\ResolverInterface $localeResolver
  * @return string
  */
 public function getPaymentMarkWhatIsPaypalUrl(\Magento\Framework\Locale\ResolverInterface $localeResolver = null)
 {
     $countryCode = 'US';
     if (null !== $localeResolver) {
         $shouldEmulate = null !== $this->_storeId && $this->_storeManager->getStore()->getId() != $this->_storeId;
         if ($shouldEmulate) {
             $localeResolver->emulate($this->_storeId);
         }
         $countryCode = \Locale::getRegion($localeResolver->getLocale());
         if ($shouldEmulate) {
             $localeResolver->revert();
         }
     }
     return sprintf('https://www.paypal.com/%s/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', strtolower($countryCode));
 }
Ejemplo n.º 14
0
 /**
  * Refresh bestsellers report statistics for last day
  *
  * @param \Magento\Cron\Model\Schedule $schedule
  * @return $this
  */
 public function aggregateSalesReportBestsellersData($schedule)
 {
     $this->_localeResolver->emulate(0);
     $currentDate = $this->_localeDate->date();
     $date = $currentDate->subHour(25);
     $this->_bestsellersFactory->create()->aggregate($date);
     $this->_localeResolver->revert();
     return $this;
 }