public function getAttributeList() { if (!self::$_attributes) { $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); $attrs = Vikont_Data2data_Helper_Db::getTableValues('eav/attribute', array('attribute_id', 'attribute_code'), array('entity_type_id=' . self::getEntityTypeId())); foreach ($attrs as $attr) { $data = $setup->getAttribute(self::getEntityTypeId(), $attr['attribute_id']); self::$_attributes[$attr['attribute_code']] = array('backend' => $data['backend_model'], 'type' => $data['backend_type'], 'table' => $data['backend_table'], 'frontend' => $data['frontend_model'], 'input' => $data['frontend_input'], 'label' => $data['frontend_label'], 'frontend_class' => $data['frontend_class'], 'source' => $data['source_model'], 'required' => $data['is_required'], 'user_defined' => $data['is_user_defined'], 'default' => $data['default_value'], 'unique' => $data['is_unique'], 'note' => $data['note'], 'global' => $data['is_global']); } } return self::$_attributes; }
<?php $installer = new Mage_Eav_Model_Entity_Setup('core_setup'); $installer->startSetup(); $setup = $this; $fieldList = array('is_reservation', 'tax_class_id', 'payperrentals_quantity', 'payperrentals_min_number', 'payperrentals_min_type', 'payperrentals_max_number', 'payperrentals_max_type', 'payperrentals_avail_number', 'payperrentals_avail_type', 'payperrentals_avail_numberb', 'payperrentals_avail_typeb', 'payperrentals_deposit', 'payperrentals_has_shipping', 'payperrentals_has_multiply', 'payperrentals_pricingtype', 'payperrentals_use_serials', 'payperrentals_use_send_return', 'payperrentals_use_times', 'res_excluded_dates', 'res_prices', 'payperrentals_padding_days', 'res_serialnumbers', 'disabled_with_message', 'res_excluded_daysweek', 'allow_overbooking', 'global_min_period', 'global_max_period', 'global_turnover_after', 'global_turnover_before', 'global_excludedays'); foreach ($fieldList as $field) { $applyTo = explode(',', $installer->getAttribute('catalog_product', $field, 'apply_to')); if (!in_array('bundle', $applyTo)) { $applyTo[] = 'bundle'; } $installer->updateAttribute('catalog_product', $field, 'apply_to', implode(',', $applyTo)); } try { $setup->removeAttribute('catalog_product', 'bundle_pricingtype'); } catch (Exception $E) { } $setup->addAttribute('catalog_product', 'bundle_pricingtype', array('backend' => '', 'source' => 'payperrentals/product_bundlepricingtype', 'group' => 'Payperrentals', 'label' => 'Bundle Pricing Type', 'input' => 'select', 'type' => 'int', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_WEBSITE, 'visible' => true, 'default' => 0, 'required' => false, 'user_defined' => false, 'apply_to' => 'bundle', 'visible_on_front' => false, 'position' => 10)); $installer->endSetup();
function updateSourceModel(Mage_Eav_Model_Entity_Setup $setup, $entityTypeId, $code, $key, $value) { $id = $setup->getAttribute($entityTypeId, $code, 'attribute_id'); $setup->updateAttribute($entityTypeId, $id, $key, $value); }
/** * aheadWorks Co. * * NOTICE OF LICENSE * * This source file is subject to the EULA * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://ecommerce.aheadworks.com/AW-LICENSE.txt * * ================================================================= * MAGENTO EDITION USAGE NOTICE * ================================================================= * This package designed for Magento enterprise edition * aheadWorks does not guarantee correct work of this extension * on any other Magento edition except Magento enterprise edition. * aheadWorks does not provide extension support in case of * incorrect edition usage. * ================================================================= * * @category AW * @package AW_Onsale * @version 2.4.0 * @copyright Copyright (c) 2010-2012 aheadWorks Co. (http://www.aheadworks.com) * @license http://ecommerce.aheadworks.com/AW-LICENSE.txt */ function setSortOrder(Mage_Eav_Model_Entity_Setup $setup, $entityTypeId, $code, $sortOrder) { $id = $setup->getAttribute($entityTypeId, $code, 'attribute_id'); $setup->updateAttribute($entityTypeId, $id, array(), null, $sortOrder); }
function updateFrontendModel(Mage_Eav_Model_Entity_Setup $setup, $entityTypeId, $code, $value) { $id = $setup->getAttribute($entityTypeId, $code, 'attribute_id'); $setup->updateAttribute($entityTypeId, $id, 'frontend_model', $value); }
/** * aheadWorks Co. * * NOTICE OF LICENSE * * This source file is subject to the EULA * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://ecommerce.aheadworks.com/AW-LICENSE.txt * * ================================================================= * MAGENTO EDITION USAGE NOTICE * ================================================================= * This package designed for Magento enterprise edition * aheadWorks does not guarantee correct work of this extension * on any other Magento edition except Magento enterprise edition. * aheadWorks does not provide extension support in case of * incorrect edition usage. * ================================================================= * * @category AW * @package AW_Onsale * @version 2.4.0 * @copyright Copyright (c) 2010-2012 aheadWorks Co. (http://www.aheadworks.com) * @license http://ecommerce.aheadworks.com/AW-LICENSE.txt */ function updateScoupe(Mage_Eav_Model_Entity_Setup $setup, $entityTypeId, $code, $value) { $id = $setup->getAttribute($entityTypeId, $code, 'attribute_id'); $setup->updateAttribute($entityTypeId, $id, 'is_global', $value); }
if (!$webposHelper->columnExist($this->getTable('sales/order'), 'webpos_base_change')) { $installer->run("ALTER TABLE {$this->getTable('sales/order')} ADD COLUMN `webpos_base_change` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($this->getTable('sales/invoice'), 'webpos_change')) { $installer->run("ALTER TABLE {$this->getTable('sales/invoice')} ADD COLUMN `webpos_change` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($this->getTable('sales/invoice'), 'webpos_base_change')) { $installer->run("ALTER TABLE {$this->getTable('sales/invoice')} ADD COLUMN `webpos_base_change` decimal(12,4) NOT NULL default '0'"); } $webposHelper->addDefaultData(); $installer->endSetup(); $installer = new Mage_Eav_Model_Entity_Setup(); $installer->startSetup(); $fieldList = array('tax_class_id'); foreach ($fieldList as $field) { $applyTo = explode(',', $installer->getAttribute(Mage_Catalog_Model_Product::ENTITY, $field, 'apply_to')); if (!in_array('customsale', $applyTo)) { $applyTo[] = 'customsale'; $installer->updateAttribute(Mage_Catalog_Model_Product::ENTITY, $field, 'apply_to', implode(',', $applyTo)); } } $installer->endSetup(); $product = Mage::getModel('catalog/product'); $product->getIdBySku('webpos-customsale'); if ($product->getId()) { try { $product->setData('tax_class_id', 0); $product->save(); } catch (Exception $e) { Zend_debug::dump($e->getMessage()); }
<?php $installer = new Mage_Eav_Model_Entity_Setup('core_setup'); $installer->startSetup(); $entityTypeId = $installer->getEntityTypeId('catalog_product'); $idAttributeOldSelect = $installer->getAttribute($entityTypeId, 'categoria_anymarket', 'attribute_id'); $installer->updateAttribute($entityTypeId, $idAttributeOldSelect, 'frontend_input', 'select'); $installer->updateAttribute($entityTypeId, $idAttributeOldSelect, 'backend_type', 'varchar'); $installer->updateAttribute($entityTypeId, $idAttributeOldSelect, 'backend_model', 'eav/entity_attribute_backend_array'); $installer->updateAttribute($entityTypeId, $idAttributeOldSelect, 'source_model', 'db1_anymarket/system_config_source_categories_values'); $installer->updateAttribute($entityTypeId, $idAttributeOldSelect, 'note', 'Selecione uma categoria para enviar ao Anymarket'); $installer->endSetup();
public function createLightSpeedAttributeSet() { // Find the Default Product attribute set. $collection = Mage::getResourceModel('eav/entity_attribute_set_collection')->setEntityTypeFilter($this->getProductEntityTypeId()->getId())->addFieldToFilter('attribute_set_name', 'Default'); $default_attribute_set = $collection->getFirstItem(); // Create a attribute set called "LIGHTSPEED_PRODUCT_ATTRIBUTE_SET" based off of the Default product attribute set. $lightspeed_attribute_set_name = "LIGHTSPEED_PRODUCT_ATTRIBUTE_SET"; $attrSet = Mage::getModel('eav/entity_attribute_set'); $attrSet->setAttributeSetName($lightspeed_attribute_set_name); $attrSet->setEntityTypeId($this->getProductEntityTypeId()->getId()); try { $attrSet->save(); } catch (Mage_Core_Exception $e) { $this->_fault('filters_invalid', $e->getMessage()); } $attrSet = $attrSet->initFromSkeleton($default_attribute_set->getId()); $attrSet->save(); $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); // Create a group called LIGHTSPEED_ATTRIBUTES for the $setup->addAttributeGroup('catalog_product', $attrSet->getId(), 'LIGHTSPEED_ATTRIBUTES'); $attrSet->save(); // Create the attributes to be put into the LIGHTSPEED_ATTRIBUTES group. $product_colour_code = 'LIGHTSPEED_PRODUCT_COLOR'; $product_size_code = 'LIGHTSPEED_PRODUCT_SIZE'; $this->createAttribute($product_colour_code, 'Color'); // Colour is spelt Color, the American way. $this->createAttribute($product_size_code, 'Size'); $attribute_group = $setup->getAttributeGroup('catalog_product', $attrSet->getId(), 'LIGHTSPEED_ATTRIBUTES'); $colour_attribute = $setup->getAttribute('catalog_product', $product_colour_code); $size_attribute = $setup->getAttribute('catalog_product', $product_size_code); $attrSet->save(); // Add attributes to attribute set. $setup->addAttributeToSet($entityTypeId = 'catalog_product', $attrSet->getId(), $attribute_group['attribute_group_id'], $colour_attribute['attribute_id']); $setup->addAttributeToSet($entityTypeId = 'catalog_product', $attrSet->getId(), $attribute_group['attribute_group_id'], $size_attribute['attribute_id']); return $attrSet->getId(); }
<?php /** * * @category Directshop * @package Directshop_FraudDetection * @author Ben James * @copyright Copyright (c) 2008-2010 Directshop Pty Ltd. (http://directshop.com.au) */ $installer = $this; $installer->startSetup(); $installer->run("\r\nDROP TABLE IF EXISTS {$this->getTable('frauddetection_data')};\r\nCREATE TABLE {$this->getTable('frauddetection_data')} (\r\n `entity_id` int(10) NOT NULL auto_increment,\r\n `order_id` int(10) NOT NULL,\r\n `fraud_score` int(11) NULL DEFAULT '0',\r\n `fraud_data` text NULL,\r\n `sent_data` text NULL,\r\n PRIMARY KEY (`entity_id`),\r\n KEY `order_id_idx` (`order_id`)\r\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\r\n"); // transfer any old data across $setup = new Mage_Eav_Model_Entity_Setup('core_setup'); if ($setup->getEntityType('order_payment') !== false) { $responseAttribute = $setup->getAttribute('order_payment', 'maxmind_response'); $scoreAttribute = $setup->getAttribute('order', 'fraud_score'); if ($responseAttribute && $setup->tableExists('sales_order_entity_text')) { $read = Mage::getSingleton('core/resource')->getConnection('core_read'); $existingData = $read->fetchAll("select * from {$this->getTable('sales_order_entity_text')} where attribute_id = ?", array($responseAttribute['attribute_id'])); foreach ($existingData as $data) { $parentId = $read->fetchOne("select parent_id from {$this->getTable('sales_order_entity')} where entity_id = ?", array($data['entity_id'])); $fraudScore = 0; if ($scoreAttribute) { $fraudScore = $read->fetchOne("select value from {$this->getTable('sales_order_int')} where entity_id = ? AND attribute_id = ?", array($parentId, $scoreAttribute['attribute_id'])); } else { $fraudData = @unserialize($data['value']); if (isset($fraudData['ourscore'])) { $fraudScore = $fraudData['ourscore']; } }
public function updatedb23Action() { $installer = new Mage_Core_Model_Resource_Setup(); $installer->startSetup(); $webposHelper = Mage::helper("webpos"); if (!$webposHelper->columnExist($installer->getTable('sales_flat_order'), 'webpos_admin_id')) { $installer->run("ALTER TABLE {$installer->getTable('sales_flat_order')} ADD COLUMN `webpos_admin_id` int(10) default NULL"); } if (!$webposHelper->columnExist($installer->getTable('sales_flat_order'), 'webpos_admin_name')) { $installer->run("ALTER TABLE {$installer->getTable('sales_flat_order')} ADD COLUMN `webpos_admin_name` varchar(255) default NULL"); } if (!$webposHelper->columnExist($installer->getTable('webpos_user'), 'store_ids')) { $installer->run("ALTER TABLE {$installer->getTable('webpos_user')} ADD `store_ids` VARCHAR(255) NOT NULL AFTER `user_id`;"); } if (!$webposHelper->columnExist($installer->getTable('webpos_transaction'), 'user_id')) { $installer->run("ALTER TABLE {$installer->getTable('webpos_transaction')} ADD `user_id` int(4) unsigned DEFAULT NULL;"); } if (!$webposHelper->columnExist($installer->getTable('webpos_transaction'), 'till_id')) { $installer->run("ALTER TABLE {$installer->getTable('webpos_transaction')} ADD `till_id` unsigned NULL DEFAULT 0;"); } if (!$webposHelper->columnExist($installer->getTable('webpos_transaction'), 'location_id')) { $installer->run("ALTER TABLE {$installer->getTable('webpos_transaction')} ADD `location_id` unsigned NULL DEFAULT 0;"); } if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'till_id')) { $installer->run(" ALTER TABLE {$installer->getTable('sales/order')} ADD `till_id` int(11) unsigned NOT NULL DEFAULT 0; "); } if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'location_id')) { $installer->run(" ALTER TABLE {$installer->getTable('sales/order')} ADD `location_id` int(11) unsigned NOT NULL DEFAULT 0; "); } if (!$webposHelper->columnExist($installer->getTable('sales/quote_payment'), 'ccforpos_ref_no')) { $installer->run(" ALTER TABLE {$installer->getTable('sales/quote_payment')} ADD `ccforpos_ref_no` VARCHAR( 255 ) NOT NULL; "); } if (!$webposHelper->columnExist($installer->getTable('sales/order_payment'), 'ccforpos_ref_no')) { $installer->run(" ALTER TABLE {$installer->getTable('sales/order_payment')} ADD `ccforpos_ref_no` VARCHAR( 255 ) NOT NULL; "); } if (!$webposHelper->columnExist($installer->getTable('webpos_order'), 'till_id')) { $installer->run(" ALTER TABLE {$installer->getTable('webpos_order')} ADD `till_id` int(11) unsigned NOT NULL DEFAULT 0; "); } if (!$webposHelper->columnExist($installer->getTable('webpos_order'), 'location_id')) { $installer->run(" ALTER TABLE {$installer->getTable('webpos_order')} ADD `location_id` int(11) unsigned NOT NULL DEFAULT 0; "); } if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_cash')) { $installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_cash` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_base_cash')) { $installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_base_cash` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_cash')) { $installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_cash` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_base_cash')) { $installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_base_cash` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_ccforpos')) { $installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_ccforpos` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_base_ccforpos')) { $installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_base_ccforpos` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_ccforpos')) { $installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_ccforpos` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_base_ccforpos')) { $installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_base_ccforpos` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_cp1forpos')) { $installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_cp1forpos` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_base_cp1forpos')) { $installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_base_cp1forpos` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_cp1forpos')) { $installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_cp1forpos` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_base_cp1forpos')) { $installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_base_cp1forpos` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_cp2forpos')) { $installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_cp2forpos` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_base_cp2forpos')) { $installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_base_cp2forpos` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_cp2forpos')) { $installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_cp2forpos` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_base_cp2forpos')) { $installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_base_cp2forpos` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_change')) { $installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_change` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/order'), 'webpos_base_change')) { $installer->run("ALTER TABLE {$installer->getTable('sales/order')} ADD COLUMN `webpos_base_change` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_change')) { $installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_change` decimal(12,4) NOT NULL default '0'"); } if (!$webposHelper->columnExist($installer->getTable('sales/invoice'), 'webpos_base_change')) { $installer->run("ALTER TABLE {$installer->getTable('sales/invoice')} ADD COLUMN `webpos_base_change` decimal(12,4) NOT NULL default '0'"); } $installer->endSetup(); $installer = new Mage_Eav_Model_Entity_Setup(); $installer->startSetup(); $fieldList = array('tax_class_id'); foreach ($fieldList as $field) { $applyTo = explode(',', $installer->getAttribute(Mage_Catalog_Model_Product::ENTITY, $field, 'apply_to')); if (!in_array('customsale', $applyTo)) { $applyTo[] = 'customsale'; $installer->updateAttribute(Mage_Catalog_Model_Product::ENTITY, $field, 'apply_to', implode(',', $applyTo)); } } $installer->endSetup(); $product = Mage::getModel('catalog/product'); $product->getIdBySku('webpos-customsale'); if ($product->getId()) { try { $product->setData('tax_class_id', 0); $product->save(); } catch (Exception $e) { Zend_debug::dump($e->getMessage()); } } }