<?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();
Esempio n. 2
0
 public function createOptions($newOptions)
 {
     $cache = Mage::app()->getCache();
     $installer = new Mage_Eav_Model_Entity_Setup('core_setup');
     $attributeApi = Mage::getModel('catalog/product_attribute_api');
     $helperCatalog = Mage::helper('catalog');
     $installer->startSetup();
     $attributesList = array();
     foreach ($newOptions as $attribute_id => $options) {
         $newOption = array();
         $newOption['attribute_id'] = $attribute_id;
         $attributesList[] = $attribute_id;
         $newOption['value'] = array();
         for ($i = 0; $i < sizeof($options); $i++) {
             $label = $helperCatalog->stripTags($options[$i]);
             $cachedValue = $cache->load($attribute_id . '_' . strtolower($label));
             if ($cachedValue != 1) {
                 $newOption['value']['option' . $i][0] = $label;
                 $cache->save("1", $attribute_id . '_' . strtolower($label), array('LINNLIVE_EXTENSION_ATTRIBUTES'), 300);
             }
         }
         if (sizeof($newOption['value'])) {
             $installer->addAttributeOption($newOption);
         }
     }
     $installer->endSetup();
     Mage::app()->cleanCache(array(Mage_Core_Model_Translate::CACHE_TAG));
     $currentOptions = array();
     $attributeApi = Mage::getModel('catalog/product_attribute_api');
     foreach ($attributesList as $attribute_id) {
         $attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', $attribute_id);
         foreach ($attribute->getSource()->getAllOptions(true, true) as $option) {
             $label = strtolower($option['label']);
             $optionId = $option['value'];
             if (!isset($currentOptions[$attribute_id][$label])) {
                 $currentOptions[$attribute_id][$label] = $optionId;
             }
             $currentOptionId = $currentOptions[$attribute_id][$label];
             if ($optionId > $currentOptionId) {
                 $attributeApi->removeOption($attribute_id, $optionId);
             }
             if ($currentOptionId > $optionId) {
                 $attributeApi->removeOption($attribute_id, $currentOptionId);
                 $currentOptions[$attribute_id][$label] = $optionId;
             }
         }
     }
     return $currentOptions;
 }
Esempio n. 3
0
<?php

$installer = $this;
$installer->startSetup();
$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$entityTypeId = $setup->getEntityTypeId('customer_address');
$attributeSetId = $setup->getDefaultAttributeSetId($entityTypeId);
$attributeGroupId = $setup->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
$setup->addAttributeToGroup($entityTypeId, $attributeSetId, $attributeGroupId, 'tax_invoice', '999');
$setup->endSetup();
$installer->endSetup();
 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());
         }
     }
 }