예제 #1
0
 /**
  * Get date value as string.
  * Format can be specified, or it will be taken from $this->getFormat()
  *
  * @param string $format (compatible with \Magento\Framework\Stdlib\DateTime\Date
  * @return string
  */
 public function getValue($format = null)
 {
     if (empty($this->_value)) {
         return '';
     }
     if (null === $format) {
         $format = $this->getDateFormat();
         $format .= $format && $this->getTimeFormat() ? ' ' : '';
         $format .= $this->getTimeFormat() ? $this->getTimeFormat() : '';
     }
     return $this->_value->toString($format);
 }
예제 #2
0
파일: Special.php 프로젝트: aiesh/magento2
 /**
  * Preparing data and adding to rss object
  *
  * @param array $args
  * @return void
  */
 public function addSpecialXmlCallback($args)
 {
     if (!isset(self::$_currentDate)) {
         self::$_currentDate = new \Magento\Framework\Stdlib\DateTime\Date();
     }
     // dispatch event to determine whether the product will eventually get to the result
     $product = new \Magento\Framework\Object(array('allowed_in_rss' => true, 'allowed_price_in_rss' => true));
     $args['product'] = $product;
     $this->_eventManager->dispatch('rss_catalog_special_xml_callback', $args);
     if (!$product->getAllowedInRss()) {
         return;
     }
     // add row to result and determine whether special price is active (less or equal to the final price)
     $row = $args['row'];
     $row['use_special'] = false;
     $row['allowed_price_in_rss'] = $product->getAllowedPriceInRss();
     if (isset($row['special_to_date']) && $row['final_price'] <= $row['special_price'] && $row['allowed_price_in_rss']) {
         $compareDate = self::$_currentDate->compareDate($row['special_to_date'], \Magento\Framework\Stdlib\DateTime::DATE_INTERNAL_FORMAT);
         if (-1 === $compareDate || 0 === $compareDate) {
             $row['use_special'] = true;
         }
     }
     $args['results'][] = $row;
 }