Skip to content

Commit

Permalink
Merge branch '2.4-develop' of https://github.com/mage-os/mirror-magento2
Browse files Browse the repository at this point in the history
 into 2.4-develop
  • Loading branch information
mage-os-ci committed Nov 21, 2023
2 parents bdde41c + 6f5a25e commit b6cc3c5
Show file tree
Hide file tree
Showing 41 changed files with 1,067 additions and 78 deletions.
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;
}
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;
}
}
1 change: 1 addition & 0 deletions app/code/Magento/Catalog/etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<preference for="Magento\Catalog\Model\ProductLink\Data\ListCriteriaInterface" type="Magento\Catalog\Model\ProductLink\Data\ListCriteria" />
<preference for="Magento\Catalog\Api\CategoryListDeleteBySkuInterface" type="Magento\Catalog\Model\CategoryLinkRepository"/>
<preference for="Magento\Theme\CustomerData\MessagesProviderInterface" type="Magento\Catalog\Model\Theme\CustomerData\MessagesProvider"/>
<preference for="Magento\Catalog\Api\ProductAttributeIsFilterableManagementInterface" type="Magento\Catalog\Model\Product\Attribute\IsFilterableManagement" />
<type name="Magento\Customer\Model\ResourceModel\Visitor">
<plugin name="catalogLog" type="Magento\Catalog\Model\Plugin\Log" />
</type>
Expand Down
12 changes: 12 additions & 0 deletions app/code/Magento/Catalog/etc/webapi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@
<resource ref="Magento_Catalog::attributes_attributes" />
</resources>
</route>
<route url="/V1/products/attributes/:attributeCode/is-filterable" method="GET">
<service class="Magento\Catalog\Api\ProductAttributeIsFilterableManagementInterface" method="get"/>
<resources>
<resource ref="Magento_Catalog::attributes_attributes" />
</resources>
</route>
<route url="/V1/products/attributes" method="GET">
<service class="Magento\Catalog\Api\ProductAttributeRepositoryInterface" method="getList" />
<resources>
Expand Down Expand Up @@ -87,6 +93,12 @@
<resource ref="Magento_Catalog::attributes_attributes" />
</resources>
</route>
<route url="/V1/products/attributes/:attributeCode/is-filterable/:isFilterable" method="PUT">
<service class="Magento\Catalog\Api\ProductAttributeIsFilterableManagementInterface" method="set"/>
<resources>
<resource ref="Magento_Catalog::attributes_attributes" />
</resources>
</route>
<route url="/V1/products/attributes/:attributeCode" method="DELETE">
<service class="Magento\Catalog\Api\ProductAttributeRepositoryInterface" method="deleteById"/>
<resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,10 +125,6 @@ public function resolve(
return [];
}

if (!$product->getTierPrices()) {
return [];
}

$productId = (int)$product->getId();
$this->tiers->addProductFilter($productId);

Expand Down
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,68 @@
*/
class Provider implements ProviderInterface
{
/**
* @var array
*/
private $minimalPrice = [
FinalPrice::PRICE_CODE => [],
RegularPrice::PRICE_CODE => []
];

/**
* @var array
*/
private $maximalPrice = [
FinalPrice::PRICE_CODE => [],
RegularPrice::PRICE_CODE => []
];

/**
* @inheritdoc
*/
public function getMinimalFinalPrice(SaleableInterface $product): AmountInterface
{
/** @var FinalPrice $finalPrice */
$finalPrice = $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE);
return $finalPrice->getMinimalPrice();
if (!isset($this->minimalPrice[FinalPrice::PRICE_CODE][$product->getId()])) {
/** @var FinalPrice $finalPrice */
$finalPrice = $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE);
$this->minimalPrice[FinalPrice::PRICE_CODE][$product->getId()] = $finalPrice->getMinimalPrice();
}
return $this->minimalPrice[FinalPrice::PRICE_CODE][$product->getId()];
}

