//Get Store Configuration Setting
echo Mage::getStoreConfig("carriers/freeshipping/free_shipping_subtotal");
//Get Currency Symbol
echo Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
//Print Amount Proper Currency (e.g. $102.36)
echo Mage::helper('core')->currency($subtotal, true, true)
- 24th, Jul 2010
Magento Useful Methods
- 23rd, Jul 2010
Magento Customer by Orders Total Report PHP Script
mysql_connect("localhost","root","root", 3306) or die(mysql_error());
mysql_select_db("MagentoDatabase") or die(mysql_error());
//Get Customer Entity Type Id
$query = "SELECT entity_type_id FROM `eav_entity_type` WHERE entity_type_code = 'customer'";
$query_Row = mysql_query($query);
$qs = mysql_fetch_assoc($query_Row);
$customerEntity = $qs["entity_type_id"];
//Get Customer Entity Address Id
$query = "SELECT entity_type_id FROM `eav_entity_type` WHERE entity_type_code = 'customer_address'";
$query_Row = mysql_query($query);
$qs = mysql_fetch_assoc($query_Row);
$customerAddressEntity = $qs["entity_type_id"];
//Get Attributes Ids For Customer
$attributes = array("'email'", "'prefix'", "'firstname'", "'lastname'", "'default_billing'");
$query = "SELECT attribute_code, attribute_id FROM eav_attribute WHERE attribute_code IN ( ".implode(",", $attributes)." ) AND entity_type_id = ".$customerEntity;
$query_Row = mysql_query($query);
while($qs = mysql_fetch_assoc($query_Row)){
$attributeIds[$qs["attribute_code"]] = $qs["attribute_id"];
}
//Get Attributes Ids For Customer Address
$attributes = array("'company'", "'street'", "'postcode'", "'city'", "'region'", "'country_id'", "'telephone'");
$query = "SELECT attribute_code, attribute_id FROM eav_attribute WHERE attribute_code IN ( ".implode(",", $attributes)." ) AND entity_type_id = ".$customerAddressEntity;
$query_Row = mysql_query($query);
while($qs = mysql_fetch_assoc($query_Row)){
$attributeIds[$qs["attribute_code"]] = $qs["attribute_id"];
}
$query = "
SELECT e.customer_id AS customer_id, ROUND(SUM((e.base_subtotal-IFNULL(e.base_subtotal_refunded,0)-IFNULL(e.base_subtotal_canceled,0))*e.base_to_global_rate), 2) AS orders_sum_amount, ROUND(AVG((e.base_subtotal-IFNULL(e.base_subtotal_refunded,0)-IFNULL(e.base_subtotal_canceled,0))*e.base_to_global_rate),2) AS orders_avg_amount, COUNT( e.entity_id ) AS `orders_count` , `_table_email`.`email`, `_table_prefix`.`value` AS `prefix`, `_table_firstname`.`value` AS `firstname`, `_table_lastname`.`value` AS `lastname`, `_table_default_billing`.`value` AS `default_billing`, `_table_billing_company`.`value` AS `billing_company`, `_table_billing_street`.`value` AS `billing_street`, `_table_billing_postcode`.`value` AS `billing_postcode`, `_table_billing_city`.`value` AS `billing_city`, `_table_billing_region`.`value` AS `billing_region`, `_table_billing_country_id`.`value` AS `billing_country_id`, `_table_billing_telephone`.`value` AS `billing_telephone`
FROM `sales_order` AS `e`
INNER JOIN `customer_entity_varchar` AS `_table_prefix` ON (_table_prefix.entity_id = e.customer_id) AND (_table_prefix.attribute_id=".$attributeIds['prefix'].")
INNER JOIN `customer_entity_varchar` AS `_table_firstname` ON (_table_firstname.entity_id = e.customer_id) AND (_table_firstname.attribute_id=".$attributeIds['firstname'].")
INNER JOIN `customer_entity_varchar` AS `_table_lastname` ON (_table_lastname.entity_id = e.customer_id) AND (_table_lastname.attribute_id=".$attributeIds['lastname'].")
INNER JOIN `customer_entity_int` AS `_table_default_billing` ON (_table_default_billing.entity_id = e.customer_id) AND (_table_default_billing.attribute_id=".$attributeIds['default_billing'].")
LEFT JOIN `customer_address_entity_varchar` AS `_table_billing_company` ON (_table_billing_company.entity_id = _table_default_billing.value) AND (_table_billing_company.attribute_id=".$attributeIds['company'].")
LEFT JOIN `customer_address_entity_text` AS `_table_billing_street` ON (_table_billing_street.entity_id = _table_default_billing.value) AND (_table_billing_street.attribute_id=".$attributeIds['street'].")
LEFT JOIN `customer_address_entity_varchar` AS `_table_billing_postcode` ON (_table_billing_postcode.entity_id = _table_default_billing.value) AND (_table_billing_postcode.attribute_id=".$attributeIds['postcode'].")
LEFT JOIN `customer_address_entity_varchar` AS `_table_billing_city` ON (_table_billing_city.entity_id = _table_default_billing.value) AND (_table_billing_city.attribute_id=".$attributeIds['city'].")
LEFT JOIN `customer_address_entity_varchar` AS `_table_billing_region` ON (_table_billing_region.entity_id = _table_default_billing.value) AND (_table_billing_region.attribute_id=".$attributeIds['region'].")
LEFT JOIN `customer_address_entity_varchar` AS `_table_billing_country_id` ON (_table_billing_country_id.entity_id = _table_default_billing.value) AND (_table_billing_country_id.attribute_id=".$attributeIds['country_id'].")
LEFT JOIN `customer_address_entity_varchar` AS `_table_billing_telephone` ON (_table_billing_telephone.entity_id = _table_default_billing.value) AND (_table_billing_telephone.attribute_id=".$attributeIds['telephone'].")
INNER JOIN `customer_entity` AS `_table_email` ON (_table_email.entity_id = e.customer_id)
WHERE (
e.entity_type_id = '11'
)
AND (
e.state != 'canceled'
)
AND (
e.created_at >= '".date('1900-01-01 00:00:00')."'
AND e.created_at <= '".date('Y-m-d H:i:s')."'
)
GROUP BY `e`.`customer_id`
ORDER BY orders_sum_amount DESC
";
$query_Row = mysql_query($query);
$i=0;
echo "<pre>";
//Headers
$headers = array("customer_id", "email", "orders_sum_amount", "orders_avg_amount", "orders_count", "prefix", "firstname", "lastname", "default_billing","billing_company","billing_street1","billing_street2","billing_street3","billing_postcode","billing_city","billing_region","billing_country_id","billing_telephone");
foreach($headers as $header){
echo addThis($header);
if($header != $headers[count($headers) - 1])
echo ",";
}
echo "\n";
//Rows
while($qs = mysql_fetch_assoc($query_Row))
{
foreach($headers as $header){
//Split Address Lines In 3 Fields (billing_street1, billing_street2, billing_street3)
if(($header == "billing_street1")||($header == "billing_street2")||($header == "billing_street3")) {
if($header == "billing_street1") {
$address = $qs["billing_street"];
$addressLines = preg_split('/[\n\r]+/', str_replace(array('"', '\\'), array('""', '\\\\'), $address), 3);
$i=0;
while($i<3){
if(isset($addressLines[$i]))
echo '"'.$addressLines[$i].'"';
else
echo '""';
$i++;
echo ",";
}
}
}
else {
echo addThis($qs[$header]);
//Add Comma
if($header != $headers[count($headers) - 1])
echo ",";
}
}
echo "\n";
}
echo "</pre>";
function addThis($text){
return '"' . $text . '"';
}
/* This is the final SQL query generated */ SELECT e.customer_id AS customer_id, ROUND(SUM((e.base_subtotal-IFNULL(e.base_subtotal_refunded,0)-IFNULL(e.base_subtotal_canceled,0))*e.base_to_global_rate), 2) AS orders_sum_amount, ROUND(AVG((e.base_subtotal-IFNULL(e.base_subtotal_refunded,0)-IFNULL(e.base_subtotal_canceled,0))*e.base_to_global_rate),2) AS orders_avg_amount, COUNT( e.entity_id ) AS `orders_count` , `_table_email`.`email`, `_table_prefix`.`value` AS `prefix`, `_table_firstname`.`value` AS `firstname`, `_table_lastname`.`value` AS `lastname`, `_table_default_billing`.`value` AS `default_billing`, `_table_billing_company`.`value` AS `billing_company`, `_table_billing_street`.`value` AS `billing_street`, `_table_billing_postcode`.`value` AS `billing_postcode`, `_table_billing_city`.`value` AS `billing_city`, `_table_billing_region`.`value` AS `billing_region`, `_table_billing_country_id`.`value` AS `billing_country_id`, `_table_billing_telephone`.`value` AS `billing_telephone` FROM `sales_order` AS `e` INNER JOIN `customer_entity_varchar` AS `_table_prefix` ON (_table_prefix.entity_id = e.customer_id) AND (_table_prefix.attribute_id=4) INNER JOIN `customer_entity_varchar` AS `_table_firstname` ON (_table_firstname.entity_id = e.customer_id) AND (_table_firstname.attribute_id=5) INNER JOIN `customer_entity_varchar` AS `_table_lastname` ON (_table_lastname.entity_id = e.customer_id) AND (_table_lastname.attribute_id=7) INNER JOIN `customer_entity_int` AS `_table_default_billing` ON (_table_default_billing.entity_id = e.customer_id) AND (_table_default_billing.attribute_id=13) LEFT JOIN `customer_address_entity_varchar` AS `_table_billing_company` ON (_table_billing_company.entity_id = _table_default_billing.value) AND (_table_billing_company.attribute_id=22) LEFT JOIN `customer_address_entity_text` AS `_table_billing_street` ON (_table_billing_street.entity_id = _table_default_billing.value) AND (_table_billing_street.attribute_id=23) LEFT JOIN `customer_address_entity_varchar` AS `_table_billing_postcode` ON (_table_billing_postcode.entity_id = _table_default_billing.value) AND (_table_billing_postcode.attribute_id=28) LEFT JOIN `customer_address_entity_varchar` AS `_table_billing_city` ON (_table_billing_city.entity_id = _table_default_billing.value) AND (_table_billing_city.attribute_id=24) LEFT JOIN `customer_address_entity_varchar` AS `_table_billing_region` ON (_table_billing_region.entity_id = _table_default_billing.value) AND (_table_billing_region.attribute_id=26) LEFT JOIN `customer_address_entity_varchar` AS `_table_billing_country_id` ON (_table_billing_country_id.entity_id = _table_default_billing.value) AND (_table_billing_country_id.attribute_id=25) LEFT JOIN `customer_address_entity_varchar` AS `_table_billing_telephone` ON (_table_billing_telephone.entity_id = _table_default_billing.value) AND (_table_billing_telephone.attribute_id=29) INNER JOIN `customer_entity` AS `_table_email` ON (_table_email.entity_id = e.customer_id) WHERE ( e.entity_type_id = '11' ) AND ( e.state != 'canceled' ) AND ( e.created_at >= '2010-06-07 00:00:00' AND e.created_at <= '2020-01-01 23:59:59' ) GROUP BY `e`.`customer_id` ORDER BY orders_sum_amount DESC
- 9th, Jul 2010
Useful Queries For Magento
<!-- Order Lines --> SELECT sales_order.increment_id AS "Order Number", e.item_id AS "Item Number", e.sku AS "Product Code", IF(e.qty_canceled > 0, 'cancelled', 'shippep') AS "Item Status", IF(e.qty_canceled > 0, e.updated_at, '') AS "Cancelled / Returned date", IF(e.qty_canceled > 0, '0', e.qty_ordered) AS "Number of Items sold", e.qty_canceled AS "Number of Items Returned / Cancelled", e.base_row_total AS "Net Value", e.base_tax_amount AS "VAT Value", e.discount_amount AS "Net Discount Value", ROUND((sales_order.base_shipping_amount/1.15),2) AS "NET P&P Value", sales_order.base_shipping_amount AS "P&P VAT" FROM sales_flat_order_item AS e RIGHT JOIN sales_order ON sales_order.entity_id = e.order_id ORDER BY sales_order.increment_id DESC
- 7th, Jul 2010
Magento Report with Column with Fixed Text
protected function _prepareCollection()
{
$collection = Mage::getResourceModel('customer/customer_collection')
->addNameToSelect()
->addAttributeToSelect('email')
->addAttributeToSelect('created_at')
->joinAttribute('billing_company', 'customer_address/company', 'default_billing', null, 'left')
->joinAttribute('billing_street', 'customer_address/street', 'default_billing', null, 'left')
->joinAttribute('billing_postcode', 'customer_address/postcode', 'default_billing', null, 'left')
->joinAttribute('billing_telephone', 'customer_address/telephone', 'default_billing', null, 'left')
->joinAttribute('billing_city', 'customer_address/city', 'default_billing', null, 'left')
->joinAttribute('billing_country_id', 'customer_address/country_id', 'default_billing', null, 'left');
//This line will add a default text 'No' to all column
$collection->addExpressionAttributeToSelect('rentable', "CONCAT('No')", array("email"));
$this->setCollection($collection);
//echo $collection->getSelectSql();
return parent::_prepareCollection();
}
- 14th, Jun 2010
How to Create a New Website – Multiwebsite
Creating a new website / store in Magento
1) Creating the folder
cd /magento/folder
$ mkdir newmagentostore
$ cp .htaccess newmagentostore/
$ cp index.php newmagentostore/
2) Modify newmagentostore/index.php
$mageFilename = ‘../app/Mage.php’;
2.1) Modify newmagentostore/.htaccess and add these lines:
SetEnvIf Host “127.0.0.1*” MAGE_RUN_CODE=newmagentostore
SetEnvIf Host “127.0.0.1*” MAGE_RUN_TYPE=website
3) Create a root category (Root NewMagentoStore), mark it as anchor
4) Create New Website
Configuration >>> Manage Store
Name: NewMagentoStore Website
Code: newmagentowebsite
Link to the new store
5) Create New Store
Configuration >>> Manage Store
Name: NewMagentoStore Store
Code: newmagentostore
Link to the category
6) Create New View
Configuration >>> Manage Store
Name: NewMagentoStore View
Code: newmagentoview
7) System >>> Configuration
Scope: Default Config
Currency Setup
Add all new currencies
8) System >>> Configuration
Scope: each View
Currency Setup
set the Default Currency
set the Allowed currencies
9) Config Secure and Unsecure Url
System >>> Configurations >>> Web
Scope: new website_view
Unsecure
Base Url: http://localhost:8888/magento/
Base Link URL: {{unsecure_base_url}}newmagentostore/
Secure
Base Url: http://localhost:8888/magento/
Base Link URL: {{secure_base_url}}newmagentostore/
10) Set conversion rates System >>> Manage Currency Rates
Note: If there is more than one currency allowed, the customer will have a drop-down currency select in each product category.
Note2: If you want to configure fixed prices in different currencies, set the Catalog Price Scope to Website in System >>> Configuration >>> Catalog >>> Price
You will be able to choose the scope config in each product.
- 14th, Jun 2010
Magento Admin Menu and Admin Config Variables
<!-- ************************************************ -->
<!-- ADMIN MENU / ADMIN MENU / ADMIN MENU -->
<!-- ************************************************ -->
<!-- USE: http://127.0.0.1/index.php/admin/report_customer/orders/key/b7ce150ef2c79cb01e8a88cc8287f2c1/ -->
<!-- structure menu: Admin >>> Reports >>> Customers >>> Customer by... -->
<!-- menu definition: -->
<adminhtml>
<menu>
<report>
<children>
<customers>
<children>
<emails translate="title" module="reports">
<title>Customers recently order</title>
<sort_order>60</sort_order>
<action>customreports/adminhtml_customer/order</action>
</emails>
</children>
</report>
</menu>
</adminhtml>
<!-- router definition: -->
<admin>
<routers>
<customreports>
<use>admin</use>
<args>
<module>Unexpectedit_CustomReports</module>
<frontName>customreports</frontName>
</args>
</customreports>
</routers>
</admin>
<!-- controller file:
class Unexpectedit_CustomReports_Adminhtml_CustomerController extends Mage_Adminhtml_Controller_Action
{
public function orderAction(){
[...]
}
-->
<!-- ************************************************ -->
<!-- DECLARE RESOURCE with for MENUS FOR ADMIN ROLE USER -->
<!-- ************************************************ -->
<!-- for the Menu defined above, this would be the resource -->
<!-- Note1: just go to Configuration >>> Permissions >>> Roles -->
<adminhtml>
<acl>
<resources>
<admin>
<children>
<report>
<children>
<customers>
<children>
<emails module="reports">
<title>Customers recentyly order</title>
</emails>
</children>
</children>
</report>
</children>
</admin>
</resources>
</acl>
</adminhtml>
<!-- ************************************************ -->
<!-- CONFIG VARIABLES, CONFIGURATION >>> Options -->
<!-- ************************************************ -->
<!-- File: etc/system.xml -->
<?xml version="1.0"?>
<config>
<sections>
<customer>
<groups>
<create_account>
<fields>
<email_welcome_copy translate="label">
<label>Send Welcome Copy To</label>
<frontend_type>text</frontend_type>
<sort_order>10</sort_order>
<show_in_default>1</show_in_default>
<show_in_website>1</show_in_website>
<show_in_store>1</show_in_store>
</email_welcome_copy>
</fields>
</create_account>
</groups>
</customer>
</sections>
</config>
<!-- use: -->
<?php
$email_welcome_copy=Mage::getStoreConfig('customer/create_account/email_welcome_copy');
?>
- 14th, Jun 2010
Magento declare / override Controllers
<!-- ************************************************ -->
<!-- CONTROLLER / DECLARE / Frontend -->
<!-- ************************************************ -->
<!-- USE: http://127.0.0.1/mydebug/ -->
<!-- Note: It is really important that the module name starts with capital letter. If not it would fail in some Unix systems.
Even the Controller file name should have one capital letter and Controller at the end like: IndexController.php NOT ShowProductsController.php-->
<!-- structure:
Unexpectedit/mydebug
-->
<config>
<frontend>
<routers>
<mydebug>
<use>standard</use>
<args>
<module>Unexpectedit_Mydebug</module>
<frontName>mydebug</frontName>
</args>
</mydebug>
</routers>
</frontend>
</config>
<!-- controller file:
class Unexpectedit_Mydebug_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction(){
echo "-Debug module - ";
}
}
-->
<!-- ************************************************ -->
<!-- CONTROLLER / DECLARE / Frontend with layout file -->
<!-- ************************************************ -->
<!-- USE: http://127.0.0.1/mymodule/ -->
<!-- structure:
Unexpectedit/Mymodule
-->
<frontend>
<routers>
<mymodule>
<use>standard</use>
<args>
<module>Unexpectedit_Mymodule</module>
<frontName>mymodule</frontName>
</args>
</mymodule>
</routers>
<layout>
<updates>
<mymodule>
<file>mymodule.xml</file>
</mymodule>
</updates>
</layout>
</frontend>
<!-- controller file: Unexpectedit/controllers/IndexController.php
class Unexpectedit_Mymodule_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
-->
<!-- layout.xml file: -->
<?xml version="1.0"?>
<layout version="0.1.0">
<default>
<reference name="left">
<block type="mymodule/view" name="left.mymodule_view" after="catalog"></block>
</reference>
</default>
<mymodule_index_index>
<reference name="content">
<block type="mymodule/results" name="mymodule_results" after="catalog.leftnav" template="mymodule/results.phtml" />
</reference>
</mymodule_index_index>
</layout>
<!-- ************************************************ -->
<!-- CONTROLLER / DECLARE / Admin -->
<!-- ************************************************ -->
<!-- USE: http://127.0.0.1/index.php/customreports/adminhtml_sales/bestseller/key/1eb756c24ee25b303bcf6711da65e4f6/ -->
<!-- structure:
Unexpectedit/CustomReports
/controllers
/Adminhtml
SalesController.php
-->
<!-- menu link
<emails translate="title" module="reports">
<title>Sales Report</title>
<action>customreports/adminhtml_sales/bestseller</action>
</emails>
-->
<admin>
<routers>
<customreports>
<use>admin</use>
<args>
<module>Unexpectedit_CustomReports</module>
<frontName>customreports</frontName>
</args>
</customreports>
</routers>
</admin>
<!-- controller file:
class Unexpectedit_CustomReports_Block_Adminhtml_Sales_Bestseller extends Mage_Adminhtml_Block_Widget_Grid_Container
{
public function __construct()
{
$this->_controller = 'adminhtml_sales_bestseller';
$this->_blockGroup = 'customreports';
$this->_headerText = 'Bestsellers';
parent::__construct();
$this->_removeButton('add');
}
}
-->
<!-- ************************************************ -->
<!-- CONTROLLER / OVERRIDE / Frontend -->
<!-- ************************************************ -->
<!--
Source: http://www.magentocommerce.com/wiki/how_to_overload_a_controller
Files required:
1. Magento/app/code/local/Unexpectedit/MyCustomer/etc/config.xml
2. Magento/app/code/local/Unexpectedit/MyCustomer/controllers/AccountController.php
Note: It's really important called MyCustomer instead of Customer.
-->
<!-- 1.File: Unexpectedit/MyCustomer/etc/config.xml -->
<?xml version="1.0"?>
<config>
<modules>
<Unexpectedit_MyCustomer>
<version>1.00</version>
</Unexpectedit_MyCustomer>
</modules>
<frontend>
<routers>
<handpickedcollection_mycustomer>
<use>standard</use>
<args>
<module>Unexpectedit_MyCustomer</module>
<frontName>mycustomer</frontName>
</args>
</handpickedcollection_mycustomer>
</routers>
</frontend>
<global>
<rewrite>
<handpickedcollection_mycustomer_account>
<from>#^/customer/account/#</from>
<to>/mycustomer/account/</to>
</handpickedcollection_mycustomer_account>
</rewrite>
</global>
</config>
<!-- 2.File: Unexpectedit/MyCustomer/controllers/AccountController.php -->
<?php
require_once 'Mage/Customer/controllers/AccountController.php';
class Unexpectedit_MyCustomer_AccountController extends Mage_Customer_AccountController
{
// Overloaded loginAction
public function loginAction()
{
echo "great!";
parent::indexAction();
}
?>
<!-- ************************************************ -->
<!-- CONTROLLER / OVERRIDE / Admin -->
<!-- ************************************************ -->
<!-- USE: http://127.0.0.1/index.php/admin/permissions_user/index/ -->
<!-- structure:
Unexpectedit/Adminhtml
/controllers
/Override
/Admin
/Permissions
UserController.php
-->
<admin>
<routers>
<adminhtml>
<args>
<modules>
<Unexpectedit_Adminhtml_Override before="Mage_Adminhtml">Unexpectedit_Adminhtml_Override_Admin</Unexpectedit_Adminhtml_Override>
</modules>
</args>
</adminhtml>
</routers>
</admin>
<!-- controller file:
include("Mage/Adminhtml/controllers/Permissions/UserController.php");
class Unexpectedit_Adminhtml_Override_Admin_Permissions_UserController extends Mage_Adminhtml_Permissions_UserController
{
[...]
}
-->
- 14th, Jun 2010
How to declare / override Magento Blocks
<!-- ************************************************ -->
<!-- BLOCKS / DECLARE -->
<!-- ************************************************ -->
<!-- structure:
Unexpectedit/Home
/Block
/*
-->
<global>
<blocks>
<home>
<class>Unexpectedit_Home_Block</class>
</home>
</blocks>
</global>
<!-- ************************************************ -->
<!-- BLOCKS / OVERRIDE -->
<!-- ************************************************ -->
<!-- structure:
Unexpectedit/Catalog
/Block
/List
View.php
/List
Toolbar.php
-->
<global>
<blocks>
<catalog>
<rewrite><product_view>Unexpectedit_Catalog_Block_Product_View</product_view></rewrite>
<rewrite><product_list_toolbar>Unexpectedit_Catalog_Block_Product_List_Toolbar</product_list_toolbar></rewrite>
</catalog>
</blocks>
</global>
<!-- ************************************************ -->
<!-- BLOCKS / OVERRIDE / Admin -->
<!-- ************************************************ -->
<!-- structure:
Unexpectedit/Adminhtml
/Block
/Customer/Edit/Tab
Account.php
-->
<global>
<blocks>
<adminhtml>
<rewrite><customer_edit_tab_account>Unexpectedit_Adminhtml_Block_Customer_Edit_Tab_Account</customer_edit_tab_account></rewrite>
</adminhtml>
</blocks>
</global>
- 14th, Jun 2010
PHP Magento Debug
//Print all methods
echo '<ul>';
foreach (get_class_methods(get_class($this)) as $cThis)
echo '<li>' . $cThis . '</li>';
echo '</ul>';
//Force an error and get info
throw new Exception("".print_r($array_or_classes,true));
//Print info from objects
var_export(array_keys( $array ))
//Print attributes
print_r($customer->debug());
/**
* Debug SQL Queries - Log queries in a file
*
*/
// Modify this function: /lib/Varien/Db/Adapter/Pdo/Mysql.php
// Note: the debug file will be in /var/debug/sql.txt
// File: /lib/Varien/Db/Adapter/Pdo/Mysql.php
protected $_debug = true;
protected $_logAllQueries = true;
- 14th, Jun 2010
Magento Config Settings
/** * Moving Magento, Config Folder and Database * */ //Database config /app/etc/local.xml //Also rm -Rf magento/var/session; rm -Rf magento/var/cache; //Database stuff
UPDATE core_config_data SET value = "http://127.0.0.1:8888/New_Place/" WHERE path="web/unsecure/base_url"; UPDATE core_config_data SET value = "http://127.0.0.1:8888/New_Place/" WHERE path="web/secure/base_url"; TRUNCATE log_customer; TRUNCATE log_quote; TRUNCATE log_summary; TRUNCATE log_summary_type; TRUNCATE log_url; TRUNCATE log_url_info; TRUNCATE log_visitor; TRUNCATE log_visitor_info; TRUNCATE log_visitor_online;
# # Magento Database import SQL Files # #Export with mysql_dump or phpMyAdmin #Header SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT; SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS; SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION; SET NAMES utf8; SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO'; SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0; #...this on the Footer SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT; SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS; SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION; SET SQL_NOTES=@OLD_SQL_NOTES;
/**
* Magento Folder Settings and Permissions
*
*/
find . -type d -exec chmod 777 {} \;
find . -type f -exec chmod 644 {} \;
chmod 777 -R downloader
chmod 777 -R app/etc
//Also running Apache
find . -exec chown apache {} \;
find . -exec chgrp apache {} \;
Force the modules to upgrade the MySQL Version
To make sure that magento is using the scripts: Module_name/sql/mysql-upgrade*
1) Disable module
2) Delete cache
3) change the version number of the modules in
core_resource
doing
UPDATE `core_resource` SET `version` = ‘1.4′ WHERE `core_resource`.`code` = ‘Orderpreparation_setup’ LIMIT 1 ;
4) Enable module