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); }
/** * 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; }
/** * 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; }