Exemplo n.º 1
0
 /**
  * check the database for expected tables, columns and attributes
  *
  * @param Fooman_Common_Model_Selftester $selftester
  *
  * @return bool
  */
 public function dbCheck(Fooman_Common_Model_Selftester $selftester)
 {
     $localError = false;
     $selftester->messages[] = "Checking database";
     $installer = new Mage_Sales_Model_Mysql4_Setup('sales_setup');
     $installer->startSetup();
     foreach ($selftester->_getDbFields() as $field) {
         switch ($field[0]) {
             case 'eav':
                 $localError = $this->_dbCheckEav($selftester, $field, $installer, $localError);
                 break;
             case 'sql-column':
                 $localError = $this->_dbCheckSqlColumn($selftester, $field, $installer, $localError);
                 break;
             case 'table':
                 $localError = $this->_dbCheckSqlTable($selftester, $field, $installer, $localError);
                 break;
             case 'constraint':
                 $localError = $this->_dbCheckForeignKeyConstraint($selftester, $field, $installer, $localError);
                 break;
             case 'row-data':
                 $localError = $this->_dbCheckDbRow($selftester, $field, $installer, $localError);
                 break;
         }
     }
     $installer->endSetup();
     if (empty($localError)) {
         return true;
     } else {
         if ($this->_dbOkay == false) {
             $selftester->messages[] = "<p>The selftest has found some problems with your database install.\n                    You can attempt to fix this by clicking this <a href=\"" . htmlentities(Mage::app()->getRequest()->getServer('PHP_SELF', '')) . "?fix=true\">link</a>.</p><p style=\"color:red;\"><em>A DATABASE BACKUP IS strongly\n                    RECOMMENDED BEFORE ATTEMPTING THIS!</em></p>";
         }
         return 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 info@idealiagroup.com so we can send you a copy immediately.
 *
 * @category   MSP
 * @package    MSP_CashOnDelivery
 * @copyright  Copyright (c) 2013 IDEALIAGroup srl (http://www.idealiagroup.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
$installer = $this;
$installer->startSetup();
$setup = new Mage_Sales_Model_Mysql4_Setup('core_setup');
$setup->startSetup();
$setup->addAttribute('invoice', 'msp_base_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
$setup->addAttribute('invoice', 'msp_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
$setup->addAttribute('order', 'msp_base_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
$setup->addAttribute('order', 'msp_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
$setup->addAttribute('quote', 'msp_base_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
$setup->addAttribute('quote', 'msp_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
$setup->addAttribute('order_address', 'msp_base_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
$setup->addAttribute('order_address', 'msp_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
$setup->addAttribute('quote_address', 'msp_base_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
$setup->addAttribute('quote_address', 'msp_cashondelivery_incl_tax', array('type' => 'decimal', 'visible' => false, 'required' => true));
$setup->endSetup();
$installer->endSetup();
Exemplo n.º 3
0
 public function dbCheck()
 {
     $dbOk = true;
     $localError = false;
     $this->messages[] = "Checking database";
     $installer = new Mage_Sales_Model_Mysql4_Setup('sales_setup');
     $installer->startSetup();
     if (isset($_GET['fix'])) {
         $fix = $_GET['fix'] == 'true';
     } else {
         $fix = false;
     }
     foreach ($this->_getDbFields() as $field) {
         switch ($field[0]) {
             case 'eav':
                 try {
                     $sql = "SELECT `attribute_id` FROM `{$installer->getTable('eav_attribute')}` WHERE `attribute_code` ='{$field['2']}'";
                     $test = $installer->getConnection('core_read')->fetchRow($sql);
                     if (!isset($test['attribute_id']) && !$test['attribute_id'] > 0) {
                         throw new Exception('eav attribute ' . $field[2] . ' is not installed');
                     }
                     $this->messages[] = "[OK] eav attribute " . $field[2] . " with id " . $test['attribute_id'] . "";
                 } catch (Exception $e) {
                     if ($fix) {
                         $this->messages[] = "Attempting fix for eav attribute " . $field[2] . "";
                         try {
                             $installer->addAttribute($field[1], $field[2], $field[3]);
                             $this->messages[] = "[FIX OK] eav attribute " . $field[2] . " fixed";
                         } catch (Exception $e) {
                             $this->messages[] = "[FAILED] fixing eav attribute " . $field[2] . "";
                             $dbOk = false;
                             $this->messages[] = $e->getMessage();
                             $localError = true;
                         }
                     } else {
                         $this->messages[] = "[FAILED] eav attribute " . $field[2] . "";
                         Mage::getSingleton('core/session')->addWarning('[FAILED] eav attribute ' . $field[2]);
                         $dbOk = false;
                         $this->messages[] = "[ERR] " . $e->getMessage();
                         $localError = true;
                     }
                 }
                 break;
             case 'sql-column':
                 try {
                     $test = $installer->run("SELECT `{$field['2']}` FROM `{$installer->getTable($field[1])}` LIMIT 0");
                     $this->messages[] = "[OK] column " . $field[2] . "";
                 } catch (Exception $e) {
                     if ($fix) {
                         $this->messages[] = "Attempting fix for column " . $field[2] . "";
                         try {
                             $test = $installer->run("ALTER TABLE `{$installer->getTable($field[1])}` ADD COLUMN `{$field['2']}` {$field['3']}");
                             $this->messages[] = "[FIX OK] column " . $field[2] . " fixed";
                         } catch (Exception $e) {
                             $this->messages[] = "[FAILED] fixing column " . $field[2] . "";
                             $dbOk = false;
                             $this->messages[] = $e->getMessage();
                             $localError = true;
                         }
                     } else {
                         $this->messages[] = "[FAILED] column " . $field[2] . "";
                         $dbOk = false;
                         $this->messages[] = "[ERR] " . $e->getMessage();
                         $localError = true;
                     }
                 }
                 break;
         }
     }
     $installer->endSetup();
     if (empty($localError)) {
         return true;
     } else {
         if ($dbOk == false) {
             $this->messages[] = "<p>The selftest has found some problems with your database install.\n                    You can attempt to fix this by appending ?fix=true to the address or clicking this <a href=\"" . htmlentities($_SERVER['PHP_SELF']) . "?fix=true\">link</a>.</p><p style=\"color:red;\"><em>A DATABASE BACKUP IS strongly RECOMMENDED BEFORE ATTEMPTING THIS!</em></p>";
         }
         return false;
     }
 }
Exemplo n.º 4
0
<?php

/**
 * @package		Eternal_Megamenu
 * @author		Eternal Friend
 * @copyright	Copyright 2014
 */
require_once 'app/Mage.php';
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$installer = new Mage_Sales_Model_Mysql4_Setup();
//Mage_Eav_Model_Entity_Setup,Mage_Catalog_Model_Resource_Setup,
$installer->startSetup();
$installer->updateAttribute('catalog_category', 'sw_cat_block_type', 'is_required', 0, '10');
$installer->updateAttribute('catalog_category', 'sw_cat_static_width', 'note', 'The width of the static width megamenu popup. eg: 600px', '11');
$installer->updateAttribute('catalog_category', 'sw_cat_block_columns', 'is_required', 0, '12');
$installer->updateAttribute('catalog_category', 'sw_cat_block_top', 'is_required', 0, '31');
$installer->updateAttribute('catalog_category', 'sw_cat_left_block_width', 'is_required', 0, '40');
$installer->updateAttribute('catalog_category', 'sw_cat_block_left', 'is_required', 0, '41');
$installer->updateAttribute('catalog_category', 'sw_cat_right_block_width', 'is_required', 0, '50');
$installer->updateAttribute('catalog_category', 'sw_cat_block_right', 'is_required', 0, '51');
$installer->updateAttribute('catalog_category', 'sw_cat_block_bottom', 'is_required', 0, '60');
$installer->updateAttribute('catalog_category', 'sw_cat_label', 'is_required', 0, '14');
$installer->updateAttribute('catalog_category', 'sw_cat_float_type', 'is_required', 0, '13');
$installer->addAttribute('catalog_category', 'sw_icon_image', array('type' => 'varchar', 'label' => 'Icon Image', 'input' => 'image', 'backend' => 'catalog/category_attribute_backend_image', 'required' => false, 'sort_order' => 15, 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 'group' => 'Menu'));
$installer->addAttribute('catalog_category', 'sw_font_icon', array('group' => 'Menu', 'label' => 'Font Icon Class', 'note' => 'If this category has no "Icon Image", font icon will be shown. example to input: icon-dollar', 'type' => 'text', 'input' => 'text', 'visible' => true, 'required' => false, 'backend' => '', 'frontend' => '', 'searchable' => false, 'filterable' => false, 'comparable' => false, 'user_defined' => true, 'visible_on_front' => true, 'wysiwyg_enabled' => true, 'is_html_allowed_on_front' => true, 'sort_order' => 16, 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE));
$installer->endSetup();