-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.4-develop' of https://github.com/mage-os/mirror-magento2
- Loading branch information
Showing
41 changed files
with
1,067 additions
and
78 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
app/code/Magento/Catalog/Api/ProductAttributeIsFilterableManagementInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/************************************************************************ | ||
* | ||
* ADOBE CONFIDENTIAL | ||
* ___________________ | ||
* | ||
* Copyright 2014 Adobe | ||
* All Rights Reserved. | ||
* | ||
* NOTICE: All information contained herein is, and remains | ||
* the property of Adobe and its suppliers, if any. The intellectual | ||
* and technical concepts contained herein are proprietary to Adobe | ||
* and its suppliers and are protected by all applicable intellectual | ||
* property laws, including trade secret and copyright laws. | ||
* Dissemination of this information or reproduction of this material | ||
* is strictly forbidden unless prior written permission is obtained | ||
* from Adobe. | ||
* ************************************************************************ | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Api; | ||
|
||
/** | ||
* Intended to allow setting 'is_filterable' property for specific attribute as integer value via REST/SOAP API | ||
* | ||
* @api | ||
*/ | ||
interface ProductAttributeIsFilterableManagementInterface | ||
{ | ||
/** | ||
* Retrieve 'is_filterable' property for specific attribute as integer | ||
* | ||
* @param string $attributeCode | ||
* @return int | ||
* @throws \Magento\Framework\Exception\NoSuchEntityException | ||
*/ | ||
public function get(string $attributeCode): int; | ||
|
||
/** | ||
* Set 'is_filterable' property for specific attribute as integer | ||
* | ||
* @param string $attributeCode | ||
* @param int $isFilterable | ||
* @return bool | ||
* @throws \Magento\Framework\Exception\NoSuchEntityException | ||
* @throws \Magento\Framework\Exception\InputException | ||
* @throws \Magento\Framework\Exception\StateException | ||
*/ | ||
public function set(string $attributeCode, int $isFilterable): bool; | ||
} |
64 changes: 64 additions & 0 deletions
64
app/code/Magento/Catalog/Model/Product/Attribute/IsFilterableManagement.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
/************************************************************************ | ||
* | ||
* ADOBE CONFIDENTIAL | ||
* ___________________ | ||
* | ||
* Copyright 2014 Adobe | ||
* All Rights Reserved. | ||
* | ||
* NOTICE: All information contained herein is, and remains | ||
* the property of Adobe and its suppliers, if any. The intellectual | ||
* and technical concepts contained herein are proprietary to Adobe | ||
* and its suppliers and are protected by all applicable intellectual | ||
* property laws, including trade secret and copyright laws. | ||
* Dissemination of this information or reproduction of this material | ||
* is strictly forbidden unless prior written permission is obtained | ||
* from Adobe. | ||
* ************************************************************************ | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\Catalog\Model\Product\Attribute; | ||
|
||
use Magento\Catalog\Api\ProductAttributeIsFilterableManagementInterface; | ||
use Magento\Catalog\Api\ProductAttributeRepositoryInterface; | ||
|
||
class IsFilterableManagement implements ProductAttributeIsFilterableManagementInterface | ||
{ | ||
/** | ||
* @var ProductAttributeRepositoryInterface | ||
*/ | ||
private ProductAttributeRepositoryInterface $productAttributeRepository; | ||
|
||
/** | ||
* @param ProductAttributeRepositoryInterface $productAttributeRepository | ||
*/ | ||
public function __construct( | ||
ProductAttributeRepositoryInterface $productAttributeRepository | ||
) { | ||
$this->productAttributeRepository = $productAttributeRepository; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function get(string $attributeCode): int | ||
{ | ||
$attribute = $this->productAttributeRepository->get($attributeCode); | ||
|
||
return (int)$attribute->getIsFilterable(); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function set(string $attributeCode, int $isFilterable): bool | ||
{ | ||
$attribute = $this->productAttributeRepository->get($attributeCode); | ||
$attribute->setIsFilterable($isFilterable); | ||
$this->productAttributeRepository->save($attribute); | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
app/code/Magento/CatalogCustomerGraphQl/Test/Unit/Model/Resolver/PriceTiersTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
<?php | ||
/************************************************************************ | ||
* | ||
* Copyright 2023 Adobe | ||
* All Rights Reserved. | ||
* | ||
* NOTICE: All information contained herein is, and remains | ||
* the property of Adobe and its suppliers, if any. The intellectual | ||
* and technical concepts contained herein are proprietary to Adobe | ||
* and its suppliers and are protected by all applicable intellectual | ||
* property laws, including trade secret and copyright laws. | ||
* Dissemination of this information or reproduction of this material | ||
* is strictly forbidden unless prior written permission is obtained | ||
* from Adobe. | ||
* ************************************************************************ | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\CatalogCustomerGraphQl\Test\Unit\Model\Resolver; | ||
|
||
use Magento\CatalogCustomerGraphQl\Model\Resolver\Customer\GetCustomerGroup; | ||
use Magento\CatalogCustomerGraphQl\Model\Resolver\PriceTiers; | ||
use Magento\CatalogCustomerGraphQl\Model\Resolver\Product\Price\Tiers; | ||
use Magento\CatalogCustomerGraphQl\Model\Resolver\Product\Price\TiersFactory; | ||
use Magento\CatalogGraphQl\Model\Resolver\Product\Price\Discount; | ||
use Magento\CatalogGraphQl\Model\Resolver\Product\Price\ProviderPool; | ||
use Magento\Directory\Model\PriceCurrency; | ||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Query\Resolver\ValueFactory; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
use Magento\GraphQl\Model\Query\Context; | ||
use PHPUnit\Framework\TestCase; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
|
||
/** | ||
* Test Resolver for PriceTiers | ||
*/ | ||
class PriceTiersTest extends TestCase | ||
{ | ||
/** | ||
* @var Field|MockObject | ||
*/ | ||
private $fieldMock; | ||
|
||
/** | ||
* @var ResolveInfo|MockObject | ||
*/ | ||
private $resolveInfoMock; | ||
|
||
/** | ||
* @var Context|MockObject | ||
*/ | ||
private $contextMock; | ||
|
||
/** | ||
* @var TiersFactory|MockObject | ||
*/ | ||
private $tiersFactory; | ||
|
||
/** | ||
* @var PriceTiers | ||
*/ | ||
private $priceTiers; | ||
|
||
protected function setUp(): void | ||
{ | ||
$valueFactory = $this->createMock(ValueFactory::class); | ||
$this->tiersFactory = $this->createMock(TiersFactory::class); | ||
$customerGroup = $this->createMock(GetCustomerGroup::class); | ||
$priceDiscount = $this->createMock(Discount::class); | ||
$providerPool = $this->createMock(ProviderPool::class); | ||
$priceCurrency = $this->createMock(PriceCurrency::class); | ||
$this->priceTiers = new PriceTiers( | ||
$valueFactory, | ||
$this->tiersFactory, | ||
$customerGroup, | ||
$priceDiscount, | ||
$providerPool, | ||
$priceCurrency | ||
); | ||
|
||
$this->fieldMock = $this->createMock(Field::class); | ||
$this->resolveInfoMock = $this->createMock(ResolveInfo::class); | ||
$this->contextMock = $this->createMock(Context::class); | ||
} | ||
|
||
public function testResolve() | ||
{ | ||
$tiers = $this->createMock(Tiers::class); | ||
$tiers->expects($this->once()) | ||
->method('addProductFilter') | ||
->willReturnSelf(); | ||
|
||
$this->tiersFactory->expects($this->once()) | ||
->method('create') | ||
->willReturn($tiers); | ||
|
||
$productMock = $this->createMock(\Magento\Catalog\Model\Product::class); | ||
$productMock->expects($this->never()) | ||
->method('getTierPrices'); | ||
|
||
$productMock->expects($this->once()) | ||
->method('getId') | ||
->willReturn(1); | ||
|
||
$valueMock = ['model' => $productMock]; | ||
|
||
$this->priceTiers->resolve($this->fieldMock, $this->contextMock, $this->resolveInfoMock, $valueMock); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.