magento获取页面url的办法还有magento的常用函数

时间:2022-04-17 13:14:32

<?php echo $this->getStoreUrl('checkout/cart');?>

获取结账页面的url:<?php echo $this->getUrl('checkout/cart');?>

magento的常用函数:

    1. //Get the path of your magento page.
    2. echo $this->getUrl('mypage');
    3. //Get the path of the image in your skin folder.
    4. echo $this->getSkinUrl('images/yourimage.gif');
    5. //Get the product link.
    6. echo $this->getProductData()->getProductUrl();
    7. //Get the product name.
    8. echo $this->htmlEscape($this->getProductData()->getName());
    9. //Call a static block in .phtml file.
    10. echo $this->getLayout()->createBlock('cms/block')->setBlockId('YOURBLOCKID')->toHtml();
    11. //Get Image url of current category.
    12. echo $this->getCurrentCategory()->getImageUrl();
    13. //Check whether the current category is Top category.
    14. echo $this->IsTopCategory();
    15. //Get description of current category.
    16. echo $this->getCurrentCategory()->getDescription();
    17. //Display products list page (list.phtml).
    18. echo $this->getProductListHtml();
    19. //Display CMS block page.
    20. echo $this->getCmsBlockHtml();
    21. //Get current store id.
    22. echo $storeId = Mage::app()->getStore()->getId();
    23. //Get current store name.
    24. echo $storeName = Mage::app()->getStore()->getName();
    25. //Get current store code.
    26. echo $storeCode = Mage::app()->getStore()->getCode();
    27. //Get website name.
    28. echo $websiteName = Mage::app()->getWebsite()->getName();
    29. //Get session id.
    30. echo $sessionId = Mage::getModel('core/session')->getSessionId();
    31. //Get customer id.
    32. echo $customerId = Mage::getModel('customer/session')->getCustomerId();
    33. //Get guest id.
    34. echo $vistitorId = Mage::getModel('core/session')->getVisitorId();
    35. Mage::getSingleton('customer/session')->isLoggedIn();
    36. Mage::getModel('coredate')-timestamp(time());
    37. //get Parent's Ids
    38. Mage::getModel('catalog/product_type_configurable')->getParentIdsByChild( $childid );
    39. // 返回Ip地址的字符串格式:127.0.0.1
    40. echo Mage::helper('core/http')->getRemoteAddr();
    41. // 返回Ip地址的数值格式:2130706433
    42. echo Mage::helper('core/http')->getRemoteAddr(true);