/**
  * Retrieve category url
  *
  * @param   Mage_Catalog_Model_Category $category
  * @return  string
  */
 public function getCategoryUrl($category)
 {
     if ($category instanceof Mage_Catalog_Model_Category) {
         return $category->getUrl();
     }
     return Mage::getModel('catalog/category')->setData($category->getData())->getUrl();
 }
Beispiel #2
0
 /**
  * Get url for category data
  *
  * @param Mage_Catalog_Model_Category $category
  * @return string
  */
 public function getCategoryUrl($category)
 {
     if ($category instanceof Mage_Catalog_Model_Category) {
         $url = $category->getUrl();
     } else {
         $url = $this->_getCategoryInstance()->setData($category->getData())->getUrl();
     }
     return $url;
 }
 /**
  * Override return URL fucntion to support city\zipcode oriented URLs
  *
  * 
  * @return string $url
  */
 public function getUrl()
 {
     // Init variables
     $regUrlKey = Mage::registry('bloom_nations_zipcode_info');
     $primaryCity = false;
     $zipcode = false;
     $url = false;
     if (empty($regUrlKey)) {
         // Try to get current location info
         if (isset($_COOKIE['bloom_nations_zipcode_info'])) {
             $regUrlKey = $_COOKIE['bloom_nations_zipcode_info'];
         } else {
             // Retreat to basic get URL function if initialization failed
             return parent::getUrl();
         }
     }
     // Check if this is one of the Store Fronts
     if ($this->getParentCategory() && $this->getParentCategory()->getId() == 20) {
         $cat = $this;
         if (!$this->hasData('yelp_api')) {
             $cat = Mage::getModel('catalog/category')->load($this->getId());
         }
         if ($vendor = Mage::getModel('udropship/vendor')->load($cat->getYelpApi())) {
             $city = str_replace(' ', '-', strtolower($vendor->getCity()));
             $url = '/' . $city . '-' . $cat->getUrlKey() . '.html';
             return $url;
         }
     }
     // Regular Category URL
     if (!empty($regUrlKey)) {
         $regUrlKey = strtolower(str_replace(' ', '-', str_replace(',', '', $regUrlKey)));
         // Zipcode info in the location
         if (isset($_COOKIE['bloom_nations_zipcode']) && strlen($_COOKIE['bloom_nations_zipcode']) == 5) {
             $zipcode = addslashes((string) $_COOKIE['bloom_nations_zipcode']);
         }
         if (Mage::registry('current_category')) {
             $zipcode = '';
         }
         if (isset($_GET['zipcode'])) {
             $zipcode = addslashes((string) $_GET['zipcode']);
         }
         // Primary city logic
         if (Mage::registry('primary-city')) {
             $regUrlKey = Mage::registry('primary-city') . '-ca/' . substr_replace($regUrlKey, '', -3);
         } elseif (isset($_COOKIE['primary-city']) && !empty($_COOKIE['primary-city'])) {
             $regUrlKey = $_COOKIE['primary-city'] . '-ca/' . substr_replace($regUrlKey, '', -3);
         }
         $url = '/' . $regUrlKey . '/' . $this->getUrlKey() . '-bouquets.html';
         if (strlen($zipcode) == 5) {
             $url .= '?zipcode=' . $zipcode;
         }
         return $url;
     }
     return parent::getUrl();
 }
 /**
  * linktoCategoryThumbnail
  *
  * wraps the category thumbnail with a link to the category
  *
  * @param  Mage_Catalog_Model_Category  $category
  * @param  string                       $linkCss     # CSS classes
  * @param  integer|string               $width       # thumbnail width
  * @param  integer|string               $height      # thumbnail height
  * @return string
  */
 public function linktoCategoryThumbnail(Mage_Catalog_Model_Category $category, $linkCss = '', $width = 168, $height = 168)
 {
     $link = '';
     if ($category->getIsActive()) {
         $catUrl = $category->getUrl();
         $catName = $this->htmlEscape($category->getName());
         $catThumbnail = self::displayCategoryThumbnail($category, $width, $height);
         $link = "\n                <a class='{$linkCss}' href='{$catUrl}' title='{$catName}'>\n                    {$catThumbnail}\n                    <span class='category-name'>{$catName}</span>\n                </a>\n            ";
     }
     return $link;
 }
