@@ -184,6 +184,7 @@ public function getLastUsedRewriteRequestIncrement($prefix, $suffix, $storeId)
184
184
$ select = $ adapter ->select ()
185
185
->from ($ this ->getMainTable (), new Zend_Db_Expr ('MAX( ' . $ urlIncrementPartExpression . ') ' ))
186
186
->where ('store_id = :store_id ' )
187
+ // phpcs:ignore Ecg.Sql.SlowQuery.SlowRawSql
187
188
->where ('request_path LIKE :request_path ' )
188
189
->where ($ adapter ->prepareSqlCondition ('request_path ' , [
189
190
'regexp ' => '^ ' . preg_quote ($ prefix ) . '[0-9]* ' . preg_quote ($ suffix ) . '$ '
@@ -264,6 +265,7 @@ public function prepareRewrites($storeId, $categoryIds = null, $productIds = nul
264
265
$ select ->where ('product_id IN(?) ' , $ productIds );
265
266
}
266
267
268
+ // phpcs:ignore Ecg.Performance.FetchAll.Found
267
269
$ rowSet = $ adapter ->fetchAll ($ select , $ bind );
268
270
269
271
foreach ($ rowSet as $ row ) {
@@ -467,6 +469,7 @@ protected function _getCategoryAttribute($attributeCode, $categoryIds, $storeId)
467
469
$ bind ['store_id ' ] = $ storeId ;
468
470
}
469
471
472
+ // phpcs:ignore Ecg.Performance.FetchAll.Found
470
473
$ rowSet = $ adapter ->fetchAll ($ select , $ bind );
471
474
472
475
$ attributes = [];
@@ -608,6 +611,7 @@ public function _getProductAttribute($attributeCode, $productIds, $storeId)
608
611
$ bind ['store_id ' ] = $ storeId ;
609
612
}
610
613
614
+ // phpcs:ignore Ecg.Performance.FetchAll.Found
611
615
$ rowSet = $ adapter ->fetchAll ($ select , $ bind );
612
616
613
617
$ attributes = [];
@@ -672,7 +676,7 @@ protected function _prepareStoreRootCategories($stores)
672
676
* Retrieve categories objects
673
677
* Either $categoryIds or $path (with ending slash) must be specified
674
678
*
675
- * @param int|array $categoryIds
679
+ * @param int|array|null $categoryIds
676
680
* @param int $storeId
677
681
* @param string $path
678
682
* @return array
@@ -706,6 +710,7 @@ protected function _getCategories($categoryIds, $storeId = null, $path = null)
706
710
}
707
711
708
712
$ select
713
+ // phpcs:ignore Ecg.Sql.SlowQuery.SlowRawSql
709
714
->where ('main_table.path LIKE ? ' , $ path . '% ' )
710
715
->order ('main_table.path ' );
711
716
}
@@ -730,6 +735,7 @@ protected function _getCategories($categoryIds, $storeId = null, $path = null)
730
735
'store_id ' => (int )$ storeId
731
736
];
732
737
738
+ // phpcs:ignore Ecg.Performance.FetchAll.Found
733
739
$ rowSet = $ adapter ->fetchAll ($ select , $ bind );
734
740
foreach ($ rowSet as $ row ) {
735
741
if ($ storeId !== null ) {
@@ -856,9 +862,11 @@ public function getRootChildrenIds($categoryId, $categoryPath, $includeStart = t
856
862
$ adapter = $ this ->_getReadAdapter ();
857
863
$ select = $ adapter ->select ()
858
864
->from ([$ this ->getTable ('catalog/category ' )], ['entity_id ' ])
865
+ // phpcs:ignore Ecg.Sql.SlowQuery.SlowRawSql
859
866
->where ('path LIKE ? ' , $ categoryPath . '/% ' );
860
867
861
868
$ categoryIds = [];
869
+ // phpcs:ignore Ecg.Performance.FetchAll.Found
862
870
$ rowSet = $ adapter ->fetchAll ($ select );
863
871
foreach ($ rowSet as $ row ) {
864
872
$ categoryIds [$ row ['entity_id ' ]] = $ row ['entity_id ' ];
@@ -918,7 +926,7 @@ public function getProductIdsByCategory($category)
918
926
/**
919
927
* Retrieve Product data objects
920
928
*
921
- * @param int|array $productIds
929
+ * @param int|array|null $productIds
922
930
* @param int $storeId
923
931
* @param int $entityId
924
932
* @param int $lastEntityId
@@ -953,6 +961,7 @@ protected function _getProducts($productIds, $storeId, $entityId, &$lastEntityId
953
961
$ select ->where ('e.entity_id IN(?) ' , $ productIds );
954
962
}
955
963
964
+ // phpcs:ignore Ecg.Performance.FetchAll.Found
956
965
$ rowSet = $ adapter ->fetchAll ($ select , $ bind );
957
966
foreach ($ rowSet as $ row ) {
958
967
$ product = new Varien_Object ($ row );
@@ -972,6 +981,7 @@ protected function _getProducts($productIds, $storeId, $entityId, &$lastEntityId
972
981
['product_id ' , 'category_id ' ]
973
982
)
974
983
->where ('product_id IN(?) ' , array_keys ($ products ));
984
+ // phpcs:ignore Ecg.Performance.FetchAll.Found
975
985
$ categories = $ adapter ->fetchAll ($ select );
976
986
foreach ($ categories as $ category ) {
977
987
$ productId = $ category ['product_id ' ];
@@ -1103,13 +1113,17 @@ public function clearStoreCategoriesInvalidRewrites($storeId)
1103
1113
{
1104
1114
// Form a list of all current store categories ids
1105
1115
$ store = $ this ->getStores ($ storeId );
1116
+ if (!$ store instanceof Mage_Core_Model_Store) {
1117
+ return $ this ;
1118
+ }
1119
+
1106
1120
$ rootCategoryId = $ store ->getRootCategoryId ();
1107
1121
if (!$ rootCategoryId ) {
1108
1122
return $ this ;
1109
1123
}
1110
1124
$ categoryIds = $ this ->getRootChildrenIds ($ rootCategoryId , $ store ->getRootCategoryPath ());
1111
1125
1112
- // Remove all store catalog rewrites that are for some category or cartegory /product not within store categories
1126
+ // Remove all store catalog rewrites that are for some category or category /product not within store categories
1113
1127
$ where = [
1114
1128
'store_id = ? ' => $ storeId ,
1115
1129
'category_id IS NOT NULL ' , // For sure check that it's a catalog rewrite
@@ -1136,6 +1150,10 @@ public function clearStoreCategoriesInvalidRewrites($storeId)
1136
1150
public function clearStoreProductsInvalidRewrites ($ storeId , $ productId = null )
1137
1151
{
1138
1152
$ store = $ this ->getStores ($ storeId );
1153
+ if (!$ store instanceof Mage_Core_Model_Store) {
1154
+ return $ this ;
1155
+ }
1156
+
1139
1157
$ adapter = $ this ->_getReadAdapter ();
1140
1158
$ bind = [
1141
1159
'website_id ' => (int )$ store ->getWebsiteId (),
@@ -1269,6 +1287,7 @@ public function getRewriteByProductStore(array $products)
1269
1287
$ select ->orWhere ($ cond );
1270
1288
}
1271
1289
1290
+ // phpcs:ignore Ecg.Performance.FetchAll.Found
1272
1291
$ rowSet = $ adapter ->fetchAll ($ select , $ bind );
1273
1292
foreach ($ rowSet as $ row ) {
1274
1293
$ result [$ row ['product_id ' ]] = [
0 commit comments