/**
* @inheritdoc
*/
public function getMinimalRegularPrice(SaleableInterface $product): AmountInterface
{
return $this->getRegularPrice($product);
if (!isset($this->minimalPrice[RegularPrice::PRICE_CODE][$product->getId()])) {
$this->minimalPrice[RegularPrice::PRICE_CODE][$product->getId()] = $this->getRegularPrice($product);
}
return $this->minimalPrice[RegularPrice::PRICE_CODE][$product->getId()];
}

/**
* @inheritdoc
*/
public function getMaximalFinalPrice(SaleableInterface $product): AmountInterface
{
/** @var FinalPrice $finalPrice */
$finalPrice = $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE);
return $finalPrice->getMaximalPrice();
if (!isset($this->maximalPrice[FinalPrice::PRICE_CODE][$product->getId()])) {
/** @var FinalPrice $finalPrice */
$finalPrice = $product->getPriceInfo()->getPrice(FinalPrice::PRICE_CODE);
$this->maximalPrice[FinalPrice::PRICE_CODE][$product->getId()] = $finalPrice->getMaximalPrice();
}
return $this->maximalPrice[FinalPrice::PRICE_CODE][$product->getId()];
}

/**
* @inheritdoc
*/
public function getMaximalRegularPrice(SaleableInterface $product): AmountInterface
{
return $this->getRegularPrice($product);
if (!isset($this->maximalPrice[RegularPrice::PRICE_CODE][$product->getId()])) {
$this->maximalPrice[RegularPrice::PRICE_CODE][$product->getId()] = $this->getRegularPrice($product);
}
return $this->maximalPrice[RegularPrice::PRICE_CODE][$product->getId()];
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
<!-- Mouse Hover Product On Category Page-->
<actionGroup ref="StorefrontHoverProductOnCategoryPageActionGroup" stepKey="hoverProduct"/>
<!-- Select Add to cart-->
<waitForElementClickable selector="{{StorefrontCategoryMainSection.addToCartProductBySku($$simpleProductOne.sku$$)}}" stepKey="waitForAddToCartButton"/>
<click selector="{{StorefrontCategoryMainSection.addToCartProductBySku($$simpleProductOne.sku$$)}}" stepKey="toCategory"/>
<waitForElementVisible selector="{{StorefrontProductPageSection.errorMsg}}" stepKey="wait"/>
<!-- Assert the Error Message-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
</arguments>

<waitForElement selector="{{CheckoutPaymentSection.paymentSectionTitle}}" time="30" stepKey="waitForPaymentSectionLoaded"/>
<waitForElementVisible selector="{{CheckoutPaymentSection.billingAddress}}" stepKey="waitForBillingAddressFirstNameVisible"/>
<see userInput="{{customerVar.firstName}}" selector="{{CheckoutPaymentSection.billingAddress}}" stepKey="assertBillingAddressFirstName"/>
<see userInput="{{customerVar.lastName}}" selector="{{CheckoutPaymentSection.billingAddress}}" stepKey="assertBillingAddressLastName"/>
<see userInput="{{customerAddressVar.street[0]}}" selector="{{CheckoutPaymentSection.billingAddress}}" stepKey="assertBillingAddressStreet"/>
Expand Down
14 changes: 2 additions & 12 deletions app/code/Magento/ConfigurableProduct/Test/Fixture/Attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,12 @@

namespace Magento\ConfigurableProduct\Test\Fixture;

use Magento\Catalog\Test\Fixture\SelectAttribute;
use Magento\Framework\DataObject;

class Attribute extends \Magento\Catalog\Test\Fixture\Attribute
class Attribute extends SelectAttribute
{
private const DEFAULT_DATA = [
'frontend_input' => 'select',
'options' => [
[
'label' => 'option1%uniqid%',
'sort_order' => 0,
],
[
'label' => 'option2%uniqid%',
'sort_order' => 1,
]
],
'scope' => 'global',
];

Expand Down
Loading

0 comments on commit b6cc3c5

Please sign in to comment.