本文整理汇总了PHP中Magento\Framework\App\ScopeResolverInterface类的典型用法代码示例。如果您正苦于以下问题:PHP ScopeResolverInterface类的具体用法?PHP ScopeResolverInterface怎么用?PHP ScopeResolverInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ScopeResolverInterface类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
$objectManagerHelper = new ObjectManagerHelper($this);
$this->conditionManager = $this->getMockBuilder('\\Magento\\Framework\\Search\\Adapter\\Mysql\\ConditionManager')->disableOriginalConstructor()->setMethods(['wrapBrackets'])->getMock();
$this->scopeResolver = $this->getMockBuilder('\\Magento\\Framework\\App\\ScopeResolverInterface')->disableOriginalConstructor()->setMethods(['getScope'])->getMockForAbstractClass();
$this->scope = $this->getMockBuilder('\\Magento\\Framework\\App\\ScopeInterface')->disableOriginalConstructor()->setMethods(['getId'])->getMockForAbstractClass();
$this->scopeResolver->expects($this->any())->method('getScope')->will($this->returnValue($this->scope));
$this->config = $this->getMockBuilder('\\Magento\\Eav\\Model\\Config')->disableOriginalConstructor()->setMethods(['getAttribute'])->getMock();
$this->attribute = $this->getMockBuilder('\\Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute')->disableOriginalConstructor()->setMethods(['getBackendTable', 'isStatic', 'getAttributeId', 'getAttributeCode', 'getFrontendInput'])->getMockForAbstractClass();
$this->resource = $resource = $this->getMockBuilder('\\Magento\\Framework\\App\\ResourceConnection')->disableOriginalConstructor()->setMethods(['getConnection', 'getTableName'])->getMock();
$this->connection = $this->getMockBuilder('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface')->disableOriginalConstructor()->setMethods(['select', 'getIfNullSql', 'quote'])->getMockForAbstractClass();
$this->select = $this->getMockBuilder('\\Magento\\Framework\\DB\\Select')->disableOriginalConstructor()->setMethods(['from', 'join', 'where', '__toString', 'joinLeft', 'columns', 'having'])->getMock();
$this->connection->expects($this->any())->method('select')->will($this->returnValue($this->select));
$this->connection->expects($this->any())->method('quoteIdentifier')->will($this->returnArgument(0));
$resource->expects($this->atLeastOnce())->method('getConnection')->will($this->returnValue($this->connection));
$this->filter = $this->getMockBuilder('\\Magento\\Framework\\Search\\Request\\FilterInterface')->disableOriginalConstructor()->setMethods(['getField', 'getValue', 'getType'])->getMockForAbstractClass();
$this->conditionManager->expects($this->any())->method('wrapBrackets')->with($this->select)->will($this->returnCallback(function ($select) {
return '(' . $select . ')';
}));
$this->tableMapper = $this->getMockBuilder('\\Magento\\CatalogSearch\\Model\\Search\\TableMapper')->disableOriginalConstructor()->getMock();
$this->metadataPoolMock = $this->getMockBuilder(\Magento\Framework\Model\Entity\MetadataPool::class)->disableOriginalConstructor()->getMock();
$metadata = $this->getMockBuilder(EntityMetadata::class)->disableOriginalConstructor()->getMock();
$this->metadataPoolMock->expects($this->any())->method('getMetadata')->willReturn($metadata);
$metadata->expects($this->any())->method('getLinkField')->willReturn('entity_id');
$this->target = $objectManagerHelper->getObject('Magento\\CatalogSearch\\Model\\Adapter\\Mysql\\Filter\\Preprocessor', ['conditionManager' => $this->conditionManager, 'scopeResolver' => $this->scopeResolver, 'config' => $this->config, 'resource' => $resource, 'attributePrefix' => 'attr_', 'metadataPool' => $this->metadataPoolMock, 'tableMapper' => $this->tableMapper]);
}
开发者ID:dragonsword007008,项目名称:magento2,代码行数:26,代码来源:PreprocessorTest.php
示例2: setUp
protected function setUp()
{
$objectManagerHelper = new ObjectManagerHelper($this);
$this->conditionManager = $this->getMockBuilder('\\Magento\\Framework\\Search\\Adapter\\Mysql\\ConditionManager')->disableOriginalConstructor()->setMethods(['wrapBrackets'])->getMock();
$this->scopeResolver = $this->getMockBuilder('\\Magento\\Framework\\App\\ScopeResolverInterface')->disableOriginalConstructor()->setMethods(['getScope'])->getMockForAbstractClass();
$this->scope = $this->getMockBuilder('\\Magento\\Framework\\App\\ScopeInterface')->disableOriginalConstructor()->setMethods(['getId'])->getMockForAbstractClass();
$this->scopeResolver->expects($this->once())->method('getScope')->will($this->returnValue($this->scope));
$this->config = $this->getMockBuilder('\\Magento\\Eav\\Model\\Config')->disableOriginalConstructor()->setMethods(['getAttribute'])->getMock();
$this->attribute = $this->getMockBuilder('\\Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute')->disableOriginalConstructor()->setMethods(['getBackendTable', 'isStatic', 'getAttributeId'])->getMockForAbstractClass();
$this->resource = $resource = $this->getMockBuilder('\\Magento\\Framework\\App\\Resource')->disableOriginalConstructor()->setMethods(['getConnection', 'getTableName'])->getMock();
$this->connection = $this->getMockBuilder('\\Magento\\Framework\\DB\\Adapter\\AdapterInterface')->disableOriginalConstructor()->setMethods(['select', 'getIfNullSql'])->getMockForAbstractClass();
$this->select = $this->getMockBuilder('\\Magento\\Framework\\DB\\Select')->disableOriginalConstructor()->setMethods(['from', 'where', '__toString', 'joinLeft', 'columns', 'having'])->getMock();
$this->connection->expects($this->once())->method('select')->will($this->returnValue($this->select));
$resource->expects($this->atLeastOnce())->method('getConnection')->with(\Magento\Framework\App\Resource::DEFAULT_READ_RESOURCE)->will($this->returnValue($this->connection));
$this->filter = $this->getMockBuilder('\\Magento\\Framework\\Search\\Request\\FilterInterface')->disableOriginalConstructor()->setMethods(['getField', 'getValue'])->getMockForAbstractClass();
$this->conditionManager->expects($this->any())->method('wrapBrackets')->with($this->select)->will($this->returnCallback(function ($select) {
return '(' . $select . ')';
}));
$this->target = $objectManagerHelper->getObject('Magento\\CatalogSearch\\Model\\Adapter\\Mysql\\Filter\\Preprocessor', ['conditionManager' => $this->conditionManager, 'scopeResolver' => $this->scopeResolver, 'config' => $this->config, 'resource' => $resource, 'attributePrefix' => 'attr_']);
}
开发者ID:nja78,项目名称:magento2,代码行数:20,代码来源:PreprocessorTest.php
示例3: processQueryWithField
/**
* @param FilterInterface $filter
* @param bool $isNegation
* @param string $query
* @param QueryContainer $queryContainer
* @return string
*/
private function processQueryWithField(FilterInterface $filter, $isNegation, $query, QueryContainer $queryContainer)
{
$currentStoreId = $this->scopeResolver->getScope()->getId();
$attribute = $this->config->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $filter->getField());
$select = $this->getConnection()->select();
$table = $attribute->getBackendTable();
if ($filter->getField() == 'price') {
$query = str_replace('price', 'min_price', $query);
$select->from(['main_table' => $this->resource->getTableName('catalog_product_index_price')], 'entity_id')->where($query);
} elseif ($filter->getField() == 'category_ids') {
return 'category_index.category_id = ' . $filter->getValue();
} else {
if ($attribute->isStatic()) {
$select->from(['main_table' => $table], 'entity_id')->where($query);
} else {
if ($filter->getType() == FilterInterface::TYPE_TERM) {
if (is_array($filter->getValue())) {
$value = sprintf('%s IN (%s)', $isNegation ? 'NOT' : '', implode(',', $filter->getValue()));
} else {
$value = ($isNegation ? '!' : '') . '= ' . $filter->getValue();
}
$filterQuery = sprintf('cpie.store_id = %d AND cpie.attribute_id = %d AND cpie.value %s', $this->scopeResolver->getScope()->getId(), $attribute->getId(), $value);
$queryContainer->addFilter($filterQuery);
return '';
}
$ifNullCondition = $this->getConnection()->getIfNullSql('current_store.value', 'main_table.value');
$select->from(['main_table' => $table], 'entity_id')->joinLeft(['current_store' => $table], 'current_store.attribute_id = main_table.attribute_id AND current_store.store_id = ' . $currentStoreId, null)->columns([$filter->getField() => $ifNullCondition])->where('main_table.attribute_id = ?', $attribute->getAttributeId())->where('main_table.store_id = ?', \Magento\Store\Model\Store::DEFAULT_STORE_ID)->having($query);
}
}
return 'search_index.entity_id IN (
select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter
)';
}
开发者ID:nja78,项目名称:magento2,代码行数:40,代码来源:Preprocessor.php
示例4: testSearch
public function testSearch()
{
$requestName = 'requestName';
$scopeId = 333;
$filters = [$this->createFilterMock('array_filter', ['arrayValue1', 'arrayValue2']), $this->createFilterMock('simple_filter', 'filterValue'), $this->createFilterMock('from_filter', ['from' => 30]), $this->createFilterMock('to_filter', ['to' => 100]), $this->createFilterMock('range_filter', ['from' => 60, 'to' => 82])];
$scope = $this->getMockBuilder('Magento\\Framework\\App\\ScopeInterface')->disableOriginalConstructor()->getMockForAbstractClass();
$filterGroup = $this->getMockBuilder('Magento\\Framework\\Api\\Search\\FilterGroup')->disableOriginalConstructor()->getMock();
$filterGroup->expects($this->once())->method('getFilters')->willReturn($filters);
$searchCriteria = $this->getMockBuilder('Magento\\Framework\\Api\\Search\\SearchCriteriaInterface')->disableOriginalConstructor()->getMockForAbstractClass();
$searchCriteria->expects($this->once())->method('getRequestName')->willReturn($requestName);
$searchCriteria->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroup]);
$searchResult = $this->getMockBuilder('Magento\\Framework\\Api\\Search\\SearchResult')->disableOriginalConstructor()->getMockForAbstractClass();
$request = $this->getMockBuilder('Magento\\Framework\\Search\\RequestInterface')->disableOriginalConstructor()->getMockForAbstractClass();
$response = $this->getMockBuilder('Magento\\Framework\\Search\\ResponseInterface')->disableOriginalConstructor()->getMockForAbstractClass();
$this->requestBuilder->expects($this->once())->method('setRequestName')->with($requestName);
$this->requestBuilder->expects($this->once())->method('bindDimension')->with('scope', $scopeId);
$this->requestBuilder->expects($this->exactly(6))->method('bind');
$this->requestBuilder->expects($this->once())->method('create')->willReturn($request);
$this->searchEngine->expects($this->once())->method('search')->with($request)->willReturn($response);
$this->searchResponseBuilder->expects($this->once())->method('build')->with($response)->willReturn($searchResult);
$this->scopeResolver->expects($this->once())->method('getScope')->willReturn($scope);
$scope->expects($this->once())->method('getId')->willReturn($scopeId);
$searchResult = $this->model->search($searchCriteria);
$this->assertInstanceOf('Magento\\Framework\\Api\\Search\\SearchResultInterface', $searchResult);
}
开发者ID:Doability,项目名称:magento2dev,代码行数:25,代码来源:SearchTest.php
示例5: testSearch
public function testSearch()
{
$requestName = 'requestName';
$scope = 333;
$filterField = 'filterField';
$filterValue = 'filterValue';
$filter = $this->getMockBuilder('Magento\\Framework\\Api\\Filter')->disableOriginalConstructor()->getMock();
$filter->expects($this->once())->method('getField')->willReturn($filterField);
$filter->expects($this->once())->method('getValue')->willReturn($filterValue);
$filterGroup = $this->getMockBuilder('Magento\\Framework\\Api\\Search\\FilterGroup')->disableOriginalConstructor()->getMock();
$filterGroup->expects($this->once())->method('getFilters')->willReturn([$filter]);
$searchCriteria = $this->getMockBuilder('Magento\\Framework\\Api\\Search\\SearchCriteriaInterface')->disableOriginalConstructor()->getMockForAbstractClass();
$searchCriteria->expects($this->once())->method('getRequestName')->willReturn($requestName);
$searchCriteria->expects($this->once())->method('getFilterGroups')->willReturn([$filterGroup]);
$searchResult = $this->getMockBuilder('Magento\\Framework\\Api\\Search\\SearchResult')->disableOriginalConstructor()->getMockForAbstractClass();
$request = $this->getMockBuilder('Magento\\Framework\\Search\\RequestInterface')->disableOriginalConstructor()->getMockForAbstractClass();
$response = $this->getMockBuilder('Magento\\Framework\\Search\\ResponseInterface')->disableOriginalConstructor()->getMockForAbstractClass();
$this->requestBuilder->expects($this->once())->method('setRequestName')->with($requestName);
$this->requestBuilder->expects($this->once())->method('bindDimension')->with('scope', $scope);
$this->requestBuilder->expects($this->any())->method('bind');
$this->requestBuilder->expects($this->once())->method('create')->willReturn($request);
$this->searchEngine->expects($this->once())->method('search')->with($request)->willReturn($response);
$this->searchResponseBuilder->expects($this->once())->method('build')->with($response)->willReturn($searchResult);
$this->scopeResolver->expects($this->once())->method('getScope')->willReturn($scope);
$searchResult = $this->model->search($searchCriteria);
$this->assertInstanceOf('Magento\\Framework\\Api\\Search\\SearchResultInterface', $searchResult);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:27,代码来源:SearchTest.php
示例6: processQueryWithField
/**
* @param FilterInterface $filter
* @param bool $isNegation
* @param string $query
* @return string
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
private function processQueryWithField(FilterInterface $filter, $isNegation, $query)
{
$currentStoreId = $this->scopeResolver->getScope()->getId();
$attribute = $this->config->getAttribute(\Magento\Catalog\Model\Product::ENTITY, $filter->getField());
$select = $this->getSelect();
$table = $attribute->getBackendTable();
if ($filter->getField() == 'price') {
$query = str_replace('price', 'min_price', $query);
$select->from(['main_table' => $this->resource->getTableName('catalog_product_index_price')], 'entity_id')->where($query);
} elseif ($filter->getField() == 'category_ids') {
return 'category_index.category_id = ' . $filter->getValue();
} else {
if ($attribute->isStatic()) {
$select->from(['main_table' => $table], 'entity_id')->where($query);
} else {
if ($filter->getType() == FilterInterface::TYPE_TERM) {
$field = $filter->getField();
$mapper = function ($value) use($field, $isNegation) {
return ($isNegation ? '-' : '') . $this->attributePrefix . $field . '_' . $value;
};
if (is_array($filter->getValue())) {
$value = implode(' ', array_map($mapper, $filter->getValue()));
} else {
$value = $mapper($filter->getValue());
}
return 'MATCH (data_index) AGAINST (' . $this->getConnection()->quote($value) . ' IN BOOLEAN MODE)';
}
$ifNullCondition = $this->getConnection()->getIfNullSql('current_store.value', 'main_table.value');
$select->from(['main_table' => $table], 'entity_id')->joinLeft(['current_store' => $table], 'current_store.attribute_id = main_table.attribute_id AND current_store.store_id = ' . $currentStoreId, null)->columns([$filter->getField() => $ifNullCondition])->where('main_table.attribute_id = ?', $attribute->getAttributeId())->where('main_table.store_id = ?', \Magento\Store\Model\Store::DEFAULT_STORE_ID)->having($query);
}
}
return 'search_index.product_id IN (
select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter
)';
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:42,代码来源:Preprocessor.php
示例7: getScopeId
/**
* Get scope id by code
*
* @param Dimension $dimension
* @return int
*/
private function getScopeId($dimension)
{
if (is_numeric($dimension->getValue())) {
return $dimension->getValue();
} else {
return $this->scopeResolver->getScope($dimension->getValue())->getId();
}
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:14,代码来源:IndexScopeResolver.php
示例8: generateExpression
/**
* @param Dimension $dimension
* @param AdapterInterface $adapter
* @return string
*/
private function generateExpression(Dimension $dimension, AdapterInterface $adapter)
{
$identifier = $dimension->getName();
$value = $dimension->getValue();
if (self::DEFAULT_DIMENSION_NAME === $identifier) {
$identifier = self::STORE_FIELD_NAME;
$value = $this->scopeResolver->getScope($value)->getId();
}
return sprintf('%s = %s', $adapter->quoteIdentifier($identifier), $adapter->quote($value));
}
开发者ID:pavelnovitsky,项目名称:magento2,代码行数:15,代码来源:Dimensions.php
示例9: generateExpression
/**
* @param Dimension $dimension
* @return string
*/
private function generateExpression(Dimension $dimension)
{
$field = $dimension->getName();
$value = $dimension->getValue();
if ('scope' === $field) {
$field = self::STORE_FIELD_NAME;
$value = $this->scopeResolver->getScope($value)->getId();
}
return $this->conditionManager->generateCondition('search_index.' . $field, '=', $value);
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:14,代码来源:Dimensions.php
示例10: testResolve
/**
* @param string $indexName
* @param Dimension[] $dimensions
* @param string $expected
* @dataProvider resolveDataProvider
*/
public function testResolve($indexName, array $dimensions, $expected)
{
$dimensions = array_map(function ($demension) {
return $this->createDimension($demension[0], $demension[1]);
}, $dimensions);
$scope = $this->getMockBuilder('Magento\\Framework\\App\\ScopeInterface')->disableOriginalConstructor()->getMockForAbstractClass();
$scope->expects($this->any())->method('getId')->willReturn(1);
$this->resource->expects($this->once())->method('getTableName')->willReturnArgument(0);
$this->scopeResolver->expects($this->any())->method('getScope')->willReturn($scope);
$result = $this->target->resolve($indexName, $dimensions);
$this->assertEquals($expected, $result);
}
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:18,代码来源:IndexScopeResolverTest.php
示例11: testBuildDimensionWithDefaultScope
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);
}
开发者ID:buskamuza,项目名称:magento2-skeleton,代码行数:12,代码来源:DimensionsTest.php
示例12: getPriceFormat
/**
* Functions returns array with price formatting info
*
* @return array
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
public function getPriceFormat()
{
$localeData = (new DataBundle())->get($this->_localeResolver->getLocale());
$format = $localeData['NumberElements']['latn']['patterns']['currencyFormat'] ?: explode(';', $localeData['NumberPatterns'][1])[0];
$decimalSymbol = $localeData['NumberElements']['latn']['symbols']['decimal'] ?: $localeData['NumberElements'][0];
$groupSymbol = $localeData['NumberElements']['latn']['symbols']['group'] ?: $localeData['NumberElements'][1];
$pos = strpos($format, ';');
if ($pos !== false) {
$format = substr($format, 0, $pos);
}
$format = preg_replace("/[^0\\#\\.,]/", "", $format);
$totalPrecision = 0;
$decimalPoint = strpos($format, '.');
if ($decimalPoint !== false) {
$totalPrecision = strlen($format) - (strrpos($format, '.') + 1);
} else {
$decimalPoint = strlen($format);
}
$requiredPrecision = $totalPrecision;
$t = substr($format, $decimalPoint);
$pos = strpos($t, '#');
if ($pos !== false) {
$requiredPrecision = strlen($t) - $pos - $totalPrecision;
}
if (strrpos($format, ',') !== false) {
$group = $decimalPoint - strrpos($format, ',') - 1;
} else {
$group = strrpos($format, '.');
}
$integerRequired = strpos($format, '.') - strpos($format, '0');
$result = ['pattern' => $this->_scopeResolver->getScope()->getCurrentCurrency()->getOutputFormat(), 'precision' => $totalPrecision, 'requiredPrecision' => $requiredPrecision, 'decimalSymbol' => $decimalSymbol, 'groupSymbol' => $groupSymbol, 'groupLength' => $group, 'integerRequired' => $integerRequired];
return $result;
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:39,代码来源:Format.php
示例13: processQueryWithField
/**
* @param FilterInterface $filter
* @param bool $isNegation
* @param string $query
* @return string
*/
private function processQueryWithField(FilterInterface $filter, $isNegation, $query)
{
/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */
$attribute = $this->config->getAttribute(Product::ENTITY, $filter->getField());
if ($filter->getField() === 'price') {
$resultQuery = str_replace($this->connection->quoteIdentifier('price'), $this->connection->quoteIdentifier('price_index.min_price'), $query);
} elseif ($filter->getField() === 'category_ids') {
return 'category_ids_index.category_id = ' . $filter->getValue();
} elseif ($attribute->isStatic()) {
$alias = $this->tableMapper->getMappingAlias($filter);
$resultQuery = str_replace($this->connection->quoteIdentifier($attribute->getAttributeCode()), $this->connection->quoteIdentifier($alias . '.' . $attribute->getAttributeCode()), $query);
} elseif ($filter->getType() === FilterInterface::TYPE_TERM && in_array($attribute->getFrontendInput(), ['select', 'multiselect'], true)) {
$alias = $this->tableMapper->getMappingAlias($filter);
if (is_array($filter->getValue())) {
$value = sprintf('%s IN (%s)', $isNegation ? 'NOT' : '', implode(',', $filter->getValue()));
} else {
$value = ($isNegation ? '!' : '') . '= ' . $filter->getValue();
}
$resultQuery = sprintf('%1$s.value %2$s', $alias, $value);
} else {
$table = $attribute->getBackendTable();
$select = $this->connection->select();
$ifNullCondition = $this->connection->getIfNullSql('current_store.value', 'main_table.value');
$currentStoreId = $this->scopeResolver->getScope()->getId();
$select->from(['main_table' => $table], 'entity_id')->joinLeft(['current_store' => $table], 'current_store.attribute_id = main_table.attribute_id AND current_store.store_id = ' . $currentStoreId, null)->columns([$filter->getField() => $ifNullCondition])->where('main_table.attribute_id = ?', $attribute->getAttributeId())->where('main_table.store_id = ?', Store::DEFAULT_STORE_ID)->having($query);
$resultQuery = 'search_index.entity_id IN (
select entity_id from ' . $this->conditionManager->wrapBrackets($select) . ' as filter
)';
}
return $resultQuery;
}
开发者ID:whoople,项目名称:magento2-testing,代码行数:37,代码来源:Preprocessor.php
示例14: search
/**
* {@inheritdoc}
*/
public function search(SearchCriteriaInterface $searchCriteria)
{
$this->requestBuilder->setRequestName($searchCriteria->getRequestName());
$scope = $this->scopeResolver->getScope();
$this->requestBuilder->bindDimension('scope', $scope);
foreach ($searchCriteria->getFilterGroups() as $filterGroup) {
foreach ($filterGroup->getFilters() as $filter) {
$this->addFieldToFilter($filter->getField(), $filter->getValue());
}
}
$this->requestBuilder->setFrom($searchCriteria->getCurrentPage() * $searchCriteria->getPageSize());
$this->requestBuilder->setSize($searchCriteria->getPageSize());
$request = $this->requestBuilder->create();
$searchResponse = $this->searchEngine->search($request);
return $this->searchResponseBuilder->build($searchResponse)->setSearchCriteria($searchCriteria);
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:19,代码来源:Search.php
示例15: prepareIsAllowed
/**
* @param bool $isEnabled
* @param bool $isActive
* @param bool $isDevAllowed
* @param null|string $scope
*/
protected function prepareIsAllowed($isEnabled, $isActive, $isDevAllowed, $scope = null)
{
$scopeMock = $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface', [], [], '', false);
$this->stateMock->expects($this->any())->method('isEnabled')->will($this->returnValue($isEnabled));
$this->scopeResolverMock->expects($this->once())->method('getScope')->with($scope)->will($this->returnValue($scopeMock));
$this->configMock->expects($this->once())->method('isActive')->with($scopeMock)->will($this->returnValue($isActive));
$this->configMock->expects($this->exactly((int) $isActive))->method('isDevAllowed')->will($this->returnValue($isDevAllowed));
}
开发者ID:pradeep-wagento,项目名称:magento2,代码行数:14,代码来源:InlineTest.php
示例16: aroundGetDataSet
/**
* @param \Magento\CatalogSearch\Model\Adapter\Mysql\Aggregation\DataProvider $subject
* @param callable $proceed
* @param BucketInterface $bucket
* @param Dimension[] $dimensions
*
* @return Select
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundGetDataSet(\Magento\CatalogSearch\Model\Adapter\Mysql\Aggregation\DataProvider $subject, \Closure $proceed, BucketInterface $bucket, array $dimensions)
{
if ($bucket->getField() == 'category_ids') {
$currentScope = $dimensions['scope']->getValue();
$currentScopeId = $this->scopeResolver->getScope($currentScope)->getId();
$currenCategory = $this->layer->getCurrentCategory();
$derivedTable = $this->getSelect();
$derivedTable->from(['main_table' => $this->resource->getTableName('catalog_category_product_index')], ['entity_id' => 'product_id', 'value' => 'category_id'])->where('main_table.store_id = ?', $currentScopeId);
if (!empty($currenCategory)) {
$derivedTable->join(['category' => $this->resource->getTableName('catalog_category_entity')], 'main_table.category_id = category.entity_id', [])->where('`category`.`path` LIKE ?', $currenCategory->getPath() . '%')->where('`category`.`level` > ?', $currenCategory->getLevel());
}
$select = $this->getSelect();
$select->from(['main_table' => $derivedTable]);
return $select;
}
return $proceed($bucket, $dimensions);
}
开发者ID:shabbirvividads,项目名称:magento2,代码行数:26,代码来源:DataProvider.php
示例17: expectsSetConfig
/**
* Declare calls expectation for setConfig() method
*/
protected function expectsSetConfig($themeId, $localeCode = 'en_US')
{
$this->locale->expects($this->any())->method('getLocaleCode')->will($this->returnValue($localeCode));
$scope = new \Magento\Framework\Object(['code' => 'frontendCode', 'id' => 1]);
$scopeAdmin = new \Magento\Framework\Object(['code' => 'adminCode', 'id' => 0]);
$this->scopeResolver->expects($this->any())->method('getScope')->will($this->returnValueMap([[null, $scope], ['admin', $scopeAdmin]]));
$designTheme = new \Magento\Framework\Object(['id' => $themeId]);
$this->viewDesign->expects($this->any())->method('getDesignTheme')->will($this->returnValue($designTheme));
}
开发者ID:ViniciusAugusto,项目名称:magento2,代码行数:12,代码来源:TranslateTest.php
示例18: detectDesign
/**
* Detect and apply design for the area
*
* @param \Magento\Framework\App\RequestInterface $request
* @return void
*/
public function detectDesign($request = null)
{
if ($this->_code == self::AREA_FRONTEND) {
$isDesignException = $request && $this->_applyUserAgentDesignException($request);
if (!$isDesignException) {
$this->_design->loadChange($this->_scopeResolver->getScope()->getId())->changeDesign($this->_getDesign());
}
}
}
开发者ID:IlyaGluschenko,项目名称:test001,代码行数:15,代码来源:Area.php
示例19: prepareDimensions
/**
* @param Dimension[] $dimensions
* @return string[]
*/
private function prepareDimensions(array $dimensions)
{
$preparedDimensions = [];
foreach ($dimensions as $dimension) {
if ('scope' === $dimension->getName()) {
continue;
}
$preparedDimensions[] = $this->conditionManager->generateCondition($dimension->getName(), '=', $this->dimensionScopeResolver->getScope($dimension->getValue())->getId());
}
return $preparedDimensions;
}
开发者ID:Doability,项目名称:magento2dev,代码行数:15,代码来源:IndexBuilder.php
示例20: getTaxRateIds
/**
* @param PriceBox $subject
* @return string
*/
private function getTaxRateIds(PriceBox $subject)
{
$rateIds = [];
$customerSession = $this->customerSession;
$billingAddress = $customerSession->getDefaultTaxBillingAddress();
$shippingAddress = $customerSession->getDefaultTaxShippingAddress();
$customerTaxClassId = $customerSession->getCustomerTaxClassId();
if (!empty($billingAddress)) {
$billingAddress = new \Magento\Framework\DataObject($billingAddress);
}
if (!empty($shippingAddress)) {
$shippingAddress = new \Magento\Framework\DataObject($shippingAddress);
}
if (!empty($billingAddress) || !empty($shippingAddress)) {
$rateRequest = $this->getTaxCalculation()->getRateRequest($billingAddress, $shippingAddress, $customerTaxClassId, $this->scopeResolver->getScope()->getId(), $this->customerSession->getCustomerId());
$rateRequest->setProductClassId($subject->getSaleableItem()->getTaxClassId());
$rateIds = $this->getTaxCalculation()->getResource()->getRateIds($rateRequest);
}
return implode('_', $rateIds);
}
开发者ID:Doability,项目名称:magento2dev,代码行数:24,代码来源:PriceBoxTags.php
注:本文中的Magento\Framework\App\ScopeResolverInterface类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论