Search

kmagen2

Category

Magento1

Upstream sent too big header while reading response header from upstream


folder_structure_rewrite_template_email
Folder Structure Rewrite template email order, invoice, shipment

Add new folder into theme folder is using

1.Order Email

<?= $block->escapeHtml($_item->getProduct()->getData('short_description')) ?>

2.Invoice Email + Shipment Email

<?php
 $objManager = \Magento\Framework\App\ObjectManager::getInstance();
 $itemId = $_item->getProductId();
 $productObject = $objManager->create('Magento\Catalog\Model\Product')->load($itemId);
 $short_description = $productObject->getShortDescription();
 ?>
 <?= $block->escapeHtml($short_description) 
?>

Upstream sent too big header while reading response header from upstream


Nginx 502 Bad Gateway error

[error] 5470#5470: *324 upstream sent too big header while reading response header from upstream, client: 10.254.251.177, server: abc.test.com, request: “POST /in_en/customcheckout/ HTTP/1.1”, upst ream: “fastcgi://127.0.0.1:9000”, host: “abc.com”, referrer: “https://abc.com/in_en/customcheckout/&#8221;

Configuration file /etc/nginx/nginx.conf :

http {
    ...
    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
    ...
}

client_max_body_size 100m;


Prefer:
https://github.com/magenx/Magento-nginx-config/blob/master/magento1/nginx.conf

“Front controller reached 100 router match iterations” error?


What is the cause of “Front controller reached 100 router match iterations” error?

Resolve : https://merchantprotocol.com/506/solved-front-controller-reached-100-router-match-iterations/

 

 

 

Source: http://magento.stackexchange.com/questions/69068/what-is-the-cause-of-front-controller-reached-100-router-match-iterations-erro

Migrate and merge db magento 1


Move Magento Database Sales, Customers & Invoices

November 1, 2013

http://platform.twitter.com/widgets/tweet_button.39f7ee9fffbd122b7a37a520dbdaebc6.en.html#dnt=false&id=twitter-widget-2&lang=en&original_referer=http%3A%2F%2Fblog.maximusbusiness.com%2F2013%2F11%2Fmove-magento-sales-customers%2F&size=m&text=Moving%20Magento%20Orders%2C%20Invoices%20and%20Customers%20Only%3A&time=1477987629819&type=share&url=http%3A%2F%2Fblog.maximusbusiness.com%2F2013%2F11%2Fmove-magento-sales-customers%2F%23.WBhNLH59K9k.twitter&via=OnlineMarket

Share on printfriendlyShare on email

To move a Magento website with its database is one thing, but what if you only want to update a Magento websites’ sales and recent customers? These steps may be required when your project is under the following conditions:

Orders, Sales, Magento-AdminIf the updates done to the development site are database related and not template related and the websites signup or purchase processes have not been turned off during a transfer process + development changes, then the option to simply re-transferring a database would be less preferred option.

The moving of only Magento sales and customers, as well as the sales + customer sync, can be done in 3 simple steps:

Note: This tutorial has been tested on Magento 1.7.0.2 installed on both websites. Database tables may vary based on different Magento versions.

Disabling Magento during Transfer

To avoid new signups and/or sales to the live website during the transfer process, consider disabling the checkout and signup from the configuration or create a blank file named maintenance.flag and place it on the root of your Magento install.

Move Magento with PHPmyAdmin Export/Import

A more convenient way of transferring the below database tables is by doing it in PHPmyAdmin, where you can simply export the tables to a SQL file by choosing them in the Export page of the production sites database and importing them into the target Magento installs database. You can also enable the statement Add DROP TABLE / VIEW / PROCEDURE / FUNCTION / EVENT statement in the Export options to avoid manually dropping those tables in the target database.

Transferring Customers & Sales

The first step is to transfer all the tables starting with customers_ and sales_, which are as follows on a Magento 1.7.0.2 install:

'customer_address_entity'
'customer_address_entity_datetime'
'customer_address_entity_decimal'
'customer_address_entity_int'
'customer_address_entity_text'
'customer_address_entity_varchar'
'customer_eav_attribute'
'customer_eav_attribute_website'
'customer_entity'
'customer_entity_datetime'
'customer_entity_decimal'
'customer_entity_int'
'customer_entity_text'
'customer_entity_varchar'
'customer_form_attribute'
'customer_group'

