本文整理汇总了PHP中product::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP product::getId方法的具体用法?PHP product::getId怎么用?PHP product::getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类product
的用法示例。
在下文中一共展示了product::getId方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: transform
/**
* Transforms an object (product) to a string (number).
*
* @param product|null $product
* @return string
*/
public function transform($product)
{
if (null === $product) {
return '';
}
return $product->getId();
}
示例2: getReviewsUrl
/**
* Rewriting this method to output new urls.
* Checks if a rewrite already exists, otherwise creates it.
*
* @param product $product
* @param category $category
* @param array $params
*/
public function getReviewsUrl($product, $category = null, $params = array())
{
$routePath = '';
$routeParams = $params;
$storeId = $product->getStoreId();
if (!$storeId) {
$storeId = Mage::app()->getStore()->getId();
$product->setStoreId($storeId);
}
$categoryId = $product->getCategoryId() && !$product->getDoNotUseCategoryId() ? $product->getCategoryId() : null;
$idPath = sprintf('reviews/%d', $product->getId());
//if ($categoryId) {
// $idPath = sprintf('%s/%d', $idPath, $categoryId);
//}
$rewrite = $this->getUrlRewrite();
$rewrite->setStoreId($storeId)->loadByIdPath($idPath);
$oldRequestPath = $product->getRequestPath();
if ($rewrite->getId()) {
// REWRITE RULE EXISTS
$requestPath = $rewrite->getRequestPath();
$product->setRequestPath($requestPath);
} else {
// CREATE REWRITE RULE
$model = Mage::getModel('reviewsearchfriendlyurls/url');
$requestPath = $model->addUrlRewrite($product);
}
if (isset($routeParams['_store'])) {
$storeId = Mage::app()->getStore($routeParams['_store'])->getId();
}
if ($storeId != Mage::app()->getStore()->getId()) {
$routeParams['_store_to_url'] = true;
}
if (!empty($requestPath)) {
$routeParams['_direct'] = $requestPath;
} else {
$routePath = 'catalog/product/view';
$routeParams['id'] = $product->getId();
$routeParams['s'] = $product->getUrlKey();
//if ($categoryId) {
// $routeParams['category'] = $categoryId;
//}
}
// reset cached URL instance GET query params
if (!isset($routeParams['_query'])) {
$routeParams['_query'] = array();
}
$url = $this->getUrlInstance()->setStore($storeId)->getUrl($routePath, $routeParams);
$product->setRequestPath($oldRequestPath);
return $url;
}
示例3: deleteOne
/**
* Delete
*/
public function deleteOne(product $p)
{
try {
dibi::query('DELETE FROM [:prefix:products]', 'WHERE [id] = %i', $p->getId(), 'LIMIT 1');
dibi::query('DELETE FROM [:prefix:pages]', 'WHERE [nice_name] = %s', $p->getNiceName(), 'LIMIT 1');
//<fulltext>
foreach (fulltext::index()->termDocs(new Zend_Search_Lucene_Index_Term($p->getId(), 'id')) as $id) {
fulltext::index()->delete($id);
}
fulltext::dirty($p->getId(), FALSE);
//</fulltext>
return TRUE;
} catch (Exception $e) {
return FALSE;
}
}