* * 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();
* 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) 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'); $attributeSetId = $installer->getAttributeSetId('catalog_product', 'Default'); $entityModel = new Mage_Eav_Model_Entity(); $entityTypeId = $entityModel->setType(Mage_Catalog_Model_Product::ENTITY)->getTypeId(); $groupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId); $attribute = new Mage_Catalog_Model_Resource_Eav_Attribute(); $attribute->setAttributeCode('filterable_attribute_a')->setEntityTypeId($entityTypeId)->setAttributeGroupId($groupId)->setAttributeSetId($attributeSetId)->setIsFilterable(1)->setIsUserDefined(1)->save(); $attribute = new Mage_Catalog_Model_Resource_Eav_Attribute(); $attribute->setAttributeCode('filterable_attribute_b')->setEntityTypeId($entityTypeId)->setAttributeGroupId($groupId)->setAttributeSetId($attributeSetId)->setIsFilterable(1)->setIsUserDefined(1)->save();
* 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 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) */ /* Create attribute */ $installer = new Mage_Catalog_Model_Resource_Setup('catalog_setup'); $attribute = new Mage_Catalog_Model_Resource_Eav_Attribute(); $attribute->setData(array('attribute_code' => 'attribute_with_option', 'entity_type_id' => $installer->getEntityTypeId('catalog_product'), 'is_global' => 1, 'frontend_input' => 'select', 'is_filterable' => 1, 'option' => array('value' => array('option_0' => array(0 => 'Option Label'))), 'backend_type' => 'int')); $attribute->save(); /* Assign attribute to attribute set */ $installer->addAttributeToGroup('catalog_product', 'Default', 'General', $attribute->getId()); /* Create simple products per each option */ $options = new Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection(); $options->setAttributeFilter($attribute->getId()); foreach ($options as $option) { $product = new Mage_Catalog_Model_Product(); $product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))->setWebsiteIds(array(1))->setName('Simple Product ' . $option->getId())->setSku('simple_product_' . $option->getId())->setPrice(10)->setCategoryIds(array(2))->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->setStockData(array('use_config_manage_stock' => 1, 'qty' => 5, 'is_in_stock' => 1))->save(); Mage::getSingleton('Mage_Catalog_Model_Product_Action')->updateAttributes(array($product->getId()), array($attribute->getAttributeCode() => $option->getId()), $product->getStoreId()); }
* 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; } }
* 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) */ /* Create attribute */ $installer = new Mage_Catalog_Model_Resource_Setup('catalog_setup'); $attribute = new Mage_Catalog_Model_Resource_Eav_Attribute(); $attribute->setData(array('attribute_code' => 'test_configurable', 'entity_type_id' => $installer->getEntityTypeId('catalog_product'), 'is_global' => 1, 'is_user_defined' => 1, 'frontend_input' => 'select', 'is_unique' => 0, 'is_required' => 1, 'is_configurable' => 1, 'is_searchable' => 0, 'is_visible_in_advanced_search' => 0, 'is_comparable' => 0, 'is_filterable' => 0, 'is_filterable_in_search' => 0, 'is_used_for_promo_rules' => 0, 'is_html_allowed_on_front' => 1, 'is_visible_on_front' => 0, 'used_in_product_listing' => 0, 'used_for_sort_by' => 0, 'frontend_label' => array(0 => 'Test Configurable'), 'option' => array('value' => array('option_0' => array(0 => 'Option 1'), 'option_1' => array(0 => 'Option 2')), 'order' => array('option_0' => 1, 'option_1' => 2)), 'backend_type' => 'int')); $attribute->save(); /* Assign attribute to attribute set */ $installer->addAttributeToGroup('catalog_product', 'Default', 'General', $attribute->getId()); /* Create simple products per each option */ $options = new Mage_Eav_Model_Resource_Entity_Attribute_Option_Collection(); $options->setAttributeFilter($attribute->getId()); $attributeValues = array(); $productsData = array(); foreach ($options as $option) { $product = new Mage_Catalog_Model_Product(); $product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_SIMPLE)->setId($option->getId() * 10)->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))->setWebsiteIds(array(1))->setName('Configurable Option' . $option->getId())->setSku('simple_' . $option->getId())->setPrice(10)->setTestConfigurable($option->getId())->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE)->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->setStockData(array('use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1))->save(); $dataOption = array('label' => 'test', 'attribute_id' => $attribute->getId(), 'value_index' => $option->getId(), 'is_percent' => false, 'pricing_value' => 5); $productsData[$product->getId()] = array($dataOption); $attributeValues[] = $dataOption; } $product = new Mage_Catalog_Model_Product(); $product->setTypeId(Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE)->setId(1)->setAttributeSetId($installer->getAttributeSetId('catalog_product', 'Default'))->setWebsiteIds(array(1))->setName('Configurable Product')->setSku('configurable')->setPrice(100)->setVisibility(Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH)->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED)->setStockData(array('use_config_manage_stock' => 1, 'is_in_stock' => 1))->setConfigurableProductsData($productsData)->setConfigurableAttributesData(array(array('attribute_id' => $attribute->getId(), 'attribute_code' => $attribute->getAttributeCode(), 'frontend_label' => 'test', 'values' => $attributeValues)))->save();
<?php /* * @copyright Copyright (C) 2015 Gamuza Technologies (http://www.gamuza.com.br/) * @author Eneias Ramos de Melo <*****@*****.**> */ $installer = new Mage_Catalog_Model_Resource_Setup('pagarme_setup'); $installer->startSetup(); if (!$installer->getAttribute(Mage_Catalog_Model_Product::ENTITY, 'pagarme_subscription_plan', 'attribute_id')) { $installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'pagarme_subscription_plan', array('type' => 'int', 'input' => 'select', 'backend' => '', 'frontend' => '', 'label' => 'Plano da Pagarme', 'class' => '', 'source' => 'pagarme/product_attribute_plan', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'user_defined' => false, 'default' => '', 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => false, 'unique' => false, 'apply_to' => '', 'is_configurable' => false, 'used_in_product_listing' => true, 'option' => array('values' => array()))); $attributeId = $installer->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'pagarme_subscription_plan'); $defaultSetId = $installer->getAttributeSetId(Mage_Catalog_Model_Product::ENTITY, 'default'); $installer->addAttributeGroup(Mage_Catalog_Model_Product::ENTITY, $defaultSetId, 'Pagarme'); //find out the id of the new group $groupId = $installer->getAttributeGroup(Mage_Catalog_Model_Product::ENTITY, $defaultSetId, 'Pagarme', 'attribute_group_id'); //assign the attribute to the group and set if ($attributeId > 0) { $installer->addAttributeToSet(Mage_Catalog_Model_Product::ENTITY, $defaultSetId, $groupId, $attributeId); } $attributes = array('price', 'special_price', 'special_from_date', 'special_to_date', 'minimal_price', 'cost', 'tier_price', 'weight', 'tax_class_id'); foreach ($attributes as $attributeCode) { $applyTo = explode(',', $installer->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attributeCode, 'apply_to')); if (!in_array('subscription', $applyTo)) { $applyTo[] = 'subscription'; $installer->updateAttribute(Mage_Catalog_Model_Product::ENTITY, $attributeCode, 'apply_to', join(',', $applyTo)); } } } function addSubscriptionPlans($installer) { $table = $installer->getTable('pagarme_subscription_plans');
* * 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) 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(); $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('12345')->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();