And the sales_ tables are:

'sales_bestsellers_aggregated_daily';
'sales_bestsellers_aggregated_monthly';
'sales_bestsellers_aggregated_yearly';
'sales_billing_agreement';
'sales_billing_agreement_order';
'sales_flat_creditmemo';
'sales_flat_creditmemo_comment';
'sales_flat_creditmemo_grid';
'sales_flat_creditmemo_item';
'sales_flat_invoice';
'sales_flat_invoice_comment';
'sales_flat_invoice_grid';
'sales_flat_invoice_item';
'sales_flat_order';
'sales_flat_order_address';
'sales_flat_order_grid';
'sales_flat_order_item';
'sales_flat_order_payment';
'sales_flat_order_status_history';
'sales_flat_quote';
'sales_flat_quote_address';
'sales_flat_quote_address_item';
'sales_flat_quote_item';
'sales_flat_quote_item_option';
'sales_flat_quote_payment';
'sales_flat_quote_shipping_rate';
'sales_flat_shipment';
'sales_flat_shipment_comment';
'sales_flat_shipment_grid';
'sales_flat_shipment_item';
'sales_flat_shipment_track';
'sales_invoiced_aggregated';
'sales_invoiced_aggregated_order';
'sales_order_aggregated_created';
'sales_order_aggregated_updated';
'sales_order_status';
'sales_order_status_label';
'sales_order_status_state';
'sales_order_tax';
'sales_order_tax_item';
'sales_payment_transaction';
'sales_recurring_profile';
'sales_recurring_profile_order';
'sales_refunded_aggregated';
'sales_refunded_aggregated_order';
'sales_shipping_aggregated';
'sales_shipping_aggregated_order';

Last Order ID for Sales

magento-eav-entity-storeNext, a step that is fairly easy, but that is often missed is the changing of the last entity ID for orders, invoices, credit memos and shipments. Otherwise, Magento will ignore the sales data that did not exist prior to the transfer.

For example: Imagine a Magento store has 7 orders (both development and production), the last orders’ id would probably be 100000007.During development, your production website acquires 2 additional orders (a total of 9 orders).

After moving your live sites’ sales_ tables, your development site will reflect the 9 orders correctly, but will still count from 7, instead of 9.

Hence, the next order will have an ID of 100000008 instead of 100000010, unless the last order ID is updated. The same applies for invoices, shipping and credit memos.

The fix is simple! Simply edit the table eav_entity_store and update the increment_last_idcolumn with the last id used for each row. Each rows’ entity type can be found in the table eav_entity_type. In this example (see above image), the entity types are:

  • 5 = order
  • 6 = invoice
  • 7 = creditmemo
  • 8 = shipment

That should be all that’s needed for a simple customer and sales update on two, otherwise identical Magento 1.7.0.2 sites. Hope his tutorial was useful and please feel free to comment and suggestions, questions or fixes.

Script can try:
#!/bin/bash

# VARIABLES
CONFIG_FILE="./app/etc/local.xml"
DUMP_FILE="./var/db-sales-users.sql"
TABLES="sales_bestsellers_aggregated_daily sales_bestsellers_aggregated_monthly sales_bestsellers_aggregated_yearly sales_billing_agreement sales_billing_agreement_order sales_flat_creditmemo sales_flat_creditmemo_comment sales_flat_creditmemo_grid sales_flat_creditmemo_item sales_flat_invoice sales_flat_invoice_comment sales_flat_invoice_grid sales_flat_invoice_item sales_flat_order sales_flat_order_address sales_flat_order_grid sales_flat_order_item sales_flat_order_payment sales_flat_order_status_history sales_flat_quote sales_flat_quote_address_item sales_flat_quote_item sales_flat_quote_item_option sales_flat_quote_payment sales_flat_quote_shipping_rate
sales_flat_shipment sales_flat_shipment_comment sales_flat_shipment_grid sales_flat_shipment_item sales_flat_shipment_track sales_invoiced_aggregated sales_invoiced_aggregated_order sales_order_aggregated_created sales_order_aggregated_updated sales_order_status sales_order_status_label sales_order_status_state sales_order_tax sales_order_tax_item sales_payment_transaction
sales_recurring_profile sales_recurring_profile_order sales_refunded_aggregated sales_refunded_aggregated_order sales_shipping_aggregated sales_shipping_aggregated_order customer_address_entity customer_address_entity_datetime customer_address_entity_decimal customer_address_entity_int customer_address_entity_text customer_address_entity_varchar customer_eav_attribute customer_eav_attribute_website
customer_entity customer_entity_datetime customer_entity_decimal customer_entity_int customer_entity_text customer_entity_varchar customer_form_attribute customer_group eav_entity_store"

