コード例 #1
0
 /**
  * test ApplyDate
  */
 public function testApplyDate()
 {
     $className = '\\Magento\\Framework\\DB\\Select';
     /** @var \Magento\Framework\DB\Select|\PHPUnit_Framework_MockObject_MockObject $select */
     $select = $this->getMock($className, [], [], '', false);
     $select->expects($this->exactly(2))->method('where')->willReturnSelf();
     $now = date('Y-m-d');
     $this->model->applyDate($select, $now);
 }
コード例 #2
0
ファイル: Collection.php プロジェクト: rafaelstz/magento2
 /**
  * Filter collection by website(s), customer group(s) and date.
  * Filter collection to only active rules.
  * Sorting is not involved
  *
  * @param int $websiteId
  * @param int $customerGroupId
  * @param string|null $now
  * @use $this->addWebsiteFilter()
  * @return $this
  */
 public function addWebsiteGroupDateFilter($websiteId, $customerGroupId, $now = null)
 {
     if (!$this->getFlag('website_group_date_filter')) {
         if (is_null($now)) {
             $now = $this->_date->date()->format('Y-m-d');
         }
         $this->addWebsiteFilter($websiteId);
         $entityInfo = $this->_getAssociatedEntityInfo('customer_group');
         $connection = $this->getConnection();
         $this->getSelect()->joinInner(['customer_group_ids' => $this->getTable($entityInfo['associations_table'])], $connection->quoteInto('main_table.' . $entityInfo['rule_id_field'] . ' = customer_group_ids.' . $entityInfo['rule_id_field'] . ' AND customer_group_ids.' . $entityInfo['entity_id_field'] . ' = ?', (int) $customerGroupId), []);
         $this->dateApplier->applyDate($this->getSelect(), $now);
         $this->addIsActiveFilter();
         $this->setFlag('website_group_date_filter', true);
     }
     return $this;
 }