/** * Add color attribute to default attribute set and create option */ protected function setUp() { parent::setUp(); $setup = new Mage_Catalog_Model_Resource_Setup('catalog_setup'); $colorAttributeId = $setup->getAttributeId(Mage_Catalog_Model_Product::ENTITY, 'color'); $setup->addAttributeToSet(Mage_Catalog_Model_Product::ENTITY, self::DEFAULT_ATTRIBUTE_SET, self::GENERAL_ATTRIBUTE_GROUP, $colorAttributeId); $setup->addAttributeOption(array('attribute_id' => $colorAttributeId, 'values' => ['Octarin'])); $this->optionId = $setup->getConnection()->lastInsertId($setup->getTable('eav/attribute_option')); }
<?php ini_set('display_errors', 1); error_reporting(E_ALL); require_once "app/Mage.php"; Mage::app('default'); Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID); $attrLabel = $_REQUEST['label']; $attrCode = $_REQUEST['code']; $attrType = $_REQUEST['type']; $attrInput = $_REQUEST['input']; ## Only for textarea type with editor enabled //$installer = new Mage_Eav_Model_Entity_Setup('core_setup'); $installer = new Mage_Catalog_Model_Resource_Setup(); try { $installer->addAttribute('catalog_category', $attrCode, array('group' => 'General Information', 'type' => $attrType, 'label' => $attrLabel, 'input' => $attrInput, 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, $attrType == "image" ? "'backend' => 'catalog/category_attribute_backend_image'," : '', 'sort_order' => '3', 'visible' => true, 'required' => false, 'user_defined' => true, 'default' => '', 'wysiwyg_enabled' => true, 'visible_on_front' => true, 'is_html_allowed_on_front' => true)); echo "Attribute {$attrCode} created successfully"; } catch (Exception $e) { echo "Error in creating attribute: {$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();
/** * Run script * */ public function run() { $installer = new Mage_Catalog_Model_Resource_Setup('core_setup'); try { //get products that have more then one image assigned $mediaSubSelect = $installer->getConnection()->select()->from(array('gallery' => $installer->getTable('catalog_product_entity_media_gallery')), array('id' => 'entity_id'))->group('entity_id')->having('count(entity_id) >1'); //get id_to_all_assigned_images relation $mediaSelect = $installer->getConnection()->select()->from(array('gallery' => $installer->getTable('catalog_product_entity_media_gallery')), array('id' => 'entity_id', 'images' => 'GROUP_CONCAT(value)'))->join(array('sub_media' => $mediaSubSelect), 'sub_media.id = gallery.entity_id', array())->group('id'); //get id_to_base_image relation $baseImageSelect = $installer->getConnection()->select()->from(array('product' => $installer->getTable('catalog/product')), array('id' => 'product.entity_id'))->join(array('varchar_table' => $installer->getTable('catalog_product_entity_varchar')), 'varchar_table.entity_id = product.entity_id', array('base_image' => 'value'))->join(array('eav_table' => $installer->getTable('eav/attribute')), 'varchar_table.attribute_id = eav_table.attribute_id', array())->where('eav_table.attribute_code = "image" AND eav_table.entity_type_id = 4 AND varchar_table.value <> "no_selection" AND varchar_table.value <> "" AND varchar_table.store_id = 0'); $idToBase = $installer->getConnection()->fetchPairs($baseImageSelect); $baseToId = array_flip($idToBase); $imagesToDelete = array(); $csvFileHandle = fopen(Mage::getBaseDir('var') . DS . 'duplicated_images.csv', 'w'); $query = $installer->getConnection()->query($mediaSelect); while ($row = $query->fetch()) { $md5 = array(); foreach (explode(',', $row['images']) as $image) { $filepath = Mage::getBaseDir('media') . '/catalog/product' . $image; if (file_exists($filepath)) { $md5Hash = md5_file($filepath); if (!isset($md5[$md5Hash])) { $md5[$md5Hash] = $image; } else { if (!isset($baseToId[$image])) { $imagesToDelete[] = $image; fputcsv($csvFileHandle, array($row['id'], $image)); } else { $imagesToDelete[] = $md5[$md5Hash]; fputcsv($csvFileHandle, array($row['id'], $md5[$md5Hash])); } } } } } fclose($csvFileHandle); $where = array('value in(?)' => $imagesToDelete); echo 'executing of mass detele query ' . PHP_EOL; $installer->getConnection()->delete($installer->getTable('catalog_product_entity_media_gallery'), $where); foreach ($imagesToDelete as $image) { Mage::log($image, null, 'image_duplicate.log', true); if (unlink(Mage::getBaseDir('media') . '/catalog/product' . $image)) { echo 'Deleted ' . Mage::getBaseDir('media') . '/catalog/product' . $image . PHP_EOL; } else { echo 'Can not delete ' . Mage::getBaseDir('media') . '/catalog/product' . $image . PHP_EOL; } } echo 'Finished' . PHP_EOL; } catch (Exception $e) { echo $e->getMessage() . "\n"; } }
<?php /** * mysql4-install-0.1.0 * * PHP Version 5.5.9 * * @category Webinse * @package Webinse_DailyDeals * @author Webinse Team <*****@*****.**> * @copyright 2015 Webinse Ltd. (https://www.webinse.com) * @license The Open Software License 3.0 * @link http://opensource.org/licenses/OSL-3.0 */ $installer = new Mage_Catalog_Model_Resource_Setup('core_setup'); $installer->startSetup(); $entityTypeId = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId(); $installer->addAttribute($entityTypeId, 'deal_price', array('type' => 'varchar', 'backend' => '', 'frontend' => '', 'label' => 'Deal Price', 'note' => ' ', 'input' => 'text', 'class' => '', 'source' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => false, 'required' => false, 'user_defined' => false, 'default' => '', 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => false, 'unique' => false, 'is_configurable' => false)); $installer->addAttribute($entityTypeId, 'deal_start_time', array('type' => 'datetime', 'backend' => '', 'frontend' => '', 'label' => 'Deal Start Time', 'input' => 'date', 'class' => '', 'source' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => false, 'required' => false, 'user_defined' => false, 'default' => '', 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => false, 'unique' => false, 'is_configurable' => false)); $installer->addAttribute($entityTypeId, 'deal_end_time', array('type' => 'datetime', 'backend' => '', 'frontend' => '', 'label' => 'Deal End Time', 'input' => 'date', 'class' => '', 'source' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => false, 'required' => false, 'user_defined' => false, 'default' => '', 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => false, 'unique' => false, 'is_configurable' => false)); $installer->addAttribute($entityTypeId, 'deal_qty', array('label' => 'Deal Qty', 'type' => 'int', 'input' => 'text', 'source' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => false, 'required' => false, 'user_defined' => true, 'searchable' => true, 'filterable' => true, 'filterable_in_search' => true, 'comparable' => true, 'visible_on_front' => false, 'visible_in_advanced_search' => false, 'unique' => false)); $installer->addAttribute($entityTypeId, 'deal_bought', array('label' => 'Deal Bought', 'type' => 'int', 'input' => 'text', 'source' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => false, 'required' => false, 'user_defined' => true, 'searchable' => true, 'default' => '0', 'filterable' => true, 'filterable_in_search' => true, 'comparable' => true, 'visible_on_front' => false, 'visible_in_advanced_search' => false, 'unique' => false)); $installer->addAttribute($entityTypeId, 'deal_status', array('label' => 'Deal Status', 'type' => 'int', 'input' => 'boolean', 'source' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => false, 'required' => false, 'user_defined' => true, 'searchable' => true, 'filterable' => true, 'filterable_in_search' => true, 'comparable' => true, 'visible_on_front' => false, 'visible_in_advanced_search' => false, 'unique' => false)); $attributesCode = array('deal_price', 'deal_start_time', 'deal_end_time', 'deal_qty', 'deal_bought', 'deal_status'); $attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_set_collection')->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId()); foreach ($attributeSetCollection as $attribute) { $name = $attribute->getAttributeSetName(); $installer->addAttributeGroup($entityTypeId, $name, 'Daily Deals', 100); foreach ($attributesCode as $code) { $installer->addAttributeToSet($entityTypeId, $name, 'Daily Deals', $code); }
<?php //Für das anlegen des Cookie Attributes bei Bestellungen siehe Affiliate $setup = new Mage_Catalog_Model_Resource_Setup(); $setup->startSetup(); //$setup->removeAttribute(Mage_Catalog_Model_Category::ENTITY, "seo_text"); //EAN $setup->addAttribute(Mage_Catalog_Model_Category::ENTITY, "seo_text", array('group' => 'General', 'input' => 'textarea', 'type' => 'text', 'label' => 'SEO Text', 'backend' => '', 'visible' => true, 'required' => false, 'wysiwyg_enabled' => true, 'visible_on_front' => true, 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE)); $setup->endSetup();
<?php /** @var Mage_Customer_Model_Entity_Setup $this */ /** @var Mage_Catalog_Model_Resource_Setup $installer */ $installer = new Mage_Catalog_Model_Resource_Setup('core_setup'); $installer->startSetup(); $attribute_model = Mage::getModel('eav/entity_attribute'); $attribute_code = $attribute_model->getIdByCode('catalog_product', 'use_global_padding_days'); $resource = Mage::getSingleton('core/resource'); $writeConnection = $resource->getConnection('core_write'); $table = $resource->getTableName('eav/entity_attribute'); $newSortOrder = '20'; $query = "UPDATE {$table} SET sort_order = '{$newSortOrder}' WHERE attribute_id = " . (int) $attribute_code; $writeConnection->query($query); $installer->endSetup();
<?php $installer = $this; //$installer->startSetup(); $installer = new Mage_Catalog_Model_Resource_Setup('core_setup'); $installer->addAttribute('catalog_product', 'salepages', array('backend' => '', 'frontend' => '', 'label' => 'Sale Pages', 'input' => 'multiselect', 'class' => '', 'source' => 'eav/entity_attribute_source_table', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'user_defined' => true, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'apply_to' => '', 'position' => 0, 'visible_on_front' => false, 'visible_in_advanced_search' => 0)); $installer->endSetup();
<?php /** * Creating textarea EAV for product with list of video URLs. * * @package Keyup_ProductVideos * @author Jan Kuchař <*****@*****.**> * @copyright Copyright (c) 2015 Keyup IT Services (http://www.keyup.eu) * @license http://keyup.mit-license.org/2012 MIT License */ $setup = Mage::getResourceModel('catalog/setup', 'catalog_setup'); $setup->removeAttribute('catalog_product', 'videoembeder_ta'); $setup->removeAttribute('catalog_product', 'videoembedder_ta'); $setup->removeAttribute('catalog_product', 'productvideos_ta'); $installer = Mage::getResourceModel('catalog/setup', 'catalog_setup'); $installer->startSetup(); if (!$installer->getAttributeId(Mage_Catalog_Model_Product::ENTITY, Keyup_ProductVideos_Model_Config::ATTR_URLS)) { $setup = new Mage_Catalog_Model_Resource_Setup('core_setup'); $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, Keyup_ProductVideos_Model_Config::ATTR_URLS, array('group' => 'General', 'attribute_model' => NULL, 'backend' => NULL, 'type' => 'text', 'table' => NULL, 'frontend' => NULL, 'input' => 'textarea', 'label' => 'Video URLs', 'frontend_class' => NULL, 'source' => NULL, 'required' => '0', 'user_defined' => '1', 'default' => NULL, 'unique' => '0', 'input_renderer' => NULL, 'global' => '0', 'visible' => '1', 'searchable' => '0', 'filterable' => '0', 'comparable' => '0', 'visible_on_front' => '0', 'is_html_allowed_on_front' => '1', 'is_used_for_price_rules' => '0', 'filterable_in_search' => '0', 'used_in_product_listing' => '0', 'used_for_sort_by' => '0', 'is_configurable' => '0', 'apply_to' => NULL, 'visible_in_advanced_search' => '0', 'position' => '0', 'wysiwyg_enabled' => '0', 'used_for_promo_rules' => '0', 'note' => Mage::helper('keyup_productvideos')->__('Insert one Video URL per line.'))); $attribute = Mage::getModel('eav/entity_attribute')->loadByCode('catalog_product', Keyup_ProductVideos_Model_Config::ATTR_URLS); $attribute->setStoreLabels(array()); $attribute->save(); } $installer->endSetup();
/** * Run script * */ public function run() { $installer = new Mage_Catalog_Model_Resource_Setup('core_setup'); try { //grab all products ids that have 'no_selection' value in database $noSelectionSelect = $installer->getConnection()->select()->from(array('product' => $installer->getTable('catalog/product')), array('id' => 'product.entity_id'))->join(array('varchar_table' => $installer->getTable('catalog_product_entity_varchar')), 'varchar_table.entity_id = product.entity_id', array())->join(array('eav_table' => $installer->getTable('eav/attribute')), 'varchar_table.attribute_id = eav_table.attribute_id', array())->where('eav_table.attribute_code = "image" AND eav_table.entity_type_id = 4 AND varchar_table.value = "no_selection" AND varchar_table.store_id = 0'); //get products ids that have missing image value record $missingImageValueSelectInner = $installer->getConnection()->select()->from(array('product' => $installer->getTable('catalog/product')), array('id' => 'product.entity_id'))->join(array('varchar_table' => $installer->getTable('catalog_product_entity_varchar')), 'varchar_table.entity_id = product.entity_id', array())->join(array('eav_table' => $installer->getTable('eav/attribute')), 'varchar_table.attribute_id = eav_table.attribute_id', array())->where('eav_table.attribute_code = "image" AND eav_table.entity_type_id = 4 AND varchar_table.store_id = 0'); $missingImageValueSelect = $installer->getConnection()->select()->from(array('product' => $installer->getTable('catalog/product')), array('id' => 'product.entity_id'))->where('product.entity_id NOT IN ?', $missingImageValueSelectInner); //combine ids. $unitedSselect = $installer->getConnection()->select()->union(array($noSelectionSelect, $missingImageValueSelect)); $ids = $installer->getConnection()->fetchCol($unitedSselect); Mage::log(sprintf("found %s candidats for setting image", count($ids)), null, 'image_set.log', true); //Get id to image relation from catalog_product_entity_media_gallery table $mediaSelect = $installer->getConnection()->select()->from(array('gallery' => $installer->getTable(Mage_Catalog_Model_Resource_Product_Attribute_Backend_Media::GALLERY_TABLE)), array('id' => 'entity_id', 'value'))->join(array('gallery_value' => $installer->getTable(Mage_Catalog_Model_Resource_Product_Attribute_Backend_Media::GALLERY_VALUE_TABLE)), 'gallery_value.value_id = gallery.value_id AND store_id = 0', array())->where('entity_id in (?)', $ids)->order('position asc'); $query = $installer->getConnection()->query($mediaSelect); $idToImage = array(); while ($row = $query->fetch()) { if (!isset($idToImage[$row['id']])) { $idToImage[$row['id']] = $row['value']; } } //Mage::log($idToImage, null, 'image_set.log', true); /** @var Magebrew_SetImage_Model_Resource_Catalog_Product $resource */ $resource = Mage::getModel('magebrew_setimage/resource_catalog_product'); foreach ($idToImage as $id => $image) { $product = Mage::getModel('catalog/product')->setId($id); $product->setStoreId(Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID); $product->setImage($image); $product->setSmallImage($image); $product->setThumbnail($image); Mage::log(sprintf("trying to set image %s to product %s", $image, $id), null, 'image_set.log', true); $resource->saveAttribute($product, 'image'); $resource->saveAttribute($product, 'small_image'); $resource->saveAttribute($product, 'thumbnail'); echo 'set images for product ' . $id . PHP_EOL; } echo 'Finished' . PHP_EOL; } catch (Exception $e) { echo $e->getMessage() . "\n"; } }
<?php /** * mysql4-upgrade-2.0.1-2.0.2 * * PHP Version 5.5.9 * * @category Webinse * @package Webinse_DailyDeals * @author Webinse Team <*****@*****.**> * @copyright 2015 Webinse Ltd. (https://www.webinse.com) * @license The Open Software License 3.0 * @link http://opensource.org/licenses/OSL-3.0 */ $installer = new Mage_Catalog_Model_Resource_Setup('core_setup'); $installer->startSetup(); $entityTypeId = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId(); $installer->addAttribute($entityTypeId, 'deal_category_id', array('type' => 'varchar', 'backend' => '', 'frontend' => '', 'label' => 'Deal Category Id', 'note' => ' ', 'input' => 'text', 'class' => '', 'source' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => false, 'required' => false, 'user_defined' => false, 'default' => '', 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => false, 'unique' => false, 'is_configurable' => false)); $attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_set_collection')->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId()); foreach ($attributeSetCollection as $attribute) { $installer->addAttributeToSet($entityTypeId, $attribute->getAttributeSetName(), 'Daily Deals', 'deal_category_id'); } $installer->endSetup();
<?php /** * mysql4-upgrade-2.1.1-2.1.2 * * PHP Version 5.5.9 * * @category Webinse * @package Webinse_DailyDeals * @author Webinse Team <*****@*****.**> * @copyright 2015 Webinse Ltd. (https://www.webinse.com) * @license The Open Software License 3.0 * @link http://opensource.org/licenses/OSL-3.0 */ $installer = new Mage_Catalog_Model_Resource_Setup('core_setup'); $installer->startSetup(); $installer->addAttribute('catalog_product', 'deals_choice_category', array('type' => 'int', 'label' => 'Deals choice from category', 'input' => 'select', 'source' => 'eav/entity_attribute_source_boolean', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => false, 'required' => false, 'user_defined' => false, 'default' => '0', 'visible_on_front' => false, 'apply_to' => 'downloadable,simple,virtual')); $entityTypeId = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId(); $attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_set_collection')->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId()); foreach ($attributeSetCollection as $set) { $installer->addAttributeToSet($entityTypeId, $set->getAttributeSetName(), '', 'deals_choice_category'); } $installer->endSetup();
$installer->startSetup(); // For creating for a store, comment out if simgle store $store = Mage::app()->getStore('store_code'); // ===== CMS Static Blocks ===== $data = array('title' => 'Hello World', 'identifier' => 'hello-world-id', 'stores' => array(0), 'content' => '<p>Some HTML content for example</p>', 'is_active' => 1); // Check if static block already exists, if yes then update content $block = Mage::getModel('cms/block')->load($data['identifier']); if ($block->isObjectNew()) { // Create static block Mage::getModel('cms/block')->setData($data)->save(); } else { // Update Content $block->setData('content', $data['content'])->save(); } // ==== Product Attributes ===== $model = new Mage_Catalog_Model_Resource_Setup(); $model->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'my_custom_attribute_code', array('group' => 'Prices', 'type' => 'text', 'attribute_set' => 'Default', 'backend' => '', 'frontend' => '', 'label' => 'My Custom Attribute', 'input' => 'text', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'user_defined' => true, 'default' => '1', 'searchable' => false, 'filterable' => true, 'comparable' => false, 'visible_on_front' => true, 'visible_in_advanced_search' => true, 'used_in_product_listing' => true, 'unique' => false, 'apply_to' => 'simple')); // System Configuraton $conf = new Mage_Core_Model_Config(); $address = 'Address Text Here'; $conf->saveConfig('general/store_information/address', $address, 'default', 0); /* === CMS PAGE === */ $page = Mage::getModel('cms/page'); $page->setStoreId($store->getId()); $page->load('home', 'identifier'); $cmsPage = array('title' => 'Home PH', 'identifier' => 'home', 'content' => 'page content here', 'is_active' => 1, 'stores' => array($store->getId())); if ($page->getId()) { $page->setContent($cmsPage['content']); $page->setTitle($cmsPage['title']); $page->save(); } else {
<?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');
<?php /** * mysql4-upgrade-2.1.0-2.1.1 * * PHP Version 5.5.9 * * @category Webinse * @package Webinse_DailyDeals * @author Webinse Team <*****@*****.**> * @copyright 2015 Webinse Ltd. (https://www.webinse.com) * @license The Open Software License 3.0 * @link http://opensource.org/licenses/OSL-3.0 */ $installer = new Mage_Catalog_Model_Resource_Setup('core_setup'); $installer->startSetup(); $installer->addAttribute('catalog_product', 'choice_type_dealstime', array('type' => 'int', 'label' => 'Choice type dealstime', 'input' => 'select', 'source' => 'eav/entity_attribute_source_boolean', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => false, 'required' => false, 'user_defined' => false, 'default' => '1', 'visible_on_front' => false, 'apply_to' => 'downloadable,simple,virtual')); $installer->addAttribute('catalog_product', 'deal_update_days_product', array('type' => 'varchar', 'label' => 'Deal Products will be run and update each', 'input' => 'multiselect', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => false, 'required' => false, 'user_defined' => true, 'default' => "", 'backend_model' => 'eav/entity_attribute_backend_array', 'source' => 'Webinse_DailyDeals_Model_Entity_Attribute_Source_Days', 'apply_to' => 'downloadable,simple,virtual')); $entityTypeId = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId(); $attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_set_collection')->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId()); foreach ($attributeSetCollection as $set) { $installer->addAttributeToSet($entityTypeId, $set->getAttributeSetName(), '', 'choice_type_dealstime'); $installer->addAttributeToSet($entityTypeId, $set->getAttributeSetName(), '', 'deal_update_days_product'); } $installer->endSetup();
<?php $setup = new Mage_Catalog_Model_Resource_Setup('core_setup'); $attr = array('attribute_model' => NULL, 'backend' => NULL, 'type' => 'int', 'table' => NULL, 'frontend' => NULL, 'input' => 'select', 'label' => 'Google Shopping Condition', 'frontend_class' => NULL, 'source' => 'aligent_feeds/source_condition', 'required' => '0', 'user_defined' => '1', 'default' => '', 'unique' => '0', 'note' => NULL, 'input_renderer' => NULL, 'global' => '1', 'visible' => '1', 'searchable' => '0', 'filterable' => '0', 'comparable' => '0', 'visible_on_front' => '0', 'is_html_allowed_on_front' => '1', 'is_used_for_price_rules' => '0', 'filterable_in_search' => '0', 'used_in_product_listing' => '1', 'used_for_sort_by' => '0', 'is_configurable' => '0', 'apply_to' => NULL, 'visible_in_advanced_search' => '0', 'position' => '0', 'wysiwyg_enabled' => '0', 'used_for_promo_rules' => '0', 'search_weight' => '1'); $setup->addAttribute('catalog_product', 'gshopping_condition', $attr); $aAttributeSetIds = $setup->getAllAttributeSetIds('catalog_product'); $iAttributeId = $setup->getAttributeId('catalog_product', 'gshopping_condition'); foreach ($aAttributeSetIds as $iAttributeSetId) { $iAttributeGroupId = $setup->getAttributeGroupId('catalog_product', $iAttributeSetId, 'Meta Information'); $setup->addAttributeToSet('catalog_product', $iAttributeSetId, $iAttributeGroupId, $iAttributeId, 6); }
$installer = $this; //Bestellzustände hinzufügen $statusTable = $installer->getTable('sales/order_status'); $newData = ['faulty', 'partially_open', 'partially_processing', 'readytoship', 'partially_readytoship', 'delivered', 'partially_delivered', 'received', 'partially_received']; $isNew = true; $data = array(array('status' => 'faulty', 'label' => 'Faulty'), array('status' => 'partially_open', 'label' => 'Partially Open'), array('status' => 'partially_processing', 'label' => 'Partially Proccessing'), array('status' => 'readytoship', 'label' => 'Ready to Ship'), array('status' => 'partially_readytoship', 'label' => 'Partially Ready to Ship'), array('status' => 'delivered', 'label' => 'Delivered'), array('status' => 'partially_delivered', 'label' => 'Partially Delivered'), array('status' => 'received', 'label' => 'Received'), array('status' => 'partially_received', 'label' => 'Partially Received')); $select = $this->getConnection()->select(); $select->from($statusTable); $currentStatusTable = $this->getConnection()->fetchAll($select); foreach ($currentStatusTable as $currentStatus) { if (in_array($currentStatus['status'], $newData)) { $isNew = false; break; } } if ($isNew) { $installer->getConnection()->insertArray($statusTable, array('status', 'label'), $data); } //EAN als Attribute hinzufügen $setup = new Mage_Catalog_Model_Resource_Setup(); $setup->startSetup(); $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, "ean", array('type' => 'varchar', 'visible' => true, 'label' => 'EAN', 'input' => 'text', 'required' => false, 'user_defined' => true, 'default' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'sort_order' => 1, 'group' => 'General', 'apply_to' => 'simple', 'searchable' => true)); $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, "number", array('type' => 'varchar', 'visible' => true, 'label' => 'number', 'input' => 'text', 'required' => false, 'user_defined' => true, 'default' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'sort_order' => 2, 'group' => 'General', 'apply_to' => 'simple', 'searchable' => true)); $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, "iid", array('type' => 'int', 'visible' => true, 'label' => 'IID', 'input' => 'text', 'required' => false, 'user_defined' => true, 'default' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'sort_order' => 3, 'group' => 'General', 'apply_to' => 'simple', 'searchable' => true)); //Attribute Größe anlegen $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, "primary_size", array('type' => 'varchar', 'visible' => true, 'label' => 'Größe', 'input' => 'select', 'required' => false, 'user_defined' => true, 'default' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'sort_order' => 4, 'group' => 'General', 'apply_to' => 'simple', 'is_configurable' => true, 'searchable' => true, 'filterable' => true)); $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, "secondary_size", array('type' => 'varchar', 'visible' => true, 'label' => 'Korbgröße', 'input' => 'select', 'required' => false, 'user_defined' => true, 'default' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'sort_order' => 5, 'group' => 'General', 'apply_to' => 'simple', 'filterable' => true)); $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, "color", array('type' => 'varchar', 'visible' => true, 'label' => 'Farbe', 'input' => 'select', 'required' => false, 'user_defined' => true, 'default' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'sort_order' => 5, 'group' => 'General', 'apply_to' => 'simple', 'searchable' => true, 'filterable' => true, 'is_configurable' => true)); $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, "filter_color", array('type' => 'varchar', 'visible' => true, 'label' => 'Filterfarbe', 'input' => 'select', 'required' => false, 'user_defined' => true, 'default' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'sort_order' => 5, 'group' => 'General', 'apply_to' => 'simple', 'searchable' => true, 'filterable' => true)); $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, "care_instructions", array('type' => 'varchar', 'visible' => true, 'label' => 'Pflegeanleitung', 'input' => 'multiselect', 'required' => false, 'user_defined' => true, 'default' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'sort_order' => 5, 'group' => 'General', 'apply_to' => 'simple', 'searchable' => false, 'filterable' => false)); $setup->endSetup();
<?php /** * mysql4-upgrade-2.0.3-2.0.4 * * PHP Version 5.5.9 * * @category Webinse * @package Webinse_DailyDeals * @author Webinse Team <*****@*****.**> * @copyright 2015 Webinse Ltd. (https://www.webinse.com) * @license The Open Software License 3.0 * @link http://opensource.org/licenses/OSL-3.0 */ $installer = new Mage_Catalog_Model_Resource_Setup('core_setup'); $installer->startSetup(); $entityTypeId = Mage::getModel('eav/entity')->setType('catalog_category')->getTypeId(); $installer->addAttribute($entityTypeId, 'deal_qty_product_percent', array('type' => 'int', 'label' => 'Qty Deal Product (depends on availability in stock)', 'input' => 'text', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'user_defined' => true, 'default' => "", 'group' => "General Information")); $installer->addAttribute($entityTypeId, 'deal_discount_percent', array('type' => 'int', 'label' => 'Deal Discount Percent', 'input' => 'text', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'user_defined' => true, 'default' => "", 'group' => "General Information")); $attributesCode = array('deal_qty_product_percent', 'deal_discount_percent'); $attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_set_collection')->setEntityTypeFilter(Mage::getModel('catalog/category')->getResource()->getTypeId()); foreach ($attributeSetCollection as $attribute) { $name = $attribute->getAttributeSetName(); $installer->addAttributeGroup($entityTypeId, $name, 'Daily Deals', 100); foreach ($attributesCode as $code) { $installer->addAttributeToSet($entityTypeId, $name, 'Daily Deals', $code); } } $installer->endSetup();
* * 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 */ $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();
<?php /** * Magento * * 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 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) */ $installer = new Mage_Catalog_Model_Resource_Setup('catalog_setup'); $installer->updateAttribute('catalog_product', 'weight', 'is_filterable', 1);
<?php $installer = new Mage_Catalog_Model_Resource_Setup('core_setup'); $installer->startSetup(); $installer->removeAttribute(Mage_Catalog_Model_Product::ENTITY, 'hide_end_date'); $installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'hide_end_date', array('group' => 'Payperrentals', 'label' => 'Hide End Date on Product Page ', 'type' => 'int', 'input' => 'select', 'source' => 'eav/entity_attribute_source_boolean', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, 'visible' => true, 'required' => false, 'user_defined' => false, 'default' => 0, 'apply_to' => 'reservation', 'visible_on_front' => false, 'position' => 100)); $installer->endSetup();
<?php /** * mysql4-upgrade-2.0.0-2.0.1 * * PHP Version 5.5.9 * * @category Webinse * @package Webinse_DailyDeals * @author Webinse Team <*****@*****.**> * @copyright 2015 Webinse Ltd. (https://www.webinse.com) * @license The Open Software License 3.0 * @link http://opensource.org/licenses/OSL-3.0 */ $installer = new Mage_Catalog_Model_Resource_Setup('core_setup'); $installer->startSetup(); $entityTypeId = Mage::getModel('eav/entity')->setType('catalog_category')->getTypeId(); $installer->addAttribute($entityTypeId, 'deal_update_days', array('type' => 'varchar', 'label' => 'Deal Products will be run and update each', 'input' => 'multiselect', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'user_defined' => true, 'default' => "", 'group' => "General Information", 'backend_model' => 'eav/entity_attribute_backend_array', 'source' => 'Webinse_DailyDeals_Model_Entity_Attribute_Source_Days')); $installer->addAttribute($entityTypeId, 'qty_deal_product', array('type' => 'int', 'label' => 'Qty Deal Products in Category', 'input' => 'text', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'user_defined' => true, 'default' => "", 'group' => "General Information")); $attributesCode = array('qty_deal_product', 'deal_update_days'); $attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_set_collection')->setEntityTypeFilter(Mage::getModel('catalog/category')->getResource()->getTypeId()); foreach ($attributeSetCollection as $attribute) { $name = $attribute->getAttributeSetName(); $installer->addAttributeGroup($entityTypeId, $name, 'Daily Deals', 100); foreach ($attributesCode as $code) { $installer->addAttributeToSet($entityTypeId, $name, 'Daily Deals', $code); } } $installer->endSetup();
<?php /*Mage_core_Model_Resource_Setup*/ $this->startSetup(); // catalog resource model has all EAV related functions $catalogInstaller = new Mage_Catalog_Model_Resource_Setup($this->_resourceName); $this->run(" Update `{$catalogInstaller->getTable('catalog/eav_attribute')}` \r\n\tSET apply_to = CONCAT_WS(',', apply_to, 'event')\r\n WHERE `apply_to` LIKE '%simple%' AND `apply_to` NOT LIKE '%event';\r\n"); // adding attributes // add title for event $catalogInstaller->addAttribute('catalog_product', 'event_title', array('label' => 'Event Title', 'required' => TRUE, 'group' => 'Event Settings', 'apply_to' => 'event')); // add a select list for the event $catalogInstaller->addAttribute('catalog_product', 'event_id', array('label' => 'Event ID', 'required' => TRUE, 'group' => 'Event Settings', 'input' => 'select', 'source' => 'master_example/product_attribute_source_event', 'apply_to' => 'event', 'note' => 'Select your event from list'));
* 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) */ /* 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);
<?php $setup = new Mage_Catalog_Model_Resource_Setup(); $setup->startSetup(); //Thrid Size $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, "third_size", array('type' => 'varchar', 'visible' => true, 'label' => 'Brustumfang', 'input' => 'select', 'required' => false, 'user_defined' => true, 'default' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'sort_order' => 1, 'group' => 'General', 'apply_to' => 'simple', 'filterable' => true)); $setup->endSetup();
/** * Prepare database after install/upgrade * added config reinit to endSetup * * @return Loewenstark_Kitchenking_Model_Resource_Setup */ public function endSetup() { Mage::getConfig()->reinit(); Mage::app()->reinitStores(); return parent::endSetup(); }
* 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()); }
$select = $this->getConnection()->select(); $select->from($statusTable); $currentStatusTable = $this->getConnection()->fetchAll($select); foreach ($currentStatusTable as $currentStatus) { if (in_array($currentStatus['status'], $newData)) { //Falls bereits einer der Zustände vorhanden ist, wurde das Setup schon ausgeführt //daher brechen wir hier ab und fügen keine Zustände hinzu $isNew = false; break; } } if ($isNew) { $installer->getConnection()->insertArray($statusTable, array('status', 'label'), $data); } //Für das anlegen der Attribute wird ein anderes Model benötigt $setup = new Mage_Catalog_Model_Resource_Setup(); $setup->startSetup(); //EAN $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, "ean", array('type' => 'varchar', 'visible' => true, 'label' => 'EAN', 'input' => 'text', 'required' => false, 'user_defined' => true, 'default' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'sort_order' => 1, 'group' => 'General', 'apply_to' => 'simple', 'searchable' => true, 'is_configurable' => false)); //number - Artikelnnummer des Kunden $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, "number", array('type' => 'varchar', 'visible' => true, 'label' => 'number', 'input' => 'text', 'required' => false, 'user_defined' => true, 'default' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'sort_order' => 2, 'group' => 'General', 'apply_to' => 'simple,configurable', 'searchable' => true, 'is_configurable' => false)); //iid - Alvine IID des Stammproduktes $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, "iid", array('type' => 'int', 'visible' => true, 'label' => 'IID', 'input' => 'text', 'required' => false, 'user_defined' => true, 'default' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'sort_order' => 3, 'group' => 'General', 'apply_to' => 'simple,configurable', 'searchable' => true, 'is_configurable' => false)); //Attribute für die Hauptgröße, S, M , L oder bei BHs 75, 80 $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, "primary_size", array('type' => 'varchar', 'visible' => true, 'label' => 'Größe', 'input' => 'select', 'required' => false, 'user_defined' => true, 'default' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'sort_order' => 4, 'group' => 'General', 'apply_to' => 'simple', 'is_configurable' => true, 'searchable' => true, 'filterable' => true)); //Attribute für die ergänzende zweite Größe, nur bei BHs genutzt, A, B, C ... $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, "secondary_size", array('type' => 'varchar', 'visible' => true, 'label' => 'Korbgröße', 'input' => 'select', 'required' => false, 'user_defined' => true, 'default' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'sort_order' => 5, 'group' => 'General', 'apply_to' => 'simple', 'filterable' => true, 'is_configurable' => true)); //Farbe $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, "color", array('type' => 'varchar', 'visible' => true, 'label' => 'Farbe', 'input' => 'select', 'required' => false, 'user_defined' => true, 'default' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'sort_order' => 6, 'group' => 'General', 'apply_to' => 'simple', 'searchable' => true, 'filterable' => true, 'is_configurable' => true)); //Filterfarbe - wird nicht auf der Produktseite angezeigt, aber im Gallery-Filter $setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, "filter_color", array('type' => 'varchar', 'visible' => true, 'label' => 'Filterfarbe', 'input' => 'select', 'required' => false, 'user_defined' => true, 'default' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'sort_order' => 7, 'group' => 'General', 'apply_to' => 'simple,configurable', 'searchable' => true, 'filterable' => true, 'is_configurable' => false));
* 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();
<?php /** @var Mage_Customer_Model_Entity_Setup $this */ /** @var Mage_Catalog_Model_Resource_Setup $installer */ $installer = new Mage_Catalog_Model_Resource_Setup('core_setup'); $installer->startSetup(); //$installer->removeAttribute(Mage_Catalog_Model_Product::ENTITY, 'use_global_min_qty'); $installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'use_global_min_qty', array('group' => 'Inventory', 'label' => 'Use Global Minimum Qty', 'type' => 'int', 'input' => 'select', 'source' => 'eav/entity_attribute_source_boolean', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, 'visible' => true, 'required' => false, 'user_defined' => false, 'default' => '1', 'default_value' => '1', 'apply_to' => 'reservation', 'visible_on_front' => false, 'position' => 20)); //$installer->removeAttribute(Mage_Catalog_Model_Product::ENTITY, 'use_global_max_qty'); $installer->addAttribute(Mage_Catalog_Model_Product::ENTITY, 'use_global_max_qty', array('group' => 'Inventory', 'label' => 'Use Global Maximum Qty', 'type' => 'int', 'input' => 'select', 'source' => 'eav/entity_attribute_source_boolean', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, 'visible' => true, 'required' => false, 'user_defined' => false, 'default' => '1', 'default_value' => '1', 'apply_to' => 'reservation', 'visible_on_front' => false, 'position' => 30)); $installer->endSetup();