コード例 #1
0
 public function testBuildDimensionWithDefaultScope()
 {
     $name = 'scope';
     $value = \Magento\Framework\App\ScopeInterface::SCOPE_DEFAULT;
     $scopeId = -123456;
     $this->dimension->expects($this->once())->method('getName')->will($this->returnValue($name));
     $this->dimension->expects($this->once())->method('getValue')->will($this->returnValue($value));
     $this->scope->expects($this->once())->method('getId')->will($this->returnValue($scopeId));
     $this->scopeResolver->expects($this->once())->method('getScope')->with($value)->will($this->returnValue($this->scope));
     $query = $this->builder->build($this->dimension);
     $this->assertEquals(sprintf('`%s` = `%s`', \Magento\Framework\Search\Adapter\Mysql\Dimensions::STORE_FIELD_NAME, $scopeId), $query);
 }
コード例 #2
0
 private function createMatchQuery()
 {
     $this->request->expects($this->once())->method('getDimensions')->will($this->returnValue([$this->createDimension()]));
     $this->dimensionsBuilder->expects($this->once())->method('build')->will($this->returnValue('a = b'));
     $query = $this->getMockBuilder('Magento\\Framework\\Search\\Request\\Query\\Match')->setMethods(['getType'])->disableOriginalConstructor()->getMockForAbstractClass();
     $query->expects($this->once())->method('getType')->will($this->returnValue(QueryInterface::TYPE_MATCH));
     return $query;
 }
コード例 #3
0
ファイル: Mapper.php プロジェクト: shabbirvividads/magento2
 /**
  * Add filtering by dimensions
  *
  * @param RequestInterface $request
  * @param Select $select
  * @return \Magento\Framework\DB\Select
  */
 private function processDimensions(RequestInterface $request, Select $select)
 {
     $dimensions = [];
     foreach ($request->getDimensions() as $dimension) {
         $dimensions[] = $this->dimensionsBuilder->build($dimension);
     }
     $query = $this->conditionManager->combineQueries($dimensions, Select::SQL_OR);
     if (!empty($query)) {
         $select->where($this->conditionManager->wrapBrackets($query));
     }
     return $select;
 }
コード例 #4
0
ファイル: Mapper.php プロジェクト: pavelnovitsky/magento2
 /**
  * Add filtering by dimensions
  *
  * @param RequestInterface $request
  * @param Select $select
  * @return \Magento\Framework\DB\Select
  */
 private function processDimensions(RequestInterface $request, Select $select)
 {
     $dimensions = [];
     foreach ($request->getDimensions() as $dimension) {
         $dimensions[] = $this->dimensionsBuilder->build($dimension);
     }
     if (!empty($dimensions)) {
         $query = sprintf('(%s)', implode(' ' . Select::SQL_OR . ' ', $dimensions));
         $select->where($query);
     }
     return $select;
 }