<?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();
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));
//Pflegeanleitung
$setup->addAttribute(Mage_Catalog_Model_Product::ENTITY, "care_instructions", array('type' => 'varchar', 'visible' => true, 'label' => 'Pflegeanleitung', 'input' => 'multiselect', 'backend' => 'eav/entity_attribute_backend_array', 'frontend' => '', 'source' => '', 'required' => false, 'user_defined' => true, 'default' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 'sort_order' => 8, 'group' => 'General', 'apply_to' => 'simple,configurable', 'searchable' => false, 'filterable' => false, 'is_configurable' => false));
//Filtermaterial - ebenfalls nur zum Suchergebnisse filtern
<?php

/**
 * mysql4-upgrade-0.1.3-0.1.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_product')->getTypeId();
$installer->addAttribute($entityTypeId, 'old_special_price', array('type' => 'varchar', 'backend' => '', 'frontend' => '', 'label' => 'Old special 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, 'old_special_date_from', array('type' => 'datetime', 'backend' => '', 'frontend' => '', 'label' => 'Old special date from', 'note' => ' ', '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, 'old_special_date_to', array('type' => 'datetime', 'backend' => '', 'frontend' => '', 'label' => 'Old special date to', 'note' => ' ', '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));
$attNames = array('old_special_price', 'old_special_date_from', 'old_special_date_to');
$attributeSetCollection = Mage::getResourceModel('eav/entity_attribute_set_collection')->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId());
foreach ($attributeSetCollection as $attribute) {
    foreach ($attNames as $attName) {
        $installer->addAttributeToSet($entityTypeId, $attribute->getAttributeSetName(), 'Daily Deals', $attName);
    }
}
$installer->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();
<?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();
/**
 * 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);
    }
}
$installer->endSetup();
<?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

$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();
Exemplo n.º 9
0
<?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 Category', 'frontend_class' => NULL, 'source' => 'eav/entity_attribute_source_table', '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', 'option' => array('values' => array()));
$fh = fopen(__DIR__ . '/taxonomy.en-US.txt', 'r');
// Discard the first line, it's a comment.
$vLine = fgets($fh);
while (!feof($fh)) {
    $attr['option']['values'][] = trim(fgets($fh));
}
fclose($fh);
$setup->addAttribute('catalog_product', 'gshopping_category', $attr);
$aAttributeSetIds = $setup->getAllAttributeSetIds('catalog_product');
$iAttributeId = $setup->getAttributeId('catalog_product', 'gshopping_category');
foreach ($aAttributeSetIds as $iAttributeSetId) {
    $iAttributeGroupId = $setup->getAttributeGroupId('catalog_product', $iAttributeSetId, 'Meta Information');
    $setup->addAttributeToSet('catalog_product', $iAttributeSetId, $iAttributeGroupId, $iAttributeId, 5);
}
<?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

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}";
}
<?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();
Exemplo n.º 13
0
<?php

/** @var $this Mage_Core_Model_Resource_Setup */
$installer = $this;
$installer->startSetup();
$setup = new Mage_Catalog_Model_Resource_Setup('core_setup');
$setup->addAttribute('catalog_product', 'maintenance_quantity', array('group' => 'Inventory', 'input' => 'text', 'type' => 'int', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 'visible' => true, 'required' => false, 'user_defined' => false, 'default' => 0, 'apply_to' => 'reservation', 'visible_on_frontend' => false, 'position' => 2, 'label' => 'Maintenance Quantity', 'searchable' => 0, 'filterable' => 0, 'visible_in_advanced_search' => 0, 'note' => 'Used only for quantity based non-specific dates maintenance, otherwise inventory in maintenance is checked by dates. It is usually NOT necessary to modify this field manually as this is done automatically via the maintenance module.'));
$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);
}
// 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 {
    Mage::getModel('cms/page')->setData($cmsPage)->save();
$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.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();
<?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.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

/*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'));
Exemplo n.º 21
0
<?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();
<?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();
Exemplo n.º 23
0
<?php

//安装3,生成目录属性,主要是确定哪个是虚拟产品目录
require_once 'app/Mage.php';
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$installer = new Mage_Catalog_Model_Resource_Setup();
$attribute = array('type' => 'int', 'label' => '是否虚拟产品目录', 'input' => 'select', 'source' => 'eav/entity_attribute_source_boolean', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL, 'visible' => true, 'required' => false, 'user_defined' => true, 'default' => '', 'group' => 'General Information');
$installer->removeAttribute('catalog_category', 'a_cat_virtual');
$installer->addAttribute('catalog_category', 'a_cat_virtual', $attribute);
$installer->endSetup();
echo __FILE__;
echo '3增加目录属性成功';