# USAGE
function usage()
{
cat <<EOF
Usage:     $0 [OPTIONS]
Version:   1.1
Author:    Sean Grünböck / studio19.at
Changedate: 26.06.2015

Use this script to dump or import Users, Sales (Invoices,etc.) from LIVE DB to STAGING DB

OPTIONS:
      -d             Dump
      -i             Import

EOF
}

# FUNCTIONS
function message()
{
  STRIP=$(for i in {1..38}; do echo -n "#"; done)
  echo -e "$STRIP\n$1\n$STRIP"
}

function question()
{
  [[ ! "$OPT_F" == "" ]] && return 0
  echo -n "$1 [y/N]: "
  read CONFIRM
  [[ "$CONFIRM" == "y" ]] || [[ "$CONFIRM" == "Y" ]] && return 0
  return 1
}

# GET OPTIONS
while getopts ":di" OPTION; do
  case $OPTION in
    h)
      usage
      exit 0
      ;;
    *)
      [[ "$OPTARG" == "" ]] && OPTARG='"-'$OPTION' 1"'
      OPTION="OPT_$OPTION"
      eval ${OPTION}=$OPTARG
      ;;
  esac
done

[[ "$OPT_d$OPT_i" == "" ]] && usage && exit 1

# GET PARAMETERS FROM LOCAL.XML
function getParam()
{
  RETVAL=$(grep -Eoh "()?" $TMP_FILE | sed "s###g")
  if [[ "$2" == "sanitise" ]]; then
    RETVAL=$(echo "$RETVAL" | sed 's/"/\\\"/g')
  fi
  echo -e "$RETVAL"
}

which mktemp >/dev/null 2>&1
[ $? -eq 0 ] && TMP_FILE=$(mktemp ./var/local.xml.XXXXX) || TMP_FILE="./var/.tmp.local.xml"
sed -ne '/default_setup/,/\/default_setup/p' $CONFIG_FILE > $TMP_FILE

IGNORE_STRING=""
DBHOST=$(getParam "host")
DBUSER=$(getParam "username")
DBPASS=$(getParam "password" "sanitise" )
DBNAME=$(getParam "dbname")
TABLE_PREFIX=$(getParam "table_prefix")
[ -f $TMP_FILE ] && rm $TMP_FILE

if [[ ! "$OPT_d" == "" ]]; then
  mysqldump -h $DBHOST -u $DBUSER -p$DBPASS --routines --triggers --single-transaction $DBNAME $TABLES >> $DUMP_FILE
  message "dumped"
elif [[ ! "$OPT_i" == "" ]]; then
  [ ! -f "$DUMP_FILE" ] && error "SQL file does not exist"
  question "Are you sure you want to restore $DUMP_FILE to $DBNAME?"
  if [ $? -eq 0 ]; then
    mysql -h $DBHOST -u $DBUSER -p$DBPASS $DBNAME <$DUMP_FILE
    message "MYSQL IMPORT COMPLETE"
  fi
  exit 0
  
fi
Source : http://blog.maximusbusiness.com/2013/11/move-magento-sales-customers/

Sort order size for configurable product


Sizes : 31   26    30

