0

こんにちは、私は次のように達成している製品名、価格、およびカテゴリに基づいて、SEO に適した自動タイトルを作成することにより、タイトルを改善しようとしています。

$catName = isset($category_info) ? " - ".$category_info['name'] : "";
            $titlePrice = $this->data['special'] ? $this->data['special'] : ($this->data['price'] ? $this->data['price'] : ($this->data['tax'] ? $this->data['tax'] : ""));
$newTitle = $product_info['name']." - ".$titlePrice.$catName." - ".$this->config->get('config_title');
            $this->document->setTitle($newTitle);

ただし、 「特別」(セール価格) が「価格」(通常価格) よりも小さい場合、つまり「特別」価格の値がある場合、「SALE」というテキストを含めたいと考えています。

前もって感謝します!

4

1 に答える 1

0

必要なものがわかったら、価格が設定されたらSALEテキストを追加するだけです。special

$catName = isset($category_info) ? " - ".$category_info['name'] : "";
$tax = $this->data['tax'] ? $this->data['tax'] : "";
$price = $this->data['price'] ? $this->data['price'] : $tax;
$titlePrice = $this->data['special'] ? $this->data['special']." SALE" : $price;
$newTitle = $product_info['name']." - ". $titlePrice . $catName. " - ".$this->config->get('config_title');

読みやすくするために分割し(三項演算子が多すぎます!." SALE" ) 、4行目に追加しました。


SALE価格の直後に書きたくない場合は、単に追加することができます

$sale = $this->data['special'] ? "SALE" : "";

好きな場所に追加$saleします。

于 2013-03-12T13:18:16.187 に答える