forked from Hevelop/magento2-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Patch-Magento_Catalog_Url_Rewrite-2.1-language-switcher.patch
52 lines (52 loc) · 1.92 KB
/
Patch-Magento_Catalog_Url_Rewrite-2.1-language-switcher.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
--- a/Model/Storage/DbStorage.php
+++ b/Model/Storage/DbStorage.php
@@ -12,25 +12,37 @@
class DbStorage extends BaseDbStorage
{
/**
- * @param array $data
- * @return \Magento\Framework\DB\Select
+ * {@inheritDoc}
*/
protected function prepareSelect($data)
{
+ $metadata = [];
+ if (array_key_exists(UrlRewrite::METADATA, $data)) {
+ $metadata = $data[UrlRewrite::METADATA];
+ unset($data[UrlRewrite::METADATA]);
+ }
+
$select = $this->connection->select();
- $select->from(['url_rewrite' => $this->resource->getTableName('url_rewrite')])
- ->joinLeft(
- ['relation' => $this->resource->getTableName(Product::TABLE_NAME)],
- 'url_rewrite.url_rewrite_id = relation.url_rewrite_id'
- )
- ->where('url_rewrite.entity_id IN (?)', $data['entity_id'])
- ->where('url_rewrite.entity_type = ?', $data['entity_type'])
- ->where('url_rewrite.store_id IN (?)', $data['store_id']);
- if (empty($data[UrlRewrite::METADATA]['category_id'])) {
+ $select->from([
+ 'url_rewrite' => $this->resource->getTableName(self::TABLE_NAME)
+ ]);
+ $select->joinLeft(
+ ['relation' => $this->resource->getTableName(Product::TABLE_NAME)],
+ 'url_rewrite.url_rewrite_id = relation.url_rewrite_id'
+ );
+
+ foreach ($data as $column => $value) {
+ $select->where('url_rewrite.' . $column . ' IN (?)', $value);
+ }
+ if (empty($metadata['category_id'])) {
$select->where('relation.category_id IS NULL');
} else {
- $select->where('relation.category_id = ?', $data[UrlRewrite::METADATA]['category_id']);
+ $select->where(
+ 'relation.category_id = ?',
+ $metadata['category_id']
+ );
}
+
return $select;
}
}