Beispiel #5
0
 public function testGetUrl()
 {
     $this->assertStringEndsWith('catalog/category/view/', $this->_model->getUrl());
     $this->_model->setUrl('test_url');
     $this->assertEquals('test_url', $this->_model->getUrl());
     $this->_model->setUrl(null);
     $this->_model->setRequestPath('test_path');
     $this->assertStringEndsWith('test_path', $this->_model->getUrl());
     $this->_model->setUrl(null);
     $this->_model->setRequestPath(null);
     $this->_model->setId(1000);
     $this->assertStringEndsWith('catalog/category/view/id/1000/', $this->_model->getUrl());
 }
 /**
  * Get Category URL in a specific store
  *
  * @param Mage_Catalog_Model_Category $category
  * @param Mage_Core_Model_Store       $store
  *
  * @return string
  */
 public function getCategoryUrlInStore($category, $store)
 {
     if (!$store instanceof Mage_Core_Model_Store) {
         $store = Mage::app()->getStore($store);
     }
     $idPath = 'category/' . $category->getId();
     foreach ($this->getStoreUrls($idPath) as $storeId => $url) {
         if ($storeId == $store->getId()) {
             return $url;
         }
     }
     return $category->getUrl();
 }
Beispiel #7
0
 /**
  * Add URLs to the queue by category model
  *
  * @param Mage_Catalog_Model_Category $category
  * @return int
  */
 public function addCategoryToCrawlerQueue($category)
 {
     $catUrls = array();
     $origStore = Mage::app()->getStore();
     foreach (Mage::app()->getStores() as $storeId => $store) {
         Mage::app()->setCurrentStore($store);
         $catUrls[] = $category->getUrl();
     }
     Mage::app()->setCurrentStore($origStore);
     return $this->addUrlsToCrawlerQueue($catUrls);
 }
 /**
  * Get url for category data
  *
  * @param Mage_Catalog_Model_Category $category
  * @return string
  */
 public function getCategoryUrl($category)
 {
     if ($category instanceof Mage_Catalog_Model_Category) {
         $url = $category->getUrl();
     } else {
         $url = $this->_getCategoryInstance()->setData($category->getData())->getUrl();
     }
     return Mage::getModel('core/url')->sessionUrlVar($url);
 }
Beispiel #9
0
 /**
  * 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());
 }
 public function getObject(Mage_Catalog_Model_Category $category)
 {
     /** @var $productCollection Mage_Catalog_Model_Resource_Product_Collection */
     $productCollection = $category->getProductCollection();
     $category->setProductCount($productCollection->addMinimalPrice()->count());
     $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' => $category->getUrl(), '_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;
 }
Beispiel #11
0
 public function getCategoryUrl(Mage_Catalog_Model_Category $category)
 {
     return $category->getUrl();
 }
Beispiel #12
0
 /**
  * Based on provided category object returns small category array with necessary data.
  * 
  * @param Mage_Catalog_Model_Category $c
  * @return array
  */
 public function categoryToArray($c)
 {
     $category = array();
     $category['url'] = $c->getUrl();
     $category['name'] = Mage::helper('core')->htmlEscape($c->getName());
     $category['image'] = $c->getImage();
     $category['thumbnail'] = $c->getThumbnail();
     $category['description'] = Mage::helper('core')->htmlEscape($c->getDescription());
     $category['meta_description'] = Mage::helper('core')->htmlEscape($c->getMetaDescription());
     return $category;
 }
Beispiel #13
0
 /**
  * @param Mage_Catalog_Model_Category $category
  * @return mixed
  */
 public function getDeepLinkUrl($category)
 {
     return $this->_getExportHelper()->parseUrl($category->getUrl());
 }