本文整理汇总了PHP中Mage_Catalog_Model_Category::getRequestPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Category::getRequestPath方法的具体用法?PHP Mage_Catalog_Model_Category::getRequestPath怎么用?PHP Mage_Catalog_Model_Category::getRequestPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Category
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Category::getRequestPath方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCategoryUrl
/**
* Retrieve Url for specified category
*
* @param Mage_Catalog_Model_Category $category
* @return string
*/
public function getCategoryUrl(Mage_Catalog_Model_Category $category)
{
$url = $category->getData('url');
if (null !== $url) {
return $url;
}
Varien_Profiler::start('REWRITE: ' . __METHOD__);
if ($category->hasData('request_path') && $category->getRequestPath() != '') {
$category->setData('url', $this->getUrlInstance()->getDirectUrl($category->getRequestPath()));
Varien_Profiler::stop('REWRITE: ' . __METHOD__);
return $category->getData('url');
}
$requestPath = $this->_getRequestPath($category);
if ($requestPath) {
$category->setRequestPath($requestPath);
$category->setData('url', $this->getUrlInstance()->getDirectUrl($requestPath));
Varien_Profiler::stop('REWRITE: ' . __METHOD__);
return $category->getData('url');
}
Varien_Profiler::stop('REWRITE: ' . __METHOD__);
$category->setData('url', $category->getCategoryIdUrl());
return $category->getData('url');
}
示例2: drawItemSingle
/**
* Enter description here...
*
* @param Mage_Catalog_Model_Category $category
* @param int $level
* @param boolean $last
* @return string
*/
public function drawItemSingle($category, $level = 0, $last = false)
{
$html = '';
if (!$category->getIsActive()) {
return $html;
}
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
$childrenCount = $children->count();
}
$hasChildren = $children && $childrenCount;
$html .= '<li';
if ($hasChildren) {
$html .= ' onmouseover="toggleMenu(this,1)" onmouseout="toggleMenu(this,0)"';
}
$html .= ' class="level' . $level;
$html .= ' nav-' . str_replace('/', '-', Mage::helper('catalog/category')->getCategoryUrlPath($category->getRequestPath()));
if ($this->isCategoryActive($category)) {
$html .= ' active';
}
if ($last) {
$html .= ' last';
}
if ($hasChildren) {
$cnt = 0;
foreach ($children as $child) {
if ($child->getIsActive()) {
$cnt++;
}
}
if ($cnt > 0) {
$html .= ' parent';
}
}
$html .= '">' . "\n";
$html .= '<a href="' . $this->getCategoryUrl($category) . '"><span>' . $this->htmlEscape($category->getName()) . '</span></a>' . "\n";
$html .= '</li>' . "\n";
return $html;
}
示例3: _getCategoryRequestPath
/**
* Get category request path
*
* @param Mage_Catalog_Model_Category $category
* @return string
* @deprecated since 1.13.0.2
*/
protected function _getCategoryRequestPath(Mage_Catalog_Model_Category $category)
{
/**
* Initialize request_path value
*/
$category->getUrl();
/** @var $helper Enterprise_Catalog_Helper_Data */
$helper = $this->_factory->getHelper('enterprise_catalog');
return $helper->getCategoryRequestPath($category->getRequestPath(), $category->getStoreId());
}
示例4: _getFullUrl
/**
* Get full URL by request path if it exist or by ID-URL
*
* @param Mage_Catalog_Model_Category $category
* @return string
* @deprecated since 1.13.0.2
*/
protected function _getFullUrl(Mage_Catalog_Model_Category $category)
{
return $category->getRequestPath() ? $this->_getDirectUrl($category) : $category->getCategoryIdUrl();
}
示例5: _getDirectUrl
/**
* Returns category URL by which it can be accessed
* @param Mage_Catalog_Model_Category $category
* @return string
*/
protected function _getDirectUrl(Mage_Catalog_Model_Category $category)
{
return $this->getUrlInstance()->getDirectUrl($category->getRequestPath());
}
示例6: testGetRequestPath
public function testGetRequestPath()
{
$this->assertNull($this->_model->getRequestPath());
$this->_model->setData('request_path', 'test');
$this->assertEquals('test', $this->_model->getRequestPath());
}
示例7: getObject
public function getObject(Mage_Catalog_Model_Category $category)
{
/** @var $productCollection Mage_Catalog_Model_Resource_Product_Collection */
$productCollection = $category->getProductCollection();
$productCollection = $productCollection->addMinimalPrice();
$category->setProductCount($productCollection->getSize());
$transport = new Varien_Object();
Mage::dispatchEvent('algolia_category_index_before', array('category' => $category, 'custom_data' => $transport));
$customData = $transport->getData();
$storeId = $category->getStoreId();
$category->getUrlInstance()->setStore($storeId);
$path = '';
foreach ($category->getPathIds() as $categoryId) {
if ($path != '') {
$path .= ' / ';
}
$path .= $this->getCategoryName($categoryId, $storeId);
}
$image_url = NULL;
try {
$image_url = $category->getImageUrl();
} catch (Exception $e) {
/* no image, no default: not fatal */
}
$data = array('objectID' => $category->getId(), 'name' => $category->getName(), 'path' => $path, 'level' => $category->getLevel(), 'url' => Mage::getBaseUrl() . $category->getRequestPath(), '_tags' => array('category'), 'popularity' => 1, 'product_count' => $category->getProductCount());
if (!empty($image_url)) {
$data['image_url'] = $image_url;
}
foreach ($this->config->getCategoryAdditionalAttributes($storeId) as $attribute) {
$value = $category->getData($attribute['attribute']);
$attribute_ressource = $category->getResource()->getAttribute($attribute['attribute']);
if ($attribute_ressource) {
$value = $attribute_ressource->getFrontend()->getValue($category);
}
if (isset($data[$attribute['attribute']])) {
$value = $data[$attribute['attribute']];
}
if ($value) {
$data[$attribute['attribute']] = $value;
}
}
$data = array_merge($data, $customData);
foreach ($data as &$data0) {
$data0 = $this->try_cast($data0);
}
return $data;
}
示例8: drawItem
/**
* Enter description here...
*
* @param Mage_Catalog_Model_Category $category
* @param int $level
* @param boolean $last
* @return string
*/
public function drawItem($category, $level = 0, $last = false)
{
$html = '';
if (!$category->getIsActive()) {
return $html;
}
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
$childrenCount = $children->count();
}
$hasChildren = $children && $childrenCount;
$html .= '<li';
if ($hasChildren) {
//$html.= ' onmouseover="Element.addClassName(this, \'over\') " onmouseout="Element.removeClassName(this, \'over\') "';
}
$html .= ' class="level' . $level;
$html .= ' nav-' . str_replace('/', '-', Mage::helper('catalog/category')->getCategoryUrlPath($category->getRequestPath()));
if ($this->isCategoryActive($category)) {
$html .= ' active';
}
if ($last) {
$html .= ' last';
}
if ($hasChildren) {
$cnt = 0;
foreach ($children as $child) {
if ($child->getIsActive()) {
$cnt++;
}
}
if ($cnt > 0) {
$html .= ' parent';
}
}
$html .= '">' . "\n";
if ($level == 0) {
$html .= '<a href="' . $this->getCategoryUrl($category) . '"><span>' . $this->htmlEscape($category->getName()) . '</span></a><span class="head"><a href="#" style="float:right;"></a></span>' . "\n";
} else {
$html .= '<a href="' . $this->getCategoryUrl($category) . '"><span>' . $this->htmlEscape($category->getName()) . '</span></a>' . "\n";
}
if ($hasChildren) {
$j = 0;
$htmlChildren = '';
foreach ($children as $child) {
if ($child->getIsActive()) {
$htmlChildren .= $this->drawItem($child, $level + 1, ++$j >= $cnt);
}
}
if (!empty($htmlChildren)) {
$html .= '<ul class="level' . $level . '">' . "\n" . $htmlChildren . '</ul>';
}
}
$html .= '</li>' . "\n";
return $html;
}
示例9: drawItem
/**
* Enter description here...
*
* @param Mage_Catalog_Model_Category $category
* @param int $level
* @param boolean $last
* @return string
*/
public function drawItem($category, $level = 0, $last = false)
{
$html = '';
if (!$category->getIsActive()) {
return $html;
}
$children = $category->getChildren();
$hasChildren = $children && $children->count();
$html .= '<li';
if ($hasChildren) {
$html .= ' onmouseover="toggleMenu(this,1)" onmouseout="toggleMenu(this,0)"';
}
$html .= ' class="level' . $level;
$html .= ' nav-' . str_replace('/', '-', Mage::helper('catalog/category')->getCategoryUrlPath($category->getRequestPath()));
if ($this->isCategoryActive($category)) {
$html .= ' active';
}
if ($last) {
$html .= ' last';
}
if ($hasChildren) {
$cnt = 0;
foreach ($children as $child) {
if ($child->getIsActive()) {
$cnt++;
}
}
$html .= ' parent';
}
$html .= '">' . "\n";
$html .= '<a href="' . $this->getCategoryUrl($category) . '"><span>' . $this->htmlEscape($category->getName()) . '</span></a>' . "\n";
//$html.= '<span>'.$level.'</span>';
if ($hasChildren) {
$j = 0;
$htmlChildren = '';
foreach ($children as $child) {
if ($child->getIsActive()) {
$htmlChildren .= $this->drawItem($child, $level + 1, ++$j >= $cnt);
}
}
if (!empty($htmlChildren)) {
$html .= '<ul class="level' . $level . '">' . "\n" . $htmlChildren . '</ul>';
}
}
$html .= '</li>' . "\n";
return $html;
}
示例10: drawItem
/**
* Enter description here...
*
* @param Mage_Catalog_Model_Category $category
* @param int $level
* @param boolean $last
* @return string
*/
public function drawItem($category, $level = 0, $last = false)
{
$html = '';
if (!$category->getIsActive()) {
return $html;
}
if (Mage::helper('catalog/category_flat')->isEnabled()) {
$children = $category->getChildrenNodes();
$childrenCount = count($children);
} else {
$children = $category->getChildren();
$childrenCount = $children->count();
}
$hasChildren = $children && $childrenCount;
$html .= '<li';
$html .= ' class="item';
$html .= ' nav-' . str_replace('/', '-', Mage::helper('catalog/category')->getCategoryUrlPath($category->getRequestPath()));
if ($this->isCategoryActive($category)) {
$html .= ' active';
}
if ($last) {
$html .= ' last';
}
if ($hasChildren) {
$cnt = 0;
foreach ($children as $child) {
if ($child->getIsActive()) {
$cnt++;
}
}
if ($cnt > 0) {
$html .= ' hasChild';
}
}
$html .= '">' . "\n";
if ($level == 0) {
if ($hasChildren) {
$html .= '<a class="item" href="' . $this->getCategoryUrl($category) . '">' . $this->htmlEscape($category->getName()) . '</a>' . "\n";
//$html.= '<span class="collapse">collapse</span>';
} else {
$html .= '<a class="item" href="' . $this->getCategoryUrl($category) . '">' . $this->htmlEscape($category->getName()) . '</a>' . "\n";
}
} else {
if ($hasChildren) {
$html .= '<a class="item" href="' . $this->getCategoryUrl($category) . '">' . $this->htmlEscape($category->getName()) . '</a>' . "\n";
//$html.= '<span class="collapse">collapse</span>';
} else {
$html .= '<a class="item" href="' . $this->getCategoryUrl($category) . '">' . $this->htmlEscape($category->getName()) . '</a>' . "\n";
}
}
if ($hasChildren) {
$j = 0;
$htmlChildren = '';
foreach ($children as $child) {
if ($child->getIsActive()) {
$htmlChildren .= $this->drawItem($child, $level + 1, ++$j >= $cnt);
}
}
if (!empty($htmlChildren)) {
$html .= '<ul class="detail-parent">' . "\n" . $htmlChildren . '</ul>';
}
}
$html .= '</li>' . "\n";
return $html;
}