当前位置: 首页>>代码示例>>PHP>>正文


PHP TimezoneInterface::scopeDate方法代码示例

本文整理汇总了PHP中Magento\Framework\Stdlib\DateTime\TimezoneInterface::scopeDate方法的典型用法代码示例。如果您正苦于以下问题:PHP TimezoneInterface::scopeDate方法的具体用法?PHP TimezoneInterface::scopeDate怎么用?PHP TimezoneInterface::scopeDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Magento\Framework\Stdlib\DateTime\TimezoneInterface的用法示例。


在下文中一共展示了TimezoneInterface::scopeDate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * Apply catalog price rules to product in admin
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $product = $observer->getEvent()->getProduct();
     $storeId = $product->getStoreId();
     $date = $this->localeDate->scopeDate($storeId);
     $key = false;
     $ruleData = $this->coreRegistry->registry('rule_data');
     if ($ruleData) {
         $wId = $ruleData->getWebsiteId();
         $gId = $ruleData->getCustomerGroupId();
         $pId = $product->getId();
         $key = "{$date->format('Y-m-d H:i:s')}|{$wId}|{$gId}|{$pId}";
     } elseif ($product->getWebsiteId() !== null && $product->getCustomerGroupId() !== null) {
         $wId = $product->getWebsiteId();
         $gId = $product->getCustomerGroupId();
         $pId = $product->getId();
         $key = "{$date->format('Y-m-d H:i:s')}|{$wId}|{$gId}|{$pId}";
     }
     if ($key) {
         if (!$this->rulePricesStorage->hasRulePrice($key)) {
             $rulePrice = $this->resourceRuleFactory->create()->getRulePrice($date, $wId, $gId, $pId);
             $this->rulePricesStorage->setRulePrice($key, $rulePrice);
         }
         if ($this->rulePricesStorage->getRulePrice($key) !== false) {
             $finalPrice = min($product->getData('final_price'), $this->rulePricesStorage->getRulePrice($key));
             $product->setFinalPrice($finalPrice);
         }
     }
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:36,代码来源:ProcessAdminFinalPriceObserver.php

