質問

製品ページでは、製品のURL(href="http://www.example.com//www.example.com//wwator/myproduct.html" rel="nofollow"> http://www.example)を読みたいです。.com / mycategory / myproduct.html )と$myProductURLのようなPHP変数に文字列として置きます。私はまた、製品のIDを使ってこれをやりたいです。

役に立ちましたか?

解決

このようなページの現在のURLを取得できます。

$url = Mage::helper('core/url')->getCurrentUrl();
.

とこのような製品ページに製品IDを取得できます。

$product = Mage::registry('current_product');
if ($product) {
    $id = $product->getId();
}
else {
    //it means you are not in a product page
    $id = null;
}
.

他のヒント

not get Product url from this urlを作成できます 製品IDを取得したい場合は、Registry variable which give u product id を使用します。

if (Mage::registry('current_product')) {
    $Productid = Mage::registry('current_product')->getId();
}
.

あなたが製品ページにあるときにのみ機能していることに注意してください

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top