File tree Expand file tree Collapse file tree 5 files changed +15
-24
lines changed
app/code/Magento/Catalog/Model
dev/tests/integration/testsuite/Magento
CatalogUrlRewrite/Observer
Catalog/Controller/Adminhtml Expand file tree Collapse file tree 5 files changed +15
-24
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
/**
3
- *
4
- * Copyright © Magento, Inc. All rights reserved.
5
- * See COPYING.txt for license details.
3
+ * Copyright 2014 Adobe
4
+ * All Rights Reserved.
6
5
*/
7
6
8
7
namespace Magento \Catalog \Model ;
@@ -149,7 +148,7 @@ public function save(CategoryInterface $category)
149
148
*/
150
149
public function get ($ categoryId , $ storeId = null )
151
150
{
152
- $ cacheKey = $ storeId ?? ' all ' ;
151
+ $ cacheKey = $ storeId ?? $ this -> storeManager -> getStore ()-> getId () ;
153
152
if (!isset ($ this ->instances [$ categoryId ][$ cacheKey ])) {
154
153
/** @var Category $category */
155
154
$ category = $ this ->categoryFactory ->create ();
@@ -231,7 +230,7 @@ protected function validateCategory(Category $category)
231
230
* Lazy loader for the converter.
232
231
*
233
232
* @return ExtensibleDataObjectConverter
234
- *
233
+ * phpcs:disable Magento2.Annotation.MethodAnnotationStructure
235
234
* @deprecated 101.0.0
236
235
* @see we don't recommend this approach anymore
237
236
*/
Original file line number Diff line number Diff line change 1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2011 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
6
7
7
/**
@@ -37,8 +37,6 @@ class Category extends AbstractResource implements ResetAfterRequestInterface
37
37
protected $ _tree ;
38
38
39
39
/**
40
- * Catalog products table name
41
- *
42
40
* @var string
43
41
*/
44
42
protected $ _categoryProductTable ;
@@ -49,15 +47,11 @@ class Category extends AbstractResource implements ResetAfterRequestInterface
49
47
private $ entitiesWhereAttributesIs ;
50
48
51
49
/**
52
- * Id of 'is_active' category attribute
53
- *
54
50
* @var int
55
51
*/
56
52
protected $ _isActiveAttributeId = null ;
57
53
58
54
/**
59
- * Id of store
60
- *
61
55
* @var int
62
56
*/
63
57
protected $ _storeId = null ;
@@ -455,7 +449,7 @@ protected function _saveCategoryProducts($category)
455
449
'position ' => (int )$ position ,
456
450
];
457
451
}
458
- $ connection ->insertMultiple ($ this ->getCategoryProductTable (), $ data );
452
+ $ connection ->insertOnDuplicate ($ this ->getCategoryProductTable (), $ data, [ ' position ' ] );
459
453
}
460
454
461
455
/**
Original file line number Diff line number Diff line change 1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2020 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
6
declare (strict_types=1 );
7
7
@@ -48,10 +48,9 @@ protected function setUp(): void
48
48
public function testUpdateCategoryForDefaultStoreView (array $ postData ): void
49
49
{
50
50
$ storeId = (int )$ this ->storeManager ->getStore ('default ' )->getId ();
51
- $ postData = array_merge ($ postData , ['store_id ' => $ storeId ]);
52
51
$ responseData = $ this ->performSaveCategoryRequest ($ postData );
53
52
$ this ->assertRequestIsSuccessfullyPerformed ($ responseData );
54
- $ category = $ this ->categoryRepository ->get ($ postData ['entity_id ' ], $ postData [ ' store_id ' ] );
53
+ $ category = $ this ->categoryRepository ->get ($ postData ['entity_id ' ], $ storeId );
55
54
unset($ postData ['use_default ' ]);
56
55
unset($ postData ['use_config ' ]);
57
56
foreach ($ postData as $ key => $ value ) {
Original file line number Diff line number Diff line change 1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2012 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
6
declare (strict_types=1 );
7
7
@@ -153,7 +153,6 @@ public function testDefaultValueForCategoryUrlPath(): void
153
153
$ categoryId = 3 ;
154
154
$ category = $ this ->categoryRepository ->get ($ categoryId );
155
155
$ newUrlPath = 'test_url_path ' ;
156
- $ defaultUrlPath = $ category ->getData ('url_path ' );
157
156
158
157
// update url_path and check it
159
158
$ category ->setStoreId (1 );
@@ -178,7 +177,7 @@ public function testDefaultValueForCategoryUrlPath(): void
178
177
MessageInterface::TYPE_SUCCESS
179
178
);
180
179
$ category = $ this ->categoryRepository ->get ($ categoryId );
181
- $ this ->assertEquals ($ defaultUrlPath , $ category ->getData ('url_key ' ));
180
+ $ this ->assertEquals ($ newUrlPath , $ category ->getData ('url_key ' ));
182
181
}
183
182
184
183
/**
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ public function testChildrenUrlPathContainsParentCustomScopeUrlKey()
105
105
[
106
106
'parent_id ' => $ category1 ->getId (),
107
107
'name ' => 'Category 2 ' ,
108
- 'url_key ' => null ,
108
+ 'url_key ' => ' category-2 ' ,
109
109
'is_active ' => true
110
110
]
111
111
);
@@ -114,7 +114,7 @@ public function testChildrenUrlPathContainsParentCustomScopeUrlKey()
114
114
$ this ->storeManager ->setCurrentStore ($ secondStore );
115
115
116
116
$ category2 = $ this ->categoryRepository ->get ($ category2 ->getId ());
117
- $ category2 ->setUrlKey (null );
117
+ $ category2 ->setUrlKey (' category-2 ' );
118
118
$ this ->categoryRepository ->save ($ category2 );
119
119
120
120
$ this ->storeManager ->setCurrentStore (StoreModel::DEFAULT_STORE_ID );
You can’t perform that action at this time.
0 commit comments