문제

이 이벤트 옵저버를 사용하여 사용자 정의 URL 구조에 대한 멀티 스토어 제품 URL의 제조업체주요 .
이제 문제가 하나의 특정 상점 ID 만 필요로하는 것입니다.특정 상점 ID에 대한 사용자 정의 이벤트 옵저버를 어떻게 설정할 수 있습니까?

도움이 되었습니까?

해결책

오른쪽 저장소보기에있는 경우 옵저버를 확인할 수 있습니다.

public function updateurl($observer)
{
    $storeId = your store id here;
    if (Mage::app()->getStore()->getId() == $storeId) {
        //your code goes here.
    }
}
.

다른 팁

이 경우 catalog_product_save_after를 사용하는 것이 좋습니다.

및 특정 저장소 에 대해 을 원한다면 제품 저장소 ID를 제공하는 $observer->getEvent()->getProduct()->getStoreId()를 사용하십시오.

이 링크 제품 저장 옵저버에서 올바른 저장소 컨텍스트를 얻을 수 있습니까?

에 아래의 조건을 넣어야합니다

if ($observer->getEvent()->getProduct()->getStoreId() == 'Your_Match_Store_id') {
}
.

관찰자

class MageStack_24869_Model_Observer
{
    public function updateurl($observer)
    {
        if ($observer->getEvent()->getProduct()) {
            if ($observer->getEvent()->getProduct()->getStoreId() == 'Your_Match_Store_id') {
                $product = $observer->getEvent()->getProduct();
                $url = '';

                if (!is_null($product->getData('country_of_manufacture'))) {
                    $url .= $product->getAttributeText('country_of_manufacture') . '-';
                }

                if (!is_null($product->getData('sku'))) {
                    $url .= $product->getData('sku') . '-';
                }

                if(!is_null($product->getData('name'))) {
                    $url .= $product->getData('name');
                }

                $product->setData('url_key', $url);      
            }
        }
    }
}
.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top