1

I want product frontend url when admin adding new product. we use catalog_product_save_after event in this event we will get all information about product except product url

public function addNewproduct($observer) {

        $product = $observer->getEvent()->getProduct();
    $product->getName();
    $product->getShortDescription();
    Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB, true ).$product->getUrlPath();// not get this product url path

}
1
  • Can you please show your full code how to get other detaisl
    – Magento 2
    Nov 22, 2016 at 17:20

1 Answer 1

1

Try this working code :

public function addNewproduct($observer) {

    $product = $observer->getEvent()->getProduct();
    $product->getName();
    $product->getShortDescription();
    //Mage::getBaseUrl( Mage_Core_Model_Store::URL_TYPE_WEB, true ).$product->getUrlPath();// not get this product url path
    $suffix = Mage::getStoreConfig('catalog/seo/product_url_suffix');
    $productUrl = Mage::getUrl().$product->getUrlKey().$suffix;

}
5
  • But suffix is coming from admin global setting like .html
    – Vishal
    Nov 23, 2016 at 5:30
  • @MagikVishal, Now check my updated answer Nov 23, 2016 at 5:36
  • We will get storewise product url is right?
    – Vishal
    Nov 23, 2016 at 5:40
  • @MagikVishal, By default product url will same for all store. If you want, you can change the product url key for any store manually. We can get the url key of any store by providing store id. Nov 23, 2016 at 5:44
  • @MagikVishal, Is your issue resolved ? Nov 23, 2016 at 8:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.