Skip to content

Add the domReady! statement for editing the cart product on the PDP #13253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 83 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
2abaf8c
Added translate.test.js for Jasmine compatibility unit testing.
Nov 21, 2017
1691621
Fix translate.test to be eslint friendly
Nov 22, 2017
ea56695
Added accordion.test.js for Jasmine testing.
Nov 22, 2017
126a1e3
Eslint upgrades.
Nov 22, 2017
b3fedbc
Added decorate.test.js for Jasmine testing. Removed decorate-test.js
omiroshnichenko Nov 22, 2017
0117f86
Added translate.test.js for Jasmine compatibility unit testing.
Nov 21, 2017
3a907c2
Fix translate.test to be eslint friendly
Nov 22, 2017
821bdaa
Added accordion.test.js for Jasmine testing.
Nov 22, 2017
2846c78
Eslint upgrades.
Nov 22, 2017
f4712cd
Eslint improvements and logical fixes for unit testing.
Nov 22, 2017
f0a1877
Added decorate.test.js for Jasmine testing. Removed decorate-test.js
omiroshnichenko Nov 22, 2017
5e785eb
Merge remote-tracking branch 'karldeux/issue/12342/JSTestDriver-remov…
Nov 22, 2017
64bf208
Eslint improvements and logical fixes for unit testing.
Nov 22, 2017
8595da6
Fix decorate.test.js
omiroshnichenko Nov 22, 2017
2adf9e8
Fixed unsafe comparison with a literal. No need to eslint eqeqeq.
Nov 23, 2017
9b28fe2
that - this consistency and splat complete function to be Jasmine fri…
Nov 23, 2017
4127a8c
Added collapsible.test.js and removed JsTestDriver equivalent.
Nov 23, 2017
6366f83
jscs:disable jsDoc
Nov 23, 2017
c98720f
Added dropdown.test.js and removed JsTestDriver equivalent.
Nov 24, 2017
de225a9
Backend jquery-ui version has a diferent behavior on create that will…
Nov 24, 2017
9f14822
Added form.test.js and removed JsTestDriver equivalent.
Dec 1, 2017
ad90a47
jQuery consistency.
Dec 1, 2017
15928fb
8624: Stock status not coming back after qty update
RomaKis Dec 11, 2017
188ecb3
8624: Stock status not coming back after qty update
RomaKis Dec 12, 2017
546a0bb
Merge branch '2.2-develop' into 8624
RomaKis Dec 12, 2017
8d62341
magento/magento2#11897: Catalog product list widget not working with …
nmalevanec Dec 19, 2017
35a1aca
magento/magento2#12342: JSTestDriver removal
omiroshnichenko Dec 20, 2017
d5b596a
magento/magento2#11897: Catalog product list widget not working with …
nmalevanec Dec 20, 2017
36cfa45
magento/magento2#12342: JSTestDriver removal
omiroshnichenko Dec 20, 2017
b1b001a
magento/magento2#12342: JSTestDriver removal
omiroshnichenko Dec 20, 2017
b716482
magento/magento2#12342: JSTestDriver removal
omiroshnichenko Dec 20, 2017
c5a1722
magento/magento2#12342: JSTestDriver removal
omiroshnichenko Dec 20, 2017
40e6981
magento/magento2#12342: JSTestDriver removal
omiroshnichenko Dec 21, 2017
2fff734
magento/magento2#12342: JSTestDriver removal
omiroshnichenko Dec 21, 2017
e510801
Merge branch '2.2-develop' of github.com:magento/magento2 into issue/…
omiroshnichenko Dec 21, 2017
6b22445
12322: [GitHub] Bug with CDATA in XML layout update
serhii-balko Jan 4, 2018
69cad44
magento/magento2#12993: Type error in Cart/Totals [Forwardport for pu…
p-bystritsky Jan 9, 2018
dc64138
Merge branch '2.2-develop-mainline' into ISSUE-12993
p-bystritsky Jan 10, 2018
26a83d5
magento/magento2#12147: The function "isUsingStaticUrlsAllowed" (conf…
nmalevanec Jan 11, 2018
94fdca7
magento/magento2#12147: The function "isUsingStaticUrlsAllowed" (conf…
nmalevanec Jan 11, 2018
b57eb03
magento/magento2#13126: 2.2.2 - Duplicating Bundle Product Removes Bu…
nmalevanec Jan 12, 2018
d8bd657
magento/magento2#13126: 2.2.2 - Duplicating Bundle Product Removes Bu…
nmalevanec Jan 12, 2018
f7baf29
#12714 - pass parameter for export button url
sanjay-wagento Jan 16, 2018
1caaa21
MAGETWO-84480: Add cache for getimagesize() function for product images
slopukhov Jan 16, 2018
27bcb25
MAGETWO-84480: Add cache for getimagesize() function for product images
slopukhov Jan 16, 2018
f31754d
MAGETWO-84480: Add cache for getimagesize() function for product images
slopukhov Jan 16, 2018
164e946
MAGETWO-84480: Add cache for getimagesize() function for product images
slopukhov Jan 17, 2018
4b585d4
Merge branch '2.2-develop' into 8624
RomaKis Jan 17, 2018
a9a3c19
8624: Stock status not coming back after qty update
RomaKis Jan 17, 2018
3e86102
MAGETWO-84480: Add cache for getimagesize() function for product images
slopukhov Jan 17, 2018
ad951b0
MAGETWO-86840: GitHub 12322: Bug with CDATA in XML layout update #1163
Jan 18, 2018
2f5d244
Add the domReady! statement
arnoudhgz Jan 18, 2018
a667b63
magento/magento2#12342: JSTestDriver removal
omiroshnichenko Jan 18, 2018
e15c721
MAGETWO-86845: #12714 - pass parameter for export button url #13208
rogyar Jan 18, 2018
bb5d086
Merge pull request #5 from arnoudhgz/bugfix/run-js-when-dom-is-loaded…
Jan 18, 2018
574daf5
Merge branch '2.2-develop' of github.com:magento/magento2 into issue/…
omiroshnichenko Jan 18, 2018
6a48b85
MAGETWO-86845: #12714 - pass parameter for export button url #13208
ishakhsuvarov Jan 18, 2018
2e19f33
MAGETWO-86840: GitHub 12322: Bug with CDATA in XML layout update #1163
ishakhsuvarov Jan 18, 2018
faed0c5
magento/magento2#12342: JSTestDriver removal
omiroshnichenko Jan 18, 2018
59bd8fc
Merge branch '2.2-develop' of github.com:magento/magento2ce into MAGE…
slopukhov Jan 18, 2018
08b4a41
MAGETWO-85288: 8624: Stock status not coming back after qty update #955
Jan 18, 2018
ac8aa21
magento/magento2#12342: JSTestDriver removal
omiroshnichenko Jan 18, 2018
11fd8ce
Merge pull request #1966 from magento-performance/MAGETWO-84480
kandy Jan 18, 2018
afd02d7
[EngCom] Public Pull Requests - 2.2-develop
magento-engcom-team Jan 18, 2018
83a9b9c
:arrows_clockwise: [EngCom] Public Pull Requests - 2.2-develop
magento-team Jan 18, 2018
ca5c2ed
MAGETWO-86663: 11897: Catalog product list widget not working with mu…
Jan 18, 2018
772c10d
MAGETWO-86882: 2.2.2 - Duplicating Bundle Product Removes Bundle Opti…
ishakhsuvarov Jan 19, 2018
2a80282
MAGETWO-86883: The function 'isUsingStaticUrlsAllowed' (configuration…
ishakhsuvarov Jan 19, 2018
225e6d1
MAGETWO-86886: magento/magento2#12993: Type error in Cart/Totals [For…
ishakhsuvarov Jan 19, 2018
5d537a3
MAGETWO-86883: The function "isUsingStaticUrlsAllowed" (configuration…
ishakhsuvarov Jan 19, 2018
18bb122
MAGETWO-86663: 11897: Catalog product list widget not working with mu…
ishakhsuvarov Jan 19, 2018
f13beab
MAGETWO-85288: 8624: Stock status not coming back after qty update #955
ishakhsuvarov Jan 19, 2018
fa69aa5
Merge branch '2.2-develop' of github.com:magento/magento2 into issue/…
omiroshnichenko Jan 19, 2018
64f9c6d
magento/magento2#12342: JSTestDriver removal
omiroshnichenko Jan 19, 2018
f748630
MAGETWO-86859: Issue/12342/js test driver removal #12406
omiroshnichenko Jan 19, 2018
78028f0
:arrows_clockwise: [EngCom] Public Pull Requests - 2.2-develop
magento-team Jan 19, 2018
48dd554
MAGETWO-86886: magento/magento2#12993: Type error in Cart/Totals [For…
ishakhsuvarov Jan 20, 2018
b641bf8
MAGETWO-86859: Issue/12342/js test driver removal #12406
ishakhsuvarov Jan 20, 2018
1cd8257
:arrows_clockwise: [EngCom] Public Pull Requests - 2.2-develop
ishakhsuvarov Jan 20, 2018
7bcbbeb
MAGETWO-86882: Duplicating Bundle Product Removes Bundle Options From…
ishakhsuvarov Jan 20, 2018
d2d438c
MAGETWO-86882: 2.2.2 - Duplicating Bundle Product Removes Bundle Opti…
ishakhsuvarov Jan 20, 2018
d0b82cc
:arrows_clockwise: [EngCom] Public Pull Requests - 2.2-develop
magento-team Jan 20, 2018
83fb6cb
Merge branch '2.2-develop' of github.com:mediact/magento2 into 2.2-de…
arnoudhgz Jan 22, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion app/code/Magento/Bundle/Model/Product/CopyConstructor/Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,17 @@ public function build(Product $product, Product $duplicate)
$bundleOptions = $product->getExtensionAttributes()->getBundleProductOptions() ?: [];
$duplicatedBundleOptions = [];
foreach ($bundleOptions as $key => $bundleOption) {
$duplicatedBundleOptions[$key] = clone $bundleOption;
$duplicatedBundleOption = clone $bundleOption;
/**
* Set option and selection ids to 'null' in order to create new option(selection) for duplicated product,
* but not modifying existing one, which led to lost of option(selection) in original product.
*/
$productLinks = $duplicatedBundleOption->getProductLinks() ?: [];
foreach ($productLinks as $productLink) {
$productLink->setSelectionId(null);
}
$duplicatedBundleOption->setOptionId(null);
$duplicatedBundleOptions[$key] = $duplicatedBundleOption;
}
$duplicate->getExtensionAttributes()->setBundleProductOptions($duplicatedBundleOptions);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
namespace Magento\Bundle\Test\Unit\Model\Product\CopyConstructor;

use Magento\Bundle\Api\Data\BundleOptionInterface;
use Magento\Bundle\Model\Link;
use Magento\Bundle\Model\Product\CopyConstructor\Bundle;
use Magento\Catalog\Api\Data\ProductExtensionInterface;
use Magento\Catalog\Model\Product;
Expand Down Expand Up @@ -45,6 +46,7 @@ public function testBuildNegative()
*/
public function testBuildPositive()
{
/** @var Product|\PHPUnit_Framework_MockObject_MockObject $product */
$product = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->getMock();
Expand All @@ -60,18 +62,42 @@ public function testBuildPositive()
->method('getExtensionAttributes')
->willReturn($extensionAttributesProduct);

$productLink = $this->getMockBuilder(Link::class)
->setMethods(['setSelectionId'])
->disableOriginalConstructor()
->getMock();
$productLink->expects($this->exactly(2))
->method('setSelectionId')
->with($this->identicalTo(null));
$firstOption = $this->getMockBuilder(BundleOptionInterface::class)
->setMethods(['getProductLinks'])
->disableOriginalConstructor()
->getMockForAbstractClass();
$firstOption->expects($this->once())
->method('getProductLinks')
->willReturn([$productLink]);
$firstOption->expects($this->once())
->method('setOptionId')
->with($this->identicalTo(null));
$secondOption = $this->getMockBuilder(BundleOptionInterface::class)
->setMethods(['getProductLinks'])
->disableOriginalConstructor()
->getMockForAbstractClass();
$secondOption->expects($this->once())
->method('getProductLinks')
->willReturn([$productLink]);
$secondOption->expects($this->once())
->method('setOptionId')
->with($this->identicalTo(null));
$bundleOptions = [
$this->getMockBuilder(BundleOptionInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass(),
$this->getMockBuilder(BundleOptionInterface::class)
->disableOriginalConstructor()
->getMockForAbstractClass()
$firstOption,
$secondOption
];
$extensionAttributesProduct->expects($this->once())
->method('getBundleProductOptions')
->willReturn($bundleOptions);

/** @var Product|\PHPUnit_Framework_MockObject_MockObject $duplicate */
$duplicate = $this->getMockBuilder(Product::class)
->disableOriginalConstructor()
->getMock();
Expand Down
172 changes: 85 additions & 87 deletions app/code/Magento/Catalog/Model/Product/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Image as MagentoImage;
use Magento\Framework\Serialize\SerializerInterface;

/**
* @method string getFile()
Expand Down Expand Up @@ -172,6 +173,16 @@ class Image extends \Magento\Framework\Model\AbstractModel
*/
private $imageAsset;

/**
* @var string
*/
private $cachePrefix = 'IMG_INFO';

/**
* @var SerializerInterface
*/
private $serializer;

/**
* Constructor
*
Expand All @@ -190,6 +201,7 @@ class Image extends \Magento\Framework\Model\AbstractModel
* @param array $data
* @param \Magento\Catalog\Model\View\Asset\ImageFactory|null $viewAssetImageFactory
* @param \Magento\Catalog\Model\View\Asset\PlaceholderFactory|null $viewAssetPlaceholderFactory
* @param SerializerInterface|null $serializer
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
Expand All @@ -208,7 +220,8 @@ public function __construct(
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = [],
\Magento\Catalog\Model\View\Asset\ImageFactory $viewAssetImageFactory = null,
\Magento\Catalog\Model\View\Asset\PlaceholderFactory $viewAssetPlaceholderFactory = null
\Magento\Catalog\Model\View\Asset\PlaceholderFactory $viewAssetPlaceholderFactory = null,
SerializerInterface $serializer = null
) {
$this->_storeManager = $storeManager;
$this->_catalogProductMediaConfig = $catalogProductMediaConfig;
Expand All @@ -223,6 +236,7 @@ public function __construct(
->get(\Magento\Catalog\Model\View\Asset\ImageFactory::class);
$this->viewAssetPlaceholderFactory = $viewAssetPlaceholderFactory ?: ObjectManager::getInstance()
->get(\Magento\Catalog\Model\View\Asset\PlaceholderFactory::class);
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
}

/**
Expand Down Expand Up @@ -356,86 +370,6 @@ public function setSize($size)
return $this;
}

/**
* @param string|null $file
* @return bool
*/
protected function _checkMemory($file = null)
{
return $this->_getMemoryLimit() > $this->_getMemoryUsage() + $this->_getNeedMemoryForFile(
$file
)
|| $this->_getMemoryLimit() == -1;
}

/**
* @return string
*/
protected function _getMemoryLimit()
{
$memoryLimit = trim(strtoupper(ini_get('memory_limit')));

if (!isset($memoryLimit[0])) {
$memoryLimit = "128M";
}

if (substr($memoryLimit, -1) == 'K') {
return substr($memoryLimit, 0, -1) * 1024;
}
if (substr($memoryLimit, -1) == 'M') {
return substr($memoryLimit, 0, -1) * 1024 * 1024;
}
if (substr($memoryLimit, -1) == 'G') {
return substr($memoryLimit, 0, -1) * 1024 * 1024 * 1024;
}
return $memoryLimit;
}

/**
* @return int
*/
protected function _getMemoryUsage()
{
if (function_exists('memory_get_usage')) {
return memory_get_usage();
}
return 0;
}

/**
* @param string|null $file
* @return float|int
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function _getNeedMemoryForFile($file = null)
{
$file = $file === null ? $this->getBaseFile() : $file;
if (!$file) {
return 0;
}

if (!$this->_mediaDirectory->isExist($file)) {
return 0;
}

$imageInfo = getimagesize($this->_mediaDirectory->getAbsolutePath($file));

if (!isset($imageInfo[0]) || !isset($imageInfo[1])) {
return 0;
}
if (!isset($imageInfo['channels'])) {
// if there is no info about this parameter lets set it for maximum
$imageInfo['channels'] = 4;
}
if (!isset($imageInfo['bits'])) {
// if there is no info about this parameter lets set it for maximum
$imageInfo['bits'] = 8;
}
return round(
($imageInfo[0] * $imageInfo[1] * $imageInfo['bits'] * $imageInfo['channels'] / 8 + Pow(2, 16)) * 1.65
);
}

/**
* Convert array of 3 items (decimal r, g, b) to string of their hex values
*
Expand Down Expand Up @@ -472,9 +406,7 @@ public function setBaseFile($file)
'filePath' => $file,
]
);
if ($file == 'no_selection' || !$this->_fileExists($this->imageAsset->getSourceFile())
|| !$this->_checkMemory($this->imageAsset->getSourceFile())
) {
if ($file == 'no_selection' || !$this->_fileExists($this->imageAsset->getSourceFile())) {
$this->_isBaseFilePlaceholder = true;
$this->imageAsset = $this->viewAssetPlaceholderFactory->create(
[
Expand Down Expand Up @@ -682,11 +614,14 @@ public function getDestinationSubdir()
}

/**
* @return bool|void
* @return bool
*/
public function isCached()
{
return file_exists($this->imageAsset->getPath());
return (
is_array($this->loadImageInfoFromCache($this->imageAsset->getPath())) ||
file_exists($this->imageAsset->getPath())
);
}

/**
Expand Down Expand Up @@ -856,6 +791,7 @@ public function clearCache()
$this->_mediaDirectory->delete($directory);

$this->_coreFileStorageDatabase->deleteFolder($this->_mediaDirectory->getAbsolutePath($directory));
$this->clearImageInfoFromCache();
}

/**
Expand Down Expand Up @@ -890,7 +826,7 @@ public function getResizedImageInfo()
$image = $this->imageAsset->getPath();
}

$imageProperties = getimagesize($image);
$imageProperties = $this->getimagesize($image);

return $imageProperties;
} finally {
Expand Down Expand Up @@ -932,4 +868,66 @@ private function getMiscParams()

return $miscParams;
}

/**
* Get image size
*
* @param string $imagePath
* @return array
*/
private function getImageSize($imagePath)
{
$imageInfo = $this->loadImageInfoFromCache($imagePath);
if (!isset($imageInfo['size'])) {
$imageSize = getimagesize($imagePath);
$this->saveImageInfoToCache(['size' => $imageSize], $imagePath);
return $imageSize;
} else {
return $imageInfo['size'];
}
}

/**
* Save image data to cache
*
* @param array $imageInfo
* @param string $imagePath
* @return void
*/
private function saveImageInfoToCache(array $imageInfo, string $imagePath)
{
$imagePath = $this->cachePrefix . $imagePath;
$this->_cacheManager->save(
$this->serializer->serialize($imageInfo),
$imagePath,
[$this->cachePrefix]
);
}

/**
* Load image data from cache
*
* @param string $imagePath
* @return array|false
*/
private function loadImageInfoFromCache(string $imagePath)
{
$imagePath = $this->cachePrefix . $imagePath;
$cacheData = $this->_cacheManager->load($imagePath);
if (!$cacheData) {
return false;
} else {
return $this->serializer->unserialize($cacheData);
}
}

/**
* Clear image data from cache
*
* @return void
*/
private function clearImageInfoFromCache()
{
$this->_cacheManager->clean([$this->cachePrefix]);
}
}
Loading