문제

제품 페이지에서 제품 URL을 읽으려고합니다 ("nofollow"> http : //www.example.com / myCategory / myProduct.html )을 PHP 변수에 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