一、產品資訊
1、先判定是否為產品頁面
if (mage::registry(『product』))
2、獲取產品的id,根據id得到產品物件
通過sku獲取產品物件:
$_product = mage::getmodel('catalog/product')->loadbyattribute('sku',$sku);
$product_id = mage::registry(『current_product』)->getid();
$_product = mage::getmodel(『catalog/product』)->load($product_id);
3、產品的資訊
產品庫存 $qtystock = mage::getmodel('cataloginventory/stock_item')->getconllection()
->addfiledtofilter('product_id',$_product->getid());
echo $_product->getshortdescription(); //product』s short description
echo $_product->getdescription(); // product』s long description
echo $_product->getname(); //product name
echo $_product->getprice(); //product』s regular price
echo $_product->getspecialprice(); //product』s special price
echo $_product->getproducturl(); //product url
echo $_product->getimageurl(); //product』s image url
echo $_product->getsmallimageurl(); //product』s small image url
echo $_product->getthumbnailurl(); //product』s thumbnail image url
4、將產品加入購物車:
$this->getaddtocarturl($_product) ;
注:如果產品購買時需要選擇options下拉框時,該url將進入產品詳情頁,否則直接就如購物車。
5、在前台顯示產品的自定義屬性:
$_product->getresource()->getattribute('code')->getfrontend()->getvalue($_product)
code為屬性建立時的code
二、使用者訂單
1、全部訂單
$_customer= mage::getmodel('customer/customer');
$_customer->loadbyemail('使用者登入郵箱');
// get the customers last order
$orders = mage::getresourcemodel('sales/order_collection')
->addfieldtoselect('*')
->addfieldtofilter('customer_id',$_customer->getid());
->addattributetosort('created_at','desc');
foreach($ordersas $order)
2、最後乙個訂單
$_customer = mage::getmodel('customer/customer');
$_customer->loadbyemail('使用者登入郵箱');
$orders = mage::getresourcemodel('sales/order_collection')
->addfieldtoselect('*')
->addfieldtofilter('customer_id', $_customer->getid())
->addattributetosort('created_at', 'desc')
->setpagesize(1);
echo $orders->getfirstitem()->getid();
怎麼去除Magento產品URL的分類名稱?
magento預設的產品鏈結形式是帶有分類名稱的,如 一級分類 二級分類 產品名.html。為了更好的做seo,現在要改為 產品名.html 方法如下 一 system configuration catalog catalog search engine optimizations use cat...
產品 得到梁寧的產品課心得分享
1.他人定律。你的價值高低不取決於你,取決於他人的需求。也就是說,你的價值不在於你有多好,而在於他人的痛點與你所提供的價值是否匹配。所以要想變成乙個重要的人,必須學會研究和理解他人的痛點,哪兒疼戳哪兒。難點在於世界上並不存在作為乙個集體的 他人 每乙個人都是獨一無二的。因此要在與人建立關係的過程中,...
Spring相關的框架產品
spring 是乙個開放源 的設計層面框架,他解決的是業務邏輯層和其他各層的松耦合問題,因此它將面向介面的程式設計思想貫穿整個系統應用。spring mvc 屬於springframework的後續產品,已經融合在spring web flow裡面。spring 框架提供了構建 web 應用程式的全...