Exemple #1
0
 /**
  * @test
  */
 public function testCatalogCategorySaveAfter()
 {
     $this->_fpc->save('category1', 'category1_cache_id', array(sha1('category_1')));
     $this->_fpc->save('category2', 'category2_cache_id', array(sha1('category_2')));
     $category = new Mage_Catalog_Model_Category();
     $category->setId(1);
     Mage::dispatchEvent('catalog_category_save_after', array('category' => $category));
     $this->assertFalse($this->_fpc->load('category1_cache_id'));
     $this->assertEquals('category2', $this->_fpc->load('category2_cache_id'));
 }
Exemple #2
0
 /**
  * @test
  */
 public function testCatalogCategorySaveAfter()
 {
     $category1Data = new \Lesti_Fpc_Model_Fpc_CacheItem('category1', time(), 'text/html');
     $this->_fpc->save($category1Data, 'category1_cache_id', array(sha1('category_1')));
     $category2Data = new \Lesti_Fpc_Model_Fpc_CacheItem('category2', time(), 'text/html');
     $this->_fpc->save($category2Data, 'category2_cache_id', array(sha1('category_2')));
     $category = new Mage_Catalog_Model_Category();
     $category->setId(1);
     Mage::dispatchEvent('catalog_category_save_after', array('category' => $category));
     $this->assertFalse($this->_fpc->load('category1_cache_id'));
     $this->assertEquals($category2Data, $this->_fpc->load('category2_cache_id'));
 }
Exemple #3
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());
 }
Exemple #4
0
 public function testGetEmailToFriendUrl()
 {
     $product = new Mage_Catalog_Model_Product();
     $product->setId(100);
     $category = new Mage_Catalog_Model_Category();
     $category->setId(10);
     Mage::register('current_category', $category);
     try {
         $this->assertStringEndsWith('sendfriend/product/send/id/100/cat_id/10/', $this->_helper->getEmailToFriendUrl($product));
         Mage::unregister('current_category');
     } catch (Exception $e) {
         Mage::unregister('current_category');
         throw $e;
     }
 }
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    Mage
 * @package     Mage_Catalog
 * @subpackage  performance_tests
 * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
$installer = new Mage_Catalog_Model_Resource_Setup('catalog_setup');
/**
 * After installation system has two categories: root one with ID:1 and Default category with ID:2
 */
$category = new Mage_Catalog_Model_Category();
$category->setId(3)->setName('Category 1')->setParentId(2)->setPath('1/2/3')->setLevel(2)->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->setPosition(1)->save();
$product = new Mage_Catalog_Model_Product();
$product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))->setStoreId(1)->setWebsiteIds(array(1))->setName('Simple Product')->setDescription('Description')->setShortDescription('Desc')->setSku('simple')->setPrice(10)->setWeight(18)->setCategoryIds(array(2, 3))->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->setTaxClassId(0)->save();
$stockItem = new Mage_CatalogInventory_Model_Stock_Item();
$stockItem->setProductId($product->getId())->setTypeId($product->getTypeId())->setStockId(Mage_CatalogInventory_Model_Stock::DEFAULT_STOCK_ID)->setIsInStock(1)->setQty(10000)->setUseConfigMinQty(1)->setUseConfigBackorders(1)->setUseConfigMinSaleQty(1)->setUseConfigMaxSaleQty(1)->setUseConfigNotifyStockQty(1)->setUseConfigManageStock(1)->setUseConfigQtyIncrements(1)->setUseConfigEnableQtyInc(1)->save();
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    Magento
 * @package     Mage_Catalog
 * @subpackage  Test
 * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
/**
 * Products generation to test base data
 */
$testCases = (include dirname(__FILE__) . '/_algorithm_base_data.php');
$installer = new Mage_Catalog_Model_Resource_Setup('catalog_setup');
/**
 * After installation system has two categories: root one with ID:1 and Default category with ID:2
 */
$category = new Mage_Catalog_Model_Category();
$category->setId(3)->setName('Root Category')->setParentId(2)->setPath('1/2/3')->setLevel(2)->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->setPosition(1)->save();
$lastProductId = 0;
foreach ($testCases as $index => $testCase) {
    $category = new Mage_Catalog_Model_Category();
    $position = $index + 1;
    $categoryId = $index + 4;
    $category->setId($categoryId)->setName('Category ' . $position)->setParentId(3)->setPath('1/2/3/' . $categoryId)->setLevel(3)->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->setIsAnchor(true)->setPosition($position)->save();
    foreach ($testCase[0] as $price) {
        $product = new Mage_Catalog_Model_Product();
        $productId = $lastProductId + 1;
        $product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)->setId($productId)->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))->setStoreId(1)->setWebsiteIds(array(1))->setName('Simple Product ' . $productId)->setSku('simple-' . $productId)->setPrice($price)->setWeight(18)->setCategoryIds(array($categoryId))->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->save();
        ++$lastProductId;
    }
}
Exemple #7
0
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Open Software License (OSL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/osl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    Magento
 * @package     Mage_Catalog
 * @subpackage  integration_tests
 * @copyright   Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
$category = new Mage_Catalog_Model_Category();
$category->setId(3)->setName('Category 1')->setParentId(2)->setPath('1/2/3')->setLevel(2)->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->setPosition(1)->save();
$category = new Mage_Catalog_Model_Category();
$category->setId(4)->setName('Category 2')->setParentId(2)->setPath('1/2/4')->setLevel(2)->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->setPosition(2)->save();
$category = new Mage_Catalog_Model_Category();
$category->setId(5)->setName('Old Root')->setParentId(1)->setPath('1/5')->setLevel(1)->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->setPosition(3)->save();
$product = new Mage_Catalog_Model_Product();
$product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)->setId(1)->setAttributeSetId(4)->setWebsiteIds(array(1))->setName('Simple Product')->setSku('simple')->setPrice(10)->setCategoryIds(array(3))->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->save();
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    Magento
 * @package     Mage_Catalog
 * @subpackage  Test
 * @copyright   Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
