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; } }
* 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();
public function after_order_placed($observer) { $incrementId = $observer->getOrder()->getIncrementId(); // DK. $country = Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress()->getCountryId(); $postcode = Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress()->getPostcode(); $send24_consumer_key = $this->getConfigData('send24_consumer_key'); $send24_consumer_secret = $this->getConfigData('send24_consumer_secret'); $auth = base64_encode($send24_consumer_key . ':' . $send24_consumer_secret); $select_country = 'Ekspres'; // get/check Express. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://send24.com/wc-api/v3/get_products"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Basic " . $auth)); $send24_countries = json_decode(curl_exec($ch)); curl_close($ch); $n = count($send24_countries); for ($i = 0; $i < $n; $i++) { if ($send24_countries[$i]->title == $select_country) { $coast = $send24_countries[$i]->price; $send24_product_id = $send24_countries[$i]->product_id; $i = $n; $is_available = true; } else { $is_available = false; } } if ($is_available == true) { $insurance_price = 0; $discount = "false"; $ship_total = $type = $price_need = ''; $user_id = $observer->getOrder()->getCustomerId(); $shipping_data = $observer->getOrder()->getShippingAddress()->getData(); $billing_data = $observer->getOrder()->getBillingAddress()->getData(); if ($select_country == 'Ekspres') { $select_country = 'Danmark'; $where_shop_id = 'ekspres'; } // Create order. $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://send24.com/wc-api/v3/create_order"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HEADER, FALSE); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_POSTFIELDS, ' { "TO_company": "' . $shipping_data['company'] . '", "TO_first_name": "' . $shipping_data['firstname'] . '", "TO_last_name": "' . $shipping_data['lastname'] . '", "TO_phone": "' . $shipping_data['telephone'] . '", "TO_email": "' . $shipping_data['email'] . '", "TO_country": "' . $select_country . '", "TO_city": "' . $shipping_data['city'] . '", "TO_postcode": "' . $postcode . '", "Insurance" : "' . $insurance_price . '", "Weight": "5", "TO_address": "' . $shipping_data['street'] . '", "WHAT_product_id": "' . $send24_product_id . '", "WHERE_shop_id": "' . $where_shop_id . '", "discount": "' . $discount . '", "type": "' . $type . '", "need_points": "' . $price_need . '", "total": "' . $ship_total . '", "ship_mail": "' . $shipping_data['email'] . '", "bill_mail": "' . $billing_data['email'] . '" } '); curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: Basic " . $auth, "Content-Type: application/json")); $response = curl_exec($ch); curl_close($ch); } $response_order = json_decode($response, JSON_FORCE_OBJECT); $history = Mage::getModel('sales/order_status_history')->setStatus($observer->getOrder()->getStatus())->setComment('<strong>Track parsel </strong><br><a href="' . $response_order['track'] . '" target="_blank">' . $response_order['track'] . '</a>')->setEntityName(Mage_Sales_Model_Order::HISTORY_ENTITY_NAME)->setIsCustomerNotified(false)->setCreatedAt(date('Y-m-d H:i:s', time() - 60 * 60 * 24)); $observer->getOrder()->addStatusHistory($history); // Create custom value for order. // it temporarily 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(); $attribute_track_parsel = array('type' => 'varchar', 'backend_type' => 'varchar', 'frontend_input' => 'varchar', 'is_user_defined' => true, 'label' => 'Send24 Track Parsel', 'visible' => false, 'required' => false, 'user_defined' => false, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'default' => ''); $attribute_printout = array('type' => 'text', 'backend_type' => 'text', 'frontend_input' => 'text', 'is_user_defined' => true, 'label' => 'Send24 Printout', 'visible' => false, 'required' => false, 'user_defined' => false, 'searchable' => false, 'filterable' => false, 'comparable' => false, 'default' => ''); $installer->addAttribute('order', 'send24_track_parsel', $attribute_track_parsel); $installer->addAttribute('order', 'send24_printout', $attribute_printout); $installer->endSetup(); // Add Track parsel. $observer->getOrder()->setSend24TrackParsel($response_order['track']); // Add Printout. $printout = json_encode($response_order); $observer->getOrder()->setSend24Printout($printout); $observer->getOrder()->save(); return true; }
<?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();
} $installer->run("\n\tDROP TABLE IF EXISTS {$this->getTable('payperrentals/mailinglog')};\n\n\tCREATE TABLE {$this->getTable('payperrentals/mailinglog')} (\n\t\t`id` INT( 11 ) NOT NULL auto_increment,\n\t\t`is_cron` int(11) NOT NULL DEFAULT '0',\n\t\t`from_name` varchar(250) NOT NULL,\n\t\t`from_email` varchar(250) NOT NULL,\n\t\t`to_name` varchar(250) NOT NULL,\n\t\t`to_email` varchar(250) NOT NULL,\n\t\t`subject` TEXT,\n\t\t`message` TEXT,\n\t\t`message_error` TEXT,\n\t\t`created_at` DATETIME NOT NULL ,\n\t\tPRIMARY KEY ( `id` )\n\n\t) DEFAULT CHARSET utf8 ENGINE = InnoDB;\n\n\t"); $installer->endSetup(); $installer2 = new Mage_Sales_Model_Mysql4_Setup('sales_setup'); $installer2->startSetup(); $installer2->addAttribute('order', 'start_datetime', array('type' => 'datetime', 'grid' => true, 'unsigned' => true)); $installer2->addAttribute('order', 'end_datetime', array('type' => 'datetime', 'grid' => true, 'unsigned' => true)); $installer2->addAttribute('order', 'send_datetime', array('type' => 'datetime', 'grid' => true, 'unsigned' => true)); $installer2->addAttribute('order', 'return_datetime', array('type' => 'datetime', 'grid' => true, 'unsigned' => true)); $installer2->addAttribute('order', 'estimate_send', array('type' => 'datetime', 'grid' => true, 'unsigned' => true)); $installer2->addAttribute('order', 'estimate_return', array('type' => 'datetime', 'grid' => true, 'unsigned' => true)); $installer2->addAttribute('quote', 'start_datetime', array('type' => 'datetime', 'grid' => true, 'unsigned' => true)); $installer2->addAttribute('quote', 'end_datetime', array('type' => 'datetime', 'grid' => true, 'unsigned' => true)); $installer2->getConnection()->addColumn($installer2->getTable('sales/quote'), 'start_datetime', 'DATETIME'); $installer2->getConnection()->addColumn($installer2->getTable('sales/order'), 'end_datetime', 'DATETIME'); $installer2->getConnection()->addColumn($installer2->getTable('sales/quote'), 'end_datetime', 'DATETIME'); $installer2->getConnection()->addColumn($installer2->getTable('sales/order'), 'start_datetime', 'DATETIME'); $installer2->getConnection()->addColumn($installer2->getTable('sales/order'), 'send_datetime', 'DATETIME'); $installer2->getConnection()->addColumn($installer2->getTable('sales/order'), 'return_datetime', 'DATETIME'); $installer2->getConnection()->addColumn($installer2->getTable('sales/order'), 'estimate_send', 'DATETIME'); $installer2->getConnection()->addColumn($installer2->getTable('sales/order'), 'estimate_return', 'DATETIME'); $installer2->addAttribute('quote', 'send_datetime', array('type' => 'datetime', 'grid' => true, 'unsigned' => true)); $installer2->addAttribute('quote', 'return_datetime', array('type' => 'datetime', 'grid' => true, 'unsigned' => true)); $installer2->addAttribute('quote', 'estimate_send', array('type' => 'datetime', 'grid' => true, 'unsigned' => true)); $installer2->addAttribute('quote', 'estimate_return', array('type' => 'datetime', 'grid' => true, 'unsigned' => true)); $installer2->getConnection()->addColumn($installer2->getTable('sales/quote'), 'send_datetime', 'DATETIME'); $installer2->getConnection()->addColumn($installer2->getTable('sales/quote'), 'return_datetime', 'DATETIME'); $installer2->getConnection()->addColumn($installer2->getTable('sales/quote'), 'estimate_send', 'DATETIME'); $installer2->getConnection()->addColumn($installer2->getTable('sales/quote'), 'estimate_return', 'DATETIME'); $installer2->endSetup();