当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Catalog_Model_Category::setId方法代码示例

本文整理汇总了PHP中Mage_Catalog_Model_Category::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Category::setId方法的具体用法?PHP Mage_Catalog_Model_Category::setId怎么用?PHP Mage_Catalog_Model_Category::setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Catalog_Model_Category的用法示例。


在下文中一共展示了Mage_Catalog_Model_Category::setId方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCatalogCategorySaveAfter

 /**
  * @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'));
 }
开发者ID:AndreKlang,项目名称:Lesti_Fpc,代码行数:13,代码来源:Save.php

示例2: testCatalogCategorySaveAfter

 /**
  * @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'));
 }
开发者ID:kurtinge,项目名称:Lesti_Fpc,代码行数:15,代码来源:Save.php

示例3: testGetUrl

 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());
 }
开发者ID:natxetee,项目名称:magento2,代码行数:13,代码来源:CategoryTest.php

示例4: testGetEmailToFriendUrl

 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;
     }
 }
开发者ID:NatashaOlut,项目名称:Mage_Test,代码行数:15,代码来源:Product.php

示例5:

 *
 * 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();
开发者ID:nemphys,项目名称:magento2,代码行数:31,代码来源:catalog_category.php

示例6: dirname

 * 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;
    }
}
开发者ID:NatashaOlut,项目名称:Mage_Test,代码行数:31,代码来源:products_base.php

示例7:

 *
 * 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();
开发者ID:relue,项目名称:magento2,代码行数:31,代码来源:url_rewrites.php

示例8: array

 * 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;
}
开发者ID:NatashaOlut,项目名称:Mage_Test,代码行数:31,代码来源:products_advanced.php

示例9:

 *
 * 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();
开发者ID:relue,项目名称:magento2,代码行数:31,代码来源:categories.php

示例10: array

 */
/**
 * 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
 */
开发者ID:nayanchamp,项目名称:magento2,代码行数:31,代码来源:catalog_200_categories_80k_products.php


注:本文中的Mage_Catalog_Model_Category::setId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。