3
3
* Copyright © Magento, Inc. All rights reserved.
4
4
* See COPYING.txt for license details.
5
5
*/
6
+
6
7
namespace Magento \Catalog \Model \ResourceModel \Product ;
7
8
8
9
use Magento \Store \Model \Store ;
@@ -149,7 +150,7 @@ public function loadProductGalleryByAttributeId($product, $attributeId)
149
150
*/
150
151
protected function createBaseLoadSelect ($ entityId , $ storeId , $ attributeId )
151
152
{
152
- $ select = $ this ->createBatchBaseSelect ($ storeId , $ attributeId );
153
+ $ select = $ this ->createBatchBaseSelect ($ storeId , $ attributeId );
153
154
154
155
$ select = $ select ->where (
155
156
'entity. ' . $ this ->metadata ->getLinkField () . ' = ? ' ,
@@ -378,9 +379,9 @@ public function deleteGalleryValueInStore($valueId, $entityId, $storeId)
378
379
$ conditions = implode (
379
380
' AND ' ,
380
381
[
381
- $ this ->getConnection ()->quoteInto ('value_id = ? ' , (int ) $ valueId ),
382
- $ this ->getConnection ()->quoteInto ($ this ->metadata ->getLinkField () . ' = ? ' , (int ) $ entityId ),
383
- $ this ->getConnection ()->quoteInto ('store_id = ? ' , (int ) $ storeId )
382
+ $ this ->getConnection ()->quoteInto ('value_id = ? ' , (int )$ valueId ),
383
+ $ this ->getConnection ()->quoteInto ($ this ->metadata ->getLinkField () . ' = ? ' , (int )$ entityId ),
384
+ $ this ->getConnection ()->quoteInto ('store_id = ? ' , (int )$ storeId )
384
385
]
385
386
);
386
387
@@ -408,7 +409,7 @@ public function duplicate($attributeId, $newFiles, $originalProductId, $newProdu
408
409
409
410
$ select = $ this ->getConnection ()->select ()->from (
410
411
[$ this ->getMainTableAlias () => $ this ->getMainTable ()],
411
- ['value_id ' , 'value ' ]
412
+ ['value_id ' , 'value ' , ' media_type ' , ' disabled ' ]
412
413
)->joinInner (
413
414
['entity ' => $ this ->getTable (self ::GALLERY_VALUE_TO_ENTITY_TABLE )],
414
415
$ this ->getMainTableAlias () . '.value_id = entity.value_id ' ,
@@ -425,16 +426,16 @@ public function duplicate($attributeId, $newFiles, $originalProductId, $newProdu
425
426
426
427
// Duplicate main entries of gallery
427
428
foreach ($ this ->getConnection ()->fetchAll ($ select ) as $ row ) {
428
- $ data = [
429
- 'attribute_id ' => $ attributeId,
430
- 'value ' => isset ( $ newFiles [$ row ['value_id ' ]]) ? $ newFiles [ $ row ['value_id ' ]] : $ row [ ' value ' ],
431
- ] ;
429
+ $ data = $ row ;
430
+ $ data [ 'attribute_id ' ] = $ attributeId;
431
+ $ data [ 'value ' ] = $ newFiles [$ row ['value_id ' ]] ?? $ row ['value ' ];
432
+ unset( $ data [ ' value_id ' ]) ;
432
433
433
434
$ valueIdMap [$ row ['value_id ' ]] = $ this ->insertGallery ($ data );
434
435
$ this ->bindValueToEntity ($ valueIdMap [$ row ['value_id ' ]], $ newProductId );
435
436
}
436
437
437
- if (count ($ valueIdMap ) == 0 ) {
438
+ if (count ($ valueIdMap ) === 0 ) {
438
439
return [];
439
440
}
440
441
0 commit comments