Skip to content

Commit

Permalink
Merge branch '2.3-develop' into 2.3-develop-19099-issue
Browse files Browse the repository at this point in the history
  • Loading branch information
eduard13 committed Nov 9, 2018
2 parents fea9aaf + 6481cec commit 508832b
Show file tree
Hide file tree
Showing 41 changed files with 752 additions and 301 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
<severity value="MAJOR"/>
<testCaseId value="MAGETWO-63898"/>
<group value="analytics"/>
<skip>
<issueId value="MAGETWO-96223"/>
</skip>
</annotations>

<actionGroup ref="LoginActionGroup" stepKey="loginAsAdmin"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,7 @@ public function __construct(
*/
public function getAddToWishlistParams($product)
{
$continueUrl = $this->urlEncoder->encode($this->getUrl('customer/account'));
$urlParamName = Action::PARAM_NAME_URL_ENCODED;

$continueUrlParams = [$urlParamName => $continueUrl];

return $this->_wishlistHelper->getAddParams($product, $continueUrlParams);
return $this->_wishlistHelper->getAddParams($product);
}

/**
Expand Down
18 changes: 15 additions & 3 deletions app/code/Magento/Catalog/Model/Design.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
namespace Magento\Catalog\Model;

use \Magento\Framework\TranslateInterface;

/**
* Catalog Custom Category design Model
*
Expand All @@ -31,14 +33,20 @@ class Design extends \Magento\Framework\Model\AbstractModel
*/
protected $_localeDate;

/**
* @var TranslateInterface
*/
private $translator;

/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
* @param \Magento\Framework\View\DesignInterface $design
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
* @param array $data
* @param TranslateInterface|null $translator
*/
public function __construct(
\Magento\Framework\Model\Context $context,
Expand All @@ -47,10 +55,13 @@ public function __construct(
\Magento\Framework\View\DesignInterface $design,
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = []
array $data = [],
TranslateInterface $translator = null
) {
$this->_localeDate = $localeDate;
$this->_design = $design;
$this->translator = $translator ?:
\Magento\Framework\App\ObjectManager::getInstance()->get(TranslateInterface::class);
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
}

Expand All @@ -63,6 +74,7 @@ public function __construct(
public function applyCustomDesign($design)
{
$this->_design->setDesignTheme($design);
$this->translator->loadData(null, true);
return $this;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\CatalogGraphQl\Model\Resolver\Product;

use Magento\Catalog\Model\Product;
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;

/**
* Returns product's image data
*/
class ProductImage implements ResolverInterface
{
/**
* @inheritdoc
*/
public function resolve(
Field $field,
$context,
ResolveInfo $info,
array $value = null,
array $args = null
): array {
if (!isset($value['model'])) {
throw new LocalizedException(__('"model" value should be specified'));
}

/** @var Product $product */
$product = $value['model'];
$imageType = $field->getName();

return [
'model' => $product,
'image_type' => $imageType,
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\CatalogGraphQl\Model\Resolver\Product\ProductImage;

use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ResourceModel\Product as ProductResourceModel;
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\Store\Model\StoreManagerInterface;

/**
* Returns product's image label
*/
class Label implements ResolverInterface
{
/**
* @var ProductResourceModel
*/
private $productResource;

/**
* @var StoreManagerInterface
*/
private $storeManager;

/**
* @param ProductResourceModel $productResource
* @param StoreManagerInterface $storeManager
*/
public function __construct(
ProductResourceModel $productResource,
StoreManagerInterface $storeManager
) {
$this->productResource = $productResource;
$this->storeManager = $storeManager;
}

/**
* @inheritdoc
*/
public function resolve(
Field $field,
$context,
ResolveInfo $info,
array $value = null,
array $args = null
) {
if (!isset($value['image_type'])) {
throw new LocalizedException(__('"image_type" value should be specified'));
}

if (!isset($value['model'])) {
throw new LocalizedException(__('"model" value should be specified'));
}

/** @var Product $product */
$product = $value['model'];
$imageType = $value['image_type'];
$imagePath = $product->getData($imageType);
$productId = (int)$product->getEntityId();

// null if image is not set
if (null === $imagePath) {
return $this->getAttributeValue($productId, 'name');
}

$imageLabel = $this->getAttributeValue($productId, $imageType . '_label');
if (null === $imageLabel) {
$imageLabel = $this->getAttributeValue($productId, 'name');
}

return $imageLabel;
}

/**
* Get attribute value
*
* @param int $productId
* @param string $attributeCode
* @return null|string Null if attribute value is not exists
*/
private function getAttributeValue(int $productId, string $attributeCode): ?string
{
$storeId = $this->storeManager->getStore()->getId();

$value = $this->productResource->getAttributeRawValue($productId, $attributeCode, $storeId);
return is_array($value) && empty($value) ? null : $value;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
declare(strict_types=1);

namespace Magento\CatalogGraphQl\Model\Resolver\Product;
namespace Magento\CatalogGraphQl\Model\Resolver\Product\ProductImage;

use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\ImageFactory;
Expand All @@ -15,13 +15,11 @@
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;

/**
* Returns product's image. If the image is not set, returns a placeholder
* Returns product's image url
*/
class Image implements ResolverInterface
class Url implements ResolverInterface
{
/**
* Product image factory
*
* @var ImageFactory
*/
private $productImageFactory;
Expand All @@ -44,23 +42,36 @@ public function resolve(
ResolveInfo $info,
array $value = null,
array $args = null
): array {
) {
if (!isset($value['image_type'])) {
throw new LocalizedException(__('"image_type" value should be specified'));
}

if (!isset($value['model'])) {
throw new LocalizedException(__('"model" value should be specified'));
}

/** @var Product $product */
$product = $value['model'];
$imageType = $field->getName();
$path = $product->getData($imageType);
$imagePath = $product->getData($value['image_type']);

$imageUrl = $this->getImageUrl($value['image_type'], $imagePath);
return $imageUrl;
}

/**
* Get image url
*
* @param string $imageType
* @param string|null $imagePath Null if image is not set
* @return string
*/
private function getImageUrl(string $imageType, ?string $imagePath): string
{
$image = $this->productImageFactory->create();
$image->setDestinationSubdir($imageType)
->setBaseFile($path);
->setBaseFile($imagePath);
$imageUrl = $image->getUrl();

return [
'url' => $imageUrl,
'path' => $path,
];
return $imageUrl;
}
}
15 changes: 6 additions & 9 deletions app/code/Magento/CatalogGraphQl/etc/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -257,16 +257,13 @@ interface ProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\
meta_title: String @doc(description: "A string that is displayed in the title bar and tab of the browser and in search results lists")
meta_keyword: String @doc(description: "A comma-separated list of keywords that are visible only to search engines")
meta_description: String @doc(description: "A brief overview of the product for search results listings, maximum 255 characters")
image: String @doc(description: "The relative path to the main image on the product page")
small_image: ProductImage @doc(description: "The relative path to the small image, which is used on catalog pages") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\Image")
thumbnail: String @doc(description: "The relative path to the product's thumbnail image")
image: ProductImage @doc(description: "The relative path to the main image on the product page") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductImage")
small_image: ProductImage @doc(description: "The relative path to the small image, which is used on catalog pages") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductImage")
thumbnail: ProductImage @doc(description: "The relative path to the product's thumbnail image") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductImage")
new_from_date: String @doc(description: "The beginning date for new product listings, and determines if the product is featured as a new product") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\NewFromTo")
new_to_date: String @doc(description: "The end date for new product listings") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\NewFromTo")
tier_price: Float @doc(description: "The price when tier pricing is in effect and the items purchased threshold has been reached")
options_container: String @doc(description: "If the product has multiple options, determines where they appear on the product page")
image_label: String @doc(description: "The label assigned to a product image")
small_image_label: String @doc(description: "The label assigned to a product's small image")
thumbnail_label: String @doc(description: "The label assigned to a product's thumbnail image")
created_at: String @doc(description: "Timestamp indicating when the product was created")
updated_at: String @doc(description: "Timestamp indicating when the product was updated")
country_of_manufacture: String @doc(description: "The product's country of origin")
Expand Down Expand Up @@ -352,9 +349,9 @@ type CustomizableFileValue @doc(description: "CustomizableFileValue defines the
image_size_y: Int @doc(description: "The maximum height of an image")
}

type ProductImage @doc(description: "Product image information. Contains image relative path and URL") {
url: String
path: String
type ProductImage @doc(description: "Product image information. Contains image relative path, URL and label") {
url: String @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductImage\\Url")
label: String @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\ProductImage\\Label")
}

interface CustomizableOptionInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\\CustomizableOptionTypeResolver") @doc(description: "The CustomizableOptionInterface contains basic information about a customizable option. It can be implemented by several types of configurable options.") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<element name="shippingMethodRow" type="text" selector=".form.methods-shipping table tbody tr"/>
<element name="checkShippingMethodByName" type="radio" selector="//div[@id='checkout-shipping-method-load']//td[contains(., '{{var1}}')]/..//input" parameterized="true"/>
<element name="shippingMethodRowByName" type="text" selector="//div[@id='checkout-shipping-method-load']//td[contains(., '{{var1}}')]/.." parameterized="true"/>
<element name="shipHereButton" type="button" selector="//button[contains(@class, 'action-select-shipping-item')]/parent::div/following-sibling::div/button[contains(@class, 'action-select-shipping-item')]"/>
<element name="shipHereButton" type="button" selector="//div/following-sibling::div/button[contains(@class, 'action-select-shipping-item')]"/>
<element name="shippingMethodLoader" type="button" selector="//div[contains(@class, 'checkout-shipping-method')]/following-sibling::div[contains(@class, 'loading-mask')]"/>
</section>
</sections>
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
click="editAddress">
<span translate="'Edit'"></span>
</button>
<!-- ko if: (!isSelected()) -->
<button type="button" click="selectAddress" class="action action-select-shipping-item">
<span translate="'Ship Here'"></span>
</button>
<!-- /ko -->
</div>
2 changes: 1 addition & 1 deletion app/code/Magento/Customer/etc/db_schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@
<column xsi:type="int" name="customer_id" padding="11" unsigned="false" nullable="true" identity="false"
comment="Customer Id"/>
<column xsi:type="varchar" name="session_id" nullable="true" length="64" comment="Session ID"/>
<column xsi:type="timestamp" name="last_visit_at" on_update="true" nullable="true" default="CURRENT_TIMESTAMP"
<column xsi:type="timestamp" name="last_visit_at" on_update="true" nullable="false" default="CURRENT_TIMESTAMP"
comment="Last Visit Time"/>
<constraint xsi:type="primary" referenceId="PRIMARY">
<column name="visitor_id"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ define([
} else {
isValid = $.validator.validateSingleElement(this.options.cache.input);
zxcvbnScore = zxcvbn(password).score;
displayScore = isValid ? zxcvbnScore : 1;
displayScore = isValid && zxcvbnScore > 0 ? zxcvbnScore : 1;
}
}

Expand Down
11 changes: 9 additions & 2 deletions app/code/Magento/CustomerImportExport/Model/Import/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ class Address extends AbstractCustomer
*/
protected $_entityTable;

/**
* Region collection instance
*
* @var \Magento\Directory\Model\ResourceModel\Region\Collection
*/
private $_regionCollection;

/**
* Countries and regions
*
Expand Down Expand Up @@ -781,7 +788,7 @@ public static function getDefaultAddressAttributeMapping()
}

/**
* check if address for import is empty (for customer composite mode)
* Check if address for import is empty (for customer composite mode)
*
* @param array $rowData
* @return array
Expand Down Expand Up @@ -940,7 +947,7 @@ protected function _checkRowDuplicate($customerId, $addressId)
}

/**
* set customer attributes
* Set customer attributes
*
* @param array $customerAttributes
* @return $this
Expand Down
Loading

0 comments on commit 508832b

Please sign in to comment.