array(3) {
  [0]=>
  object(stdClass)#779 (5) {
    ["id"]=>
    string(2) "36"
    ["label"]=>
    string(2) "31"
    ["price"]=>
    string(1) "0"
    ["oldPrice"]=>
    string(1) "0"
    ["products"]=>
    array(1) {
      [0]=>
      string(2) "19"
    }
  }
  [1]=>
  object(stdClass)#852 (5) {
    ["id"]=>
    string(2) "31"
    ["label"]=>
    string(2) "26"
    ["price"]=>
    string(1) "0"
    ["oldPrice"]=>
    string(1) "0"
    ["products"]=>
    array(1) {
      [0]=>
      string(2) "22"
    }
  }
  [2]=>
  object(stdClass)#899 (5) {
    ["id"]=>
    string(2) "35"
    ["label"]=>
    string(2) "30"
    ["price"]=>
    string(1) "0"
    ["oldPrice"]=>
    string(1) "0"
    ["products"]=>
    array(1) {
      [0]=>
      string(2) "18"
    }
  }
}

Resolved by :

template/configurableswatches/catalog/product/view/type/options/configurable/swatches.phtml

var_dump($_swatchArray->options);

if($_attrCode == 'size'){
    //arange $_swatchArray->options
    usort($_swatchArray->options, function($a, $b)
    {
        return strcmp($a->label, $b->label);
    });
    var_dump($_swatchArray->options);

}
array(3) {
  [0]=>
  object(stdClass)#852 (5) {
    ["id"]=>
    string(2) "31"
    ["label"]=>
    string(2) "26"
    ["price"]=>
    string(1) "0"
    ["oldPrice"]=>
    string(1) "0"
    ["products"]=>
    array(1) {
      [0]=>
      string(2) "22"
    }
  }
  [1]=>
  object(stdClass)#899 (5) {
    ["id"]=>
    string(2) "35"
    ["label"]=>
    string(2) "30"
    ["price"]=>
    string(1) "0"
    ["oldPrice"]=>
    string(1) "0"
    ["products"]=>
    array(1) {
      [0]=>
      string(2) "18"
    }
  }
  [2]=>
  object(stdClass)#779 (5) {
    ["id"]=>
    string(2) "36"
    ["label"]=>
    string(2) "31"
    ["price"]=>
    string(1) "0"
    ["oldPrice"]=>
    string(1) "0"
    ["products"]=>
    array(1) {
      [0]=>
      string(2) "19"
    }
  }
}

Add validate


Validation.addAllThese([
    ['validate-admin-password',
        'Password must contain:<br/>' +
        'Minimum length of (10) characters<br/> ' +
         'At least one numeric character (0-9)<br/>' +
        'At least one lower case character (a-z).<br/>' +
        'At least one upper case character (A-Z)<br/>' +
        'At least one non-alphanumeric character* (~, !, @, #, $, %, ^, &, *, ( ), -, =, +, ?, [ ], { })<br/>',

        function (v) {
            var pass = v.strip();
            if (0 == pass.length) {
                return true;
            }
            if ( !(/[a-z]/.test(v)) || !(/[0-9]/.test(v)) || !(/[A-Z]/.test(v)) || !(/[\_\W]/i.test(v)) ) {
                return false;
            }
            return !(pass.length < 10);
        }]
]);

!(/[\_\W]/i.test(v))

check for “_” and non-word character

Test in here .

immutable flag chattr – Cannot Restart php


Let check file and directory /tmp and these files related to progress of PHP, Apache, Magento …

immutable flag chattr 

Internal Server Error occurred while taking system backup in magento.


I tried taking a backup of Magento by Admin->System->Tools and when I clicked on System Backup, the website showed me –

systembackup.png

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

internal-server-error-while-system-backup.png

The problem comes about because Magento Backup sets permissions on files.

The offending piece of work is lib/Mage/Archive/Helper/File.php

In it you find a function

