/** * I'm not sure what exactly needs to be done here, will debug later. * * * Generate either id path, request path or target path for product and/or category * * For generating id or system path, either product or category is required * For generating request path - category is required * $parentPath used only for generating category path * * @param string $type * @param Varien_Object $product * @param Varien_Object $category * @param string $parentPath * @return string * @throws Mage_Core_Exception * @todo Test category browsing in typo3 */ public function generatePath($type = 'target', $product = null, $category = null, $parentPath = null) { if (!Mage::getSingleton('Flagbit_Typo3connect/Core')->isEnabled()) { return parent::generatePath($type, $product, $category, $parentPath); } return parent::generatePath($type, $product, $category, $parentPath); }
/** * Write data into enterprise_url_rewrites * * @param Mage_Catalog_Model_Category $category * @param Mage_Core_Model_Store $store * @param string $requestPath * @param int $valueId * * @return Mage_Catalog_Model_Category */ protected function _saveRewrite(Mage_Catalog_Model_Category $category, Mage_Core_Model_Store $store, $requestPath, $valueId) { $this->_uniqueIdentifier = $this->_factory->getHelper('core')->uniqHash(); $targetPath = $this->_urlModel->generatePath('type', null, $category); $rewriteData = array('request_path' => $requestPath, 'target_path' => $targetPath, 'guid' => $this->_uniqueIdentifier, 'is_system' => new Zend_Db_Expr(1), 'identifier' => $requestPath, 'value_id' => $valueId, 'store_id' => $store->getId(), 'entity_type' => Enterprise_Catalog_Model_Category::URL_REWRITE_ENTITY_TYPE); $this->_categoryId = $category->getId(); $this->_storeId = $store->getId(); $this->_cleanOldUrlRewrite(); $this->_connection->insert($this->_getTable('enterprise_urlrewrite/url_rewrite'), $rewriteData); $this->_refreshRelation(); $category->setRequestPath($requestPath); $this->_changedCategoryIds[$category->getId()] = $category->getId(); return $category; }
/** * @dataProvider generatePathDataProvider */ public function testGeneratePath($type, $product, $category, $parentPath, $result) { $this->assertEquals($result, $this->_model->generatePath($type, $product, $category, $parentPath)); }