示例2: execute

 /**
  * Apply catalog price rules to product on frontend
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return $this
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     $product = $observer->getEvent()->getProduct();
     $pId = $product->getId();
     $storeId = $product->getStoreId();
     if ($observer->hasDate()) {
         $date = new \DateTime($observer->getEvent()->getDate());
     } else {
         $date = $this->localeDate->scopeDate($storeId);
     }
     if ($observer->hasWebsiteId()) {
         $wId = $observer->getEvent()->getWebsiteId();
     } else {
         $wId = $this->storeManager->getStore($storeId)->getWebsiteId();
     }
     if ($observer->hasCustomerGroupId()) {
         $gId = $observer->getEvent()->getCustomerGroupId();
     } elseif ($product->hasCustomerGroupId()) {
         $gId = $product->getCustomerGroupId();
     } else {
         $gId = $this->customerSession->getCustomerGroupId();
     }
     $key = "{$date->format('Y-m-d H:i:s')}|{$wId}|{$gId}|{$pId}";
     if (!$this->rulePricesStorage->hasRulePrice($key)) {
         $rulePrice = $this->resourceRuleFactory->create()->getRulePrice($date, $wId, $gId, $pId);
         $this->rulePricesStorage->setRulePrice($key, $rulePrice);
     }
     if ($this->rulePricesStorage->getRulePrice($key) !== false) {
         $finalPrice = min($product->getData('final_price'), $this->rulePricesStorage->getRulePrice($key));
         $product->setFinalPrice($finalPrice);
     }
     return $this;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:39,代码来源:ProcessFrontFinalPriceObserver.php

示例3: beforeLoad

 /**
  * @param Collection $productCollection
  * @param bool $printQuery
  * @param bool $logQuery
  * @return array
  */
 public function beforeLoad(Collection $productCollection, $printQuery = false, $logQuery = false)
 {
     if (!$productCollection->hasFlag('catalog_rule_loaded')) {
         $connection = $this->resource->getConnection();
         $store = $this->storeManager->getStore();
         $productCollection->getSelect()->joinLeft(['catalog_rule' => $this->resource->getTableName('catalogrule_product_price')], implode(' AND ', ['catalog_rule.product_id = e.entity_id', $connection->quoteInto('catalog_rule.website_id = ?', $store->getWebsiteId()), $connection->quoteInto('catalog_rule.customer_group_id = ?', $this->customerSession->getCustomerGroupId()), $connection->quoteInto('catalog_rule.rule_date = ?', $this->dateTime->formatDate($this->localeDate->scopeDate($store->getId()), false))]), [CatalogRulePrice::PRICE_CODE => 'rule_price']);
         $productCollection->setFlag('catalog_rule_loaded', true);
     }
     return [$printQuery, $logQuery];
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:16,代码来源:AddCatalogRulePrice.php

示例4: getValue

 /**
  * Returns catalog rule value
  *
  * @return float|boolean
  */
 public function getValue()
 {
     if (null === $this->value) {
         $this->value = $this->resourceRuleFactory->create()->getRulePrice($this->dateTime->scopeDate($this->storeManager->getStore()->getId()), $this->storeManager->getStore()->getWebsiteId(), $this->customerSession->getCustomerGroupId(), $this->product->getId());
         $this->value = $this->value ? floatval($this->value) : false;
         if ($this->value) {
             $this->value = $this->priceCurrency->convertAndRound($this->value);
         }
     }
     return $this->value;
 }
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:16,代码来源:CatalogRulePrice.php

示例5: getValue

 /**
  * Returns catalog rule value
  *
  * @return float|boolean
  */
 public function getValue()
 {
     if (null === $this->value) {
         if ($this->product->hasData(self::PRICE_CODE)) {
             $this->value = floatval($this->product->getData(self::PRICE_CODE)) ?: false;
         } else {
             $this->value = $this->getRuleResource()->getRulePrice($this->dateTime->scopeDate($this->storeManager->getStore()->getId()), $this->storeManager->getStore()->getWebsiteId(), $this->customerSession->getCustomerGroupId(), $this->product->getId());
             $this->value = $this->value ? floatval($this->value) : false;
             if ($this->value) {
                 $this->value = $this->priceCurrency->convertAndRound($this->value);
             }
         }
     }
     return $this->value;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:20,代码来源:CatalogRulePrice.php

示例6: getStoreTZOffsetQuery

 /**
  * Retrieve query for attribute with timezone conversion
  *
  * @param string|[] $table
  * @param string $column
  * @param null|mixed $from
  * @param null|mixed $to
  * @param null|int|string|\Magento\Store\Model\Store $store
  * @param \Magento\Framework\DB\Adapter\AdapterInterface $connection
  * @return string
  */
 public function getStoreTZOffsetQuery($table, $column, $from = null, $to = null, $store = null, $connection = null)
 {
     if (!$connection) {
         $connection = $this->getConnection();
     }
     $column = $connection->quoteIdentifier($column);
     if (null === $from) {
         $selectOldest = $connection->select()->from($table, ["MIN({$column})"]);
         $from = $connection->fetchOne($selectOldest);
     }
     $periods = $this->_getTZOffsetTransitions($this->_localeDate->scopeDate($store)->format('e'), $from, $to);
     if (empty($periods)) {
         return $column;
     }
     $query = "";
     $periodsCount = count($periods);
     $i = 0;
     foreach ($periods as $offset => $timestamps) {
         $subParts = [];
         foreach ($timestamps as $ts) {
             $subParts[] = "({$column} between {$ts['from']} and {$ts['to']})";
         }
         $then = $connection->getDateAddSql($column, $offset, \Magento\Framework\DB\Adapter\AdapterInterface::INTERVAL_SECOND);
         $query .= ++$i == $periodsCount ? $then : "CASE WHEN " . join(" OR ", $subParts) . " THEN {$then} ELSE ";
     }
     return $query . str_repeat('END ', count($periods) - 1);
 }
开发者ID:whoople,项目名称:magento2-testing,代码行数:38,代码来源:AbstractReport.php

示例7: processAdminFinalPrice

 /**
  * Apply catalog price rules to product in admin
  *
  * @param EventObserver $observer
  * @return $this
  */
 public function processAdminFinalPrice($observer)
 {
     $product = $observer->getEvent()->getProduct();
     $storeId = $product->getStoreId();
     $date = $this->_localeDate->scopeDate($storeId);
     $key = false;
     $ruleData = $this->_coreRegistry->registry('rule_data');
     if ($ruleData) {
         $wId = $ruleData->getWebsiteId();
         $gId = $ruleData->getCustomerGroupId();
         $pId = $product->getId();
         $key = "{$date->format('Y-m-d H:i:s')}|{$wId}|{$gId}|{$pId}";
     } elseif ($product->getWebsiteId() !== null && $product->getCustomerGroupId() !== null) {
         $wId = $product->getWebsiteId();
         $gId = $product->getCustomerGroupId();
         $pId = $product->getId();
         $key = "{$date->format('Y-m-d H:i:s')}|{$wId}|{$gId}|{$pId}";
     }
     if ($key) {
         if (!isset($this->_rulePrices[$key])) {
             $rulePrice = $this->_resourceRuleFactory->create()->getRulePrice($date, $wId, $gId, $pId);
             $this->_rulePrices[$key] = $rulePrice;
         }
         if ($this->_rulePrices[$key] !== false) {
             $finalPrice = min($product->getData('final_price'), $this->_rulePrices[$key]);
             $product->setFinalPrice($finalPrice);
         }
     }
     return $this;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:36,代码来源:Observer.php

示例8: _getTZRangeExpressionForAttribute

 /**
  * Retrieve range expression with timezone conversion adapted for attribute
  *
  * @param string $range
  * @param string $attribute
  * @param string $tzFrom
  * @param string $tzTo
  * @return string
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 protected function _getTZRangeExpressionForAttribute($range, $attribute, $tzFrom = '+00:00', $tzTo = null)
 {
     if (null == $tzTo) {
         $tzTo = $this->_localeDate->scopeDate()->format('P');
     }
     $adapter = $this->getConnection();
     $expression = $this->_getRangeExpression($range);
     $attribute = $adapter->quoteIdentifier($attribute);
     $periodExpr = $adapter->getDateAddSql($attribute, $tzTo, \Magento\Framework\DB\Adapter\AdapterInterface::INTERVAL_HOUR);
     return str_replace('{{attribute}}', $periodExpr, $expression);
 }
开发者ID:shazal,项目名称:magento2,代码行数:21,代码来源:Collection.php

示例9: calculatePrice

 /**
  * Calculate product price based on special price data and price rules
  *
  * @param   float $basePrice
  * @param   float $specialPrice
  * @param   string $specialPriceFrom
  * @param   string $specialPriceTo
  * @param   bool|float|null $rulePrice
  * @param   mixed|null $wId
  * @param   integer|null $gId
  * @param   int|null $productId
  * @return  float
  */
 public function calculatePrice($basePrice, $specialPrice, $specialPriceFrom, $specialPriceTo, $rulePrice = false, $wId = null, $gId = null, $productId = null)
 {
     \Magento\Framework\Profiler::start('__PRODUCT_CALCULATE_PRICE__');
     if ($wId instanceof Store) {
         $sId = $wId->getId();
         $wId = $wId->getWebsiteId();
     } else {
         $sId = $this->_storeManager->getWebsite($wId)->getDefaultGroup()->getDefaultStoreId();
     }
     $finalPrice = $basePrice;
     $finalPrice = $this->calculateSpecialPrice($finalPrice, $specialPrice, $specialPriceFrom, $specialPriceTo, $sId);
     if ($rulePrice === false) {
         $date = $this->_localeDate->scopeDate($sId);
         $rulePrice = $this->_ruleFactory->create()->getRulePrice($date, $wId, $gId, $productId);
     }
     if ($rulePrice !== null && $rulePrice !== false) {
         $finalPrice = min($finalPrice, $rulePrice);
     }
     $finalPrice = max($finalPrice, 0);
     \Magento\Framework\Profiler::stop('__PRODUCT_CALCULATE_PRICE__');
     return $finalPrice;
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:35,代码来源:Price.php

示例10: _getUpdatedAt

 /**
  * Get if updated
  *
  * @param string $reportCode
  * @return string|\Magento\Framework\Stdlib\DateTime\DateInterface
  */
 protected function _getUpdatedAt($reportCode)
 {
     $flag = $this->_reportsFlagFactory->create()->setReportFlagCode($reportCode)->loadSelf();
     return $flag->hasData() ? $this->_localeDate->scopeDate(0, new \Magento\Framework\Stdlib\DateTime\Date($flag->getLastUpdate(), \Magento\Framework\Stdlib\DateTime::DATETIME_INTERNAL_FORMAT), true) : '';
 }
开发者ID:aiesh,项目名称:magento2,代码行数:11,代码来源:Collection.php

示例11: _getUpdatedAt

 /**
  * Get if updated
  *
  * @param string $reportCode
  * @return string|\DateTime
  */
 protected function _getUpdatedAt($reportCode)
 {
     $flag = $this->_reportsFlagFactory->create()->setReportFlagCode($reportCode)->loadSelf();
     return $flag->hasData() ? $this->_localeDate->scopeDate(0, $flag->getLastUpdate(), true) : '';
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:11,代码来源:Collection.php

示例12: insertOrder

 /**
  * Insert order to pdf page
  *
  * @param \Zend_Pdf_Page &$page
  * @param \Magento\Sales\Model\Order $obj
  * @param bool $putOrderId
  * @return void
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function insertOrder(&$page, $obj, $putOrderId = true)
 {
     if ($obj instanceof \Magento\Sales\Model\Order) {
         $shipment = null;
         $order = $obj;
     } elseif ($obj instanceof \Magento\Sales\Model\Order\Shipment) {
         $shipment = $obj;
         $order = $shipment->getOrder();
     }
     $this->y = $this->y ? $this->y : 815;
     $top = $this->y;
     $page->setFillColor(new \Zend_Pdf_Color_GrayScale(0.45));
     $page->setLineColor(new \Zend_Pdf_Color_GrayScale(0.45));
     $page->drawRectangle(25, $top, 570, $top - 55);
     $page->setFillColor(new \Zend_Pdf_Color_GrayScale(1));
     $this->setDocHeaderCoordinates([25, $top, 570, $top - 55]);
     $this->_setFontRegular($page, 10);
     if ($putOrderId) {
         $page->drawText(__('Order # ') . $order->getRealOrderId(), 35, $top -= 30, 'UTF-8');
     }
     $page->drawText(__('Order Date: ') . $this->_localeDate->formatDate($this->_localeDate->scopeDate($order->getStore(), $order->getCreatedAt(), true), \IntlDateFormatter::MEDIUM, false), 35, $top -= 15, 'UTF-8');
     $top -= 10;
     $page->setFillColor(new \Zend_Pdf_Color_Rgb(0.93, 0.92, 0.92));
     $page->setLineColor(new \Zend_Pdf_Color_GrayScale(0.5));
     $page->setLineWidth(0.5);
     $page->drawRectangle(25, $top, 275, $top - 25);
     $page->drawRectangle(275, $top, 570, $top - 25);
     /* Calculate blocks info */
     /* Billing Address */
     $billingAddress = $this->_formatAddress($this->addressRenderer->format($order->getBillingAddress(), 'pdf'));
     /* Payment */
     $paymentInfo = $this->_paymentData->getInfoBlock($order->getPayment())->setIsSecureMode(true)->toPdf();
     $paymentInfo = htmlspecialchars_decode($paymentInfo, ENT_QUOTES);
     $payment = explode('{{pdf_row_separator}}', $paymentInfo);
     foreach ($payment as $key => $value) {
         if (strip_tags(trim($value)) == '') {
             unset($payment[$key]);
         }
     }
     reset($payment);
     /* Shipping Address and Method */
     if (!$order->getIsVirtual()) {
         /* Shipping Address */
         $shippingAddress = $this->_formatAddress($this->addressRenderer->format($order->getShippingAddress(), 'pdf'));
         $shippingMethod = $order->getShippingDescription();
     }
     $page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
     $this->_setFontBold($page, 12);
     $page->drawText(__('Sold to:'), 35, $top - 15, 'UTF-8');
     if (!$order->getIsVirtual()) {
         $page->drawText(__('Ship to:'), 285, $top - 15, 'UTF-8');
     } else {
         $page->drawText(__('Payment Method:'), 285, $top - 15, 'UTF-8');
     }
     $addressesHeight = $this->_calcAddressHeight($billingAddress);
     if (isset($shippingAddress)) {
         $addressesHeight = max($addressesHeight, $this->_calcAddressHeight($shippingAddress));
     }
     $page->setFillColor(new \Zend_Pdf_Color_GrayScale(1));
     $page->drawRectangle(25, $top - 25, 570, $top - 33 - $addressesHeight);
     $page->setFillColor(new \Zend_Pdf_Color_GrayScale(0));
     $this->_setFontRegular($page, 10);
     $this->y = $top - 40;
     $addressesStartY = $this->y;
     foreach ($billingAddress as $value) {
         if ($value !== '') {
             $text = [];
             foreach ($this->string->split($value, 45, true, true) as $_value) {
                 $text[] = $_value;
             }
             foreach ($text as $part) {
                 $page->drawText(strip_tags(ltrim($part)), 35, $this->y, 'UTF-8');
                 $this->y -= 15;
             }
         }
     }
     $addressesEndY = $this->y;
     if (!$order->getIsVirtual()) {
         $this->y = $addressesStartY;
         foreach ($shippingAddress as $value) {
             if ($value !== '') {
                 $text = [];
                 foreach ($this->string->split($value, 45, true, true) as $_value) {
                     $text[] = $_value;
                 }
                 foreach ($text as $part) {
                     $page->drawText(strip_tags(ltrim($part)), 285, $this->y, 'UTF-8');
                     $this->y -= 15;
                 }
//.........这里部分代码省略.........
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:101,代码来源:AbstractPdf.php

示例13: _getStoreTimezoneUtcOffset

 /**
  * Retrieve store timezone offset from UTC in the form acceptable by SQL's CONVERT_TZ()
  *
  * @param null|mixed $store
  * @return string
  */
 protected function _getStoreTimezoneUtcOffset($store = null)
 {
     return $this->_localeDate->scopeDate($store)->toString(\Zend_Date::GMT_DIFF_SEP);
 }
开发者ID:aiesh,项目名称:magento2,代码行数:10,代码来源:AbstractReport.php

示例14: timeShift

 /**
  * Retrieve time shift
  *
  * @param string $datetime
  * @return string
  */
 public function timeShift($datetime)
 {
     return $this->_localeDate->scopeDate(null, $datetime, true)->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d H:i:s');
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:Collection.php

示例15: _getStoreTimezoneUtcOffset

 /**
  * Retrieve store timezone offset from UTC in the form acceptable by SQL's CONVERT_TZ()
  *
  * @param null|mixed $store
  * @return string
  */
 protected function _getStoreTimezoneUtcOffset($store = null)
 {
     return $this->_localeDate->scopeDate($store)->format('P');
 }
开发者ID:shabbirvividads,项目名称:magento2,代码行数:10,代码来源:AbstractReport.php


注:本文中的Magento\Framework\Stdlib\DateTime\TimezoneInterface::scopeDate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。