This repository has been archived by the owner on Dec 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/2.3-develop' into graphql-128-ex…
…tends-store-config-coverage
- Loading branch information
Showing
57 changed files
with
2,020 additions
and
146 deletions.
There are no files selected for viewing
109 changes: 109 additions & 0 deletions
109
app/code/Magento/Bundle/Test/Mftf/ActionGroup/AdminCreateApiBundleProductActionGroup.xml
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,109 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
|
||
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd"> | ||
<actionGroup name="AdminCreateApiDynamicBundleProductActionGroup"> | ||
<arguments> | ||
<argument name="productName" defaultValue="Api Dynamic Bundle Product" type="string"/> | ||
</arguments> | ||
<!--Create 4 simple products--> | ||
<createData entity="SimpleProduct2" stepKey="simpleProduct1"> | ||
<field key="price">4.99</field> | ||
</createData> | ||
<createData entity="SimpleProduct2" stepKey="simpleProduct2"> | ||
<field key="price">2.89</field> | ||
</createData> | ||
<createData entity="SimpleProduct2" stepKey="simpleProduct3"> | ||
<field key="price">7.33</field> | ||
</createData> | ||
<createData entity="SimpleProduct2" stepKey="simpleProduct4"> | ||
<field key="price">18.25</field> | ||
</createData> | ||
<!-- Create the bundle product based --> | ||
<createData entity="ApiBundleProduct" stepKey="createBundleProduct"> | ||
<field key="name">{{productName}}</field> | ||
</createData> | ||
<createData entity="MultipleSelectOption" stepKey="createBundleOption1_1"> | ||
<requiredEntity createDataKey="createBundleProduct"/> | ||
<field key="required">false</field> | ||
</createData> | ||
<createData entity="CheckboxOption" stepKey="createBundleOption1_2"> | ||
<requiredEntity createDataKey="createBundleProduct"/> | ||
</createData> | ||
<createData entity="ApiBundleLink" stepKey="linkOptionToProduct"> | ||
<requiredEntity createDataKey="createBundleProduct"/> | ||
<requiredEntity createDataKey="createBundleOption1_1"/> | ||
<requiredEntity createDataKey="simpleProduct1"/> | ||
</createData> | ||
<createData entity="ApiBundleLink" stepKey="linkOptionToProduct2"> | ||
<requiredEntity createDataKey="createBundleProduct"/> | ||
<requiredEntity createDataKey="createBundleOption1_1"/> | ||
<requiredEntity createDataKey="simpleProduct2"/> | ||
</createData> | ||
<createData entity="ApiBundleLink" stepKey="linkOptionToProduct3"> | ||
<requiredEntity createDataKey="createBundleProduct"/> | ||
<requiredEntity createDataKey="createBundleOption1_2"/> | ||
<requiredEntity createDataKey="simpleProduct3"/> | ||
</createData> | ||
<createData entity="ApiBundleLink" stepKey="linkOptionToProduct4"> | ||
<requiredEntity createDataKey="createBundleProduct"/> | ||
<requiredEntity createDataKey="createBundleOption1_2"/> | ||
<requiredEntity createDataKey="simpleProduct4"/> | ||
</createData> | ||
</actionGroup> | ||
<actionGroup name="AdminCreateApiFixedBundleProductActionGroup"> | ||
<arguments> | ||
<argument name="productName" defaultValue="Api Fixed Bundle Product" type="string"/> | ||
</arguments> | ||
<!--Create 4 simple products--> | ||
<createData entity="SimpleProduct2" stepKey="simpleProduct1"> | ||
<field key="price">4.99</field> | ||
</createData> | ||
<createData entity="SimpleProduct2" stepKey="simpleProduct2"> | ||
<field key="price">2.89</field> | ||
</createData> | ||
<createData entity="SimpleProduct2" stepKey="simpleProduct3"> | ||
<field key="price">7.33</field> | ||
</createData> | ||
<createData entity="SimpleProduct2" stepKey="simpleProduct4"> | ||
<field key="price">18.25</field> | ||
</createData> | ||
<!-- Create the bundle product based --> | ||
<createData entity="ApiFixedBundleProduct" stepKey="createBundleProduct"> | ||
<field key="name">{{productName}}</field> | ||
</createData> | ||
<createData entity="MultipleSelectOption" stepKey="createBundleOption1_1"> | ||
<requiredEntity createDataKey="createBundleProduct"/> | ||
<field key="required">false</field> | ||
</createData> | ||
<createData entity="CheckboxOption" stepKey="createBundleOption1_2"> | ||
<requiredEntity createDataKey="createBundleProduct"/> | ||
</createData> | ||
<createData entity="ApiBundleLink" stepKey="linkOptionToProduct"> | ||
<requiredEntity createDataKey="createBundleProduct"/> | ||
<requiredEntity createDataKey="createBundleOption1_1"/> | ||
<requiredEntity createDataKey="simpleProduct1"/> | ||
</createData> | ||
<createData entity="ApiBundleLink" stepKey="linkOptionToProduct2"> | ||
<requiredEntity createDataKey="createBundleProduct"/> | ||
<requiredEntity createDataKey="createBundleOption1_1"/> | ||
<requiredEntity createDataKey="simpleProduct2"/> | ||
</createData> | ||
<createData entity="ApiBundleLink" stepKey="linkOptionToProduct3"> | ||
<requiredEntity createDataKey="createBundleProduct"/> | ||
<requiredEntity createDataKey="createBundleOption1_2"/> | ||
<requiredEntity createDataKey="simpleProduct3"/> | ||
</createData> | ||
<createData entity="ApiBundleLink" stepKey="linkOptionToProduct4"> | ||
<requiredEntity createDataKey="createBundleProduct"/> | ||
<requiredEntity createDataKey="createBundleOption1_2"/> | ||
<requiredEntity createDataKey="simpleProduct4"/> | ||
</createData> | ||
</actionGroup> | ||
</actionGroups> |
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
67 changes: 67 additions & 0 deletions
67
app/code/Magento/CatalogGraphQl/Model/Product/Option/DateType.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,67 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\CatalogGraphQl\Model\Product\Option; | ||
|
||
use Magento\Catalog\Model\Product\Option\Type\Date as ProductDateOptionType; | ||
use Magento\Framework\Exception\LocalizedException; | ||
use Magento\Framework\Stdlib\DateTime; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
class DateType extends ProductDateOptionType | ||
{ | ||
/** | ||
* Make valid string as a value of date option type for GraphQl queries | ||
* | ||
* @param array $values All product option values, i.e. array (option_id => mixed, option_id => mixed...) | ||
* @return ProductDateOptionType | ||
*/ | ||
public function validateUserValue($values) | ||
{ | ||
if ($this->_dateExists() || $this->_timeExists()) { | ||
return parent::validateUserValue($this->formatValues($values)); | ||
} | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* Format date value from string to date array | ||
* | ||
* @param [] $values | ||
* @return [] | ||
* @throws LocalizedException | ||
*/ | ||
private function formatValues($values) | ||
{ | ||
if (isset($values[$this->getOption()->getId()])) { | ||
$value = $values[$this->getOption()->getId()]; | ||
$dateTime = \DateTime::createFromFormat(DateTime::DATETIME_PHP_FORMAT, $value); | ||
$values[$this->getOption()->getId()] = [ | ||
'date' => $value, | ||
'year' => $dateTime->format('Y'), | ||
'month' => $dateTime->format('m'), | ||
'day' => $dateTime->format('d'), | ||
'hour' => $dateTime->format('H'), | ||
'minute' => $dateTime->format('i'), | ||
'day_part' => $dateTime->format('a'), | ||
]; | ||
} | ||
|
||
return $values; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function useCalendar() | ||
{ | ||
return false; | ||
} | ||
} |
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
57 changes: 57 additions & 0 deletions
57
app/code/Magento/CatalogGraphQl/Model/Resolver/Category/CategoryHtmlAttribute.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,57 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\CatalogGraphQl\Model\Resolver\Category; | ||
|
||
use Magento\Catalog\Model\Category; | ||
use Magento\Framework\Exception\LocalizedException; | ||
use Magento\Framework\GraphQl\Config\Element\Field; | ||
use Magento\Framework\GraphQl\Query\ResolverInterface; | ||
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo; | ||
use Magento\Catalog\Helper\Output as OutputHelper; | ||
|
||
/** | ||
* Resolve rendered content for category attributes where HTML content is allowed | ||
*/ | ||
class CategoryHtmlAttribute implements ResolverInterface | ||
{ | ||
/** | ||
* @var OutputHelper | ||
*/ | ||
private $outputHelper; | ||
|
||
/** | ||
* @param OutputHelper $outputHelper | ||
*/ | ||
public function __construct( | ||
OutputHelper $outputHelper | ||
) { | ||
$this->outputHelper = $outputHelper; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public function resolve( | ||
Field $field, | ||
$context, | ||
ResolveInfo $info, | ||
array $value = null, | ||
array $args = null | ||
) { | ||
if (!isset($value['model'])) { | ||
throw new LocalizedException(__('"model" value should be specified')); | ||
} | ||
|
||
/* @var $category Category */ | ||
$category = $value['model']; | ||
$fieldName = $field->getName(); | ||
$renderedValue = $this->outputHelper->categoryAttribute($category, $category->getData($fieldName), $fieldName); | ||
|
||
return $renderedValue; | ||
} | ||
} |
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
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.