Skip to content

Commit f6ff15d

Browse files
authored
added store filter to select queries
1 parent 207315d commit f6ff15d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Console/Command/Run.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?php
22

3-
43
namespace ManishJoy\ProductUrlRewrite\Console\Command;
54

65
use Symfony\Component\Console\Command\Command;
@@ -120,10 +119,10 @@ public function enterNewUrlRewrite($_product)
120119
$requestPathWithoutSuffix = $_product->getUrlKey();
121120

122121
// check if request path exists
123-
$mathcingRows = $connection->fetchAll("SELECT `url_rewrite_id` FROM " . $urlRewriteTable . " WHERE `entity_type` = 'product' AND `request_path` = "."'".$requestPathWithoutSuffix.$this->getProductUrlSuffix()."'");
122+
$mathcingRows = $connection->fetchAll("SELECT `url_rewrite_id` FROM " . $urlRewriteTable . " WHERE `entity_type` = 'product' AND `store_id` = ". $storeId ." AND `request_path` = "."'".$requestPathWithoutSuffix.$this->getProductUrlSuffix()."'");
124123
while (count($mathcingRows) > 0) {
125124
$requestPathWithoutSuffix .= '-1';
126-
$mathcingRows = $connection->fetchAll("SELECT `url_rewrite_id` FROM " . $urlRewriteTable . " WHERE `entity_type` = 'product' AND `request_path` = "."'".$requestPathWithoutSuffix.$this->getProductUrlSuffix()."'");
125+
$mathcingRows = $connection->fetchAll("SELECT `url_rewrite_id` FROM " . $urlRewriteTable . " WHERE `entity_type` = 'product' AND `store_id` = ". $storeId ." AND `request_path` = "."'".$requestPathWithoutSuffix.$this->getProductUrlSuffix()."'");
127126
}
128127
$requestPath = $requestPathWithoutSuffix.$this->getProductUrlSuffix();
129128

@@ -142,10 +141,10 @@ public function enterNewUrlRewrite($_product)
142141
$requestPathWithoutSuffix = $categoryPath.$_product->getUrlKey();
143142

144143
// check if request path exists
145-
$mathcingRows = $connection->fetchAll("SELECT `url_rewrite_id` FROM " . $urlRewriteTable . " WHERE `entity_type` = 'product' AND `request_path` = "."'".$requestPathWithoutSuffix.$this->getProductUrlSuffix()."'");
144+
$mathcingRows = $connection->fetchAll("SELECT `url_rewrite_id` FROM " . $urlRewriteTable . " WHERE `entity_type` = 'product' AND `store_id` = ". $storeId ." AND `request_path` = "."'".$requestPathWithoutSuffix.$this->getProductUrlSuffix()."'");
146145
while (count($mathcingRows) > 0) {
147146
$requestPathWithoutSuffix .= '-1';
148-
$mathcingRows = $connection->fetchAll("SELECT `url_rewrite_id` FROM " . $urlRewriteTable . " WHERE `entity_type` = 'product' AND `request_path` = "."'".$requestPathWithoutSuffix.$this->getProductUrlSuffix()."'");
147+
$mathcingRows = $connection->fetchAll("SELECT `url_rewrite_id` FROM " . $urlRewriteTable . " WHERE `entity_type` = 'product' AND `store_id` = ". $storeId ." AND `request_path` = "."'".$requestPathWithoutSuffix.$this->getProductUrlSuffix()."'");
149148
}
150149
$requestPath = $requestPathWithoutSuffix.$this->getProductUrlSuffix();
151150
$requestPath = $categoryPath.$_product->getUrlKey().$this->getProductUrlSuffix();

0 commit comments

Comments
 (0)