2
如何獲取hookdisplayTop中的當前產品?我怎樣才能得到一個鉤子內的當前產品?
這是當前的方法,我要確保我在 「產品」 頁面:
if (Dispatcher::getInstance()->getController() == "product") {
//i'm in the product page
}
如何獲取hookdisplayTop中的當前產品?我怎樣才能得到一個鉤子內的當前產品?
這是當前的方法,我要確保我在 「產品」 頁面:
if (Dispatcher::getInstance()->getController() == "product") {
//i'm in the product page
}
如果您在ProductController的是,你總是可以得到當前產品的PRODUCT_ID無需求助於倍率(如果過度使用這些可以迅速失控的,應該是最後的手段):
if ($id_product = (int)Tools::getValue('id_product'))
$product = new Product($id_product,
true,
$this->context->language->id,
$this->context->shop->id);
if (!Validate:: isLoadedObject($product))
return;
解決:
class ProductController extends ProductControllerCore
{
public function getProduct()
{
return $this->product;
}
}
你到底什麼意思?你想檢測你是否在產品頁面,或者你想獲得當前的產品ID?請清楚,然後我會寫下你如何做到這一點。 – 2013-05-08 06:12:01
如果我在產品頁面中,我想獲取當前產品對象。 – Eduardo 2013-05-08 18:02:35