/**
 * Products generation to test base data
 */
$prices = array(5, 10, 15, 20, 50, 100, 150);
$installer = new Mage_Catalog_Model_Resource_Setup('catalog_setup');
/**
 * After installation system has two categories: root one with ID:1 and Default category with ID:2
 */
$category = new Mage_Catalog_Model_Category();
$category->setId(3)->setName('Root Category')->setParentId(2)->setPath('1/2/3')->setLevel(2)->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->setPosition(1)->save();
$category = new Mage_Catalog_Model_Category();
$category->setId(4)->setName('PLN Category')->setParentId(3)->setPath('1/2/3/4')->setLevel(3)->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->setIsAnchor(true)->setPosition(1)->save();
$lastProductId = 0;
foreach ($prices as $price) {
    $product = new Mage_Catalog_Model_Product();
    $productId = $lastProductId + 1;
    $product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)->setId($productId)->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))->setStoreId(1)->setWebsiteIds(array(1))->setName('Simple Product ' . $productId)->setSku('simple-' . $productId)->setPrice($price)->setWeight(18)->setCategoryIds(array(4))->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->save();
    ++$lastProductId;
}
Exemple #9
0
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    Magento
 * @package     Mage_Catalog
 * @subpackage  integration_tests
 * @copyright   Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
$installer = new Mage_Catalog_Model_Resource_Setup('catalog_setup');
/**
 * After installation system has two categories: root one with ID:1 and Default category with ID:2
 */
$category = new Mage_Catalog_Model_Category();
$category->setId(3)->setName('Category 1')->setParentId(2)->setPath('1/2/3')->setLevel(2)->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->setPosition(1)->save();
$category = new Mage_Catalog_Model_Category();
$category->setId(4)->setName('Category 1.1')->setParentId(3)->setPath('1/2/3/4')->setLevel(3)->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->setIsAnchor(true)->setPosition(1)->save();
$category = new Mage_Catalog_Model_Category();
$category->setId(5)->setName('Category 1.1.1')->setParentId(4)->setPath('1/2/3/4/5')->setLevel(4)->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->setPosition(2)->setCustomUseParentSettings(0)->setCustomDesign('default/default/blue')->save();
$category = new Mage_Catalog_Model_Category();
$category->setId(6)->setName('Category 2')->setParentId(2)->setPath('1/2/6')->setLevel(2)->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->setPosition(2)->save();
$category = new Mage_Catalog_Model_Category();
$category->setId(7)->setName('Movable')->setParentId(2)->setPath('1/2/7')->setLevel(2)->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->setPosition(3)->save();
$category = new Mage_Catalog_Model_Category();
$category->setId(8)->setName('Inactive')->setParentId(2)->setPath('1/2/8')->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(false)->setPosition(4)->save();
$product = new Mage_Catalog_Model_Product();
$product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)->setId(1)->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))->setStoreId(1)->setWebsiteIds(array(1))->setName('Simple Product')->setSku('simple')->setPrice(10)->setWeight(18)->setCategoryIds(array(2, 3, 4))->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->save();
$product = new Mage_Catalog_Model_Product();
$product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)->setId(2)->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))->setStoreId(1)->setWebsiteIds(array(1))->setName('Simple Product Two')->setSku('simple_product_two')->setPrice(45.67)->setWeight(56)->setCategoryIds(array(5))->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->save();
 */
/**
 * Create categories
 */
$categoriesNumber = 200;
$maxNestingLevel = 3;
$anchorStep = 2;
$nestingLevel = 1;
$parentCategoryId = $defaultParentCategoryId = Mage::app()->getStore()->getRootCategoryId();
$nestingPath = "1/{$parentCategoryId}";
$categoryPath = '';
$categoryIndex = 1;
$categories = array();
$category = new Mage_Catalog_Model_Category();
while ($categoryIndex <= $categoriesNumber) {
    $category->setId(null)->setName("Category {$categoryIndex}")->setParentId($parentCategoryId)->setPath($nestingPath)->setLevel($nestingLevel)->setAvailableSortBy('name')->setDefaultSortBy('name')->setIsActive(true)->setIsAnchor($categoryIndex++ % $anchorStep == 0)->save();
    $categoryPath .= '/' . $category->getName();
    $categories[] = ltrim($categoryPath, '/');
    if ($nestingLevel++ == $maxNestingLevel) {
        $nestingLevel = 1;
        $parentCategoryId = $defaultParentCategoryId;
        $nestingPath = '1';
        $categoryPath = '';
    } else {
        $parentCategoryId = $category->getId();
    }
    $nestingPath .= "/{$parentCategoryId}";
}
/**
 * Create products
 */