opencart の製品フィルター拡張機能を作成しようとしています。
次のように、サイズ、色などのオプションを URL に割り当てます。
index.php?route=product/category&path=59_63&size=57&color=黒
問題は、ページ上の別の色をクリックすると、リンクが次のようになることです。
index.php?route=product/category&path=59_63&size=57&color=黒&color=茶
ご覧のとおり、色の引数が重複しており、カテゴリのリストがめちゃくちゃになっています。同じ引数がある場合、どうすれば削除できますか?
元の opencart のリンク ビルダー関数:
public function link($route, $args = '', $connection = 'NONSSL') {
if ($connection == 'NONSSL') {
$url = $this->url;
} else {
$url = $this->ssl;
}
$url .= 'index.php?route=' . $route;
if ($args) {
$url .= str_replace('&', '&', '&' . ltrim($args, '&'));
}
return $this->rewrite($url);
}