public function open($mode = \'w+\', $chmod = 0666)

This causes issues where permissions are changed globally.

If you must use Magento’s site crippling backup, then you should either run a script to set the file/folder permissions back.

ssh commands (can be run as a shell script)

For Magento where PHP is running through FastCGI, suPHP, or LSAPI:

find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
chmod 500 pear
chmod 500 mage #for magento 1.5+

For Magento where PHP is running as a DSO module under Apache:

find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
chmod o+w var var/.htaccess app/etc
chmod 550 pear
chmod 550 mage #for magento 1.5+
chmod -R o+w media

OR-

Open your filezilla connect using FTP with your magento root directory on the server.

Find the index.php file, right cilck and change the permissions from 666 to 644.

Now hit refresh from your browser.

Follow the same procedure for the all the files creating the same type problem(if any).

Thank You
Enjoy Magento

Source : http://network.convergenceservices.in/forum/122-troubleshooting/3902-internal-server-error-occurred-while-taking-system-backup-in-magento.html

Subquery in collection


This is what I used, it worked for me.

First make the query for your max :

$collection = Mage::getModel('key/model')->getCollection();         
$collection->getSelect()
           ->reset(Zend_Db_Select::COLUMNS)
           ->columns(array('id' => 'MAX(`main_table`.id)'))
           ->group('customer_id');
$select = $collection->getSelect();

Then create the main query and update the “from” part :

$coll = Mage::getModel('key/model')->getCollection();
$coll->getSelect()
     ->reset(Zend_Db_Select::COLUMNS)
     ->reset(Zend_Db_Select::FROM)
     ->from($select, 'id') // Using from with Zend_Db_Select as name auto uses "t" as table alias
     ->join(
          array('main_table' => $collection->getTable('key/model')),
          '`t`.id = `main_table`.id', 
          array('*')
     );

This generates a query like this :

SELECT `t`.`id`, `alias`.* FROM (SELECT MAX(`main_table`.id) AS `id` FROM `tablename` AS `main_table` GROUP BY `customer_id`) AS `t` INNER JOIN `tablename` AS `main_table` ON `t`.id = `main_table`.id

Example :

SELECT
`t`.`customer_email`,
`a`.`customer_email`,
`a`.`updated_at`,
`a`.`customer_firstname`,
`a`.`customer_lastname`,
`a`.`entity_id`
FROM
(SELECT DISTINCT
`main_table`.`customer_email`,
MAX(updated_at) AS `last_updated`
FROM
`sales_flat_order` AS `main_table`
WHERE (
`status` IN ('complete', 'complete_paid')
)
AND (`treat_gift` = '0')
AND (`store_id` = '53')
GROUP BY `customer_email`
ORDER BY `last_updated` DESC) AS `t`
INNER JOIN `sales_flat_order` AS `a`
ON `t`.customer_email = `a`.customer_email
AND `t`.last_updated = `a`.updated_at
LIMIT 3

 

                $donors = array();
		$limit = Mage::getStoreConfig('checkoutiog/recentdonors/limit');
		$allClass = Mage::helper('bluecomiog_recentdonors')->getAllClass();

		$arrStatus = ['complete', 'complete_paid'];



		$collection1 = Mage::getResourceModel('sales/order_collection');
		$collection1 ->addFieldToSelect('customer_email')
			->addFieldToFilter('status',array('in'  => $arrStatus))
			->addFieldToFilter('treat_gift','0')
			->addFieldToFilter('store_id', $storeId)
			->distinct(true);
		$collection1->getSelect()
			->columns('MAX(updated_at) as last_updated')->group('customer_email')->order('last_updated DESC');

		$select = $collection1->getSelect();

		$collection = Mage::getResourceModel('sales/order_collection');
		$collection->addFieldToSelect('entity_id');
		$collection->getSelect()
			->reset(Zend_Db_Select::COLUMNS)
			->reset(Zend_Db_Select::FROM)
			->from($select, 'customer_email') // Using from with Zend_Db_Select as name auto uses "t" as table alias
			->join(
				array('a' => $collection->getTable('sales/order')),
				'`t`.customer_email = `a`.customer_email AND `t`.last_updated = `a`.updated_at ',
				array('customer_email','updated_at','customer_firstname','customer_lastname','entity_id')
			)
			->limit($limit)
		;

		$i = 0;
		foreach($collection as $item){

			$classId =  $item->getBillingAddress()->getData('class_name');

			if($allClass != false && isset($allClass[$classId])){
				$donors[$i]['class'] = $allClass[$classId];
			}
			$donors[$i]['name'] = $item->getCustomerName();
			$i++;
		}

Create a free website or blog at WordPress.com.

Up ↑