161 cards
View
Linked content

Websites, Stores, Store Views

Here is what can be set at each level:

  Default Web Site Store Store View
Product attributes X     X
Product prices X X    
Product tax class X X    
Base currency X X    
(Default) display currency X     X
Category settings X     X
System configuration settings X X   X
Root category configuration     X  
Orders       X
Customer sharing X X    

Thanks to F…

View Status of EE Mview Changelog Tables

This SQL:

```
select emm.view_name,
emm.status,
emm.version_id as metadata_version,
cl_max_versions.max_version as cl_version,
(cl_max_versions.max_version - emm.version_id) as behind
from enterprise_mview_metadata emm
left join (
select 'enterprise_url_rewrite_redirect' as view_name, max(version_id) as max_version from enterprise_url_rewrite_redirect_cl union
select 'cataloginventory_stock_status_view' as view_name, max(version_id) as max_version from cataloginventory_stock_status_cl union
select 'enterprise_url…

Linked content

Security problem: {block} has not been whitelisted

This is introduced by either SUPEE-6788, or Magento 1.9.2.2. See the link.

XMLRPC API

The XMLRPC API parameters always confuse me, they're below:

Login:

<?xml version="1.0"?>
<methodCall>
  <methodName>login</methodName>
  <params>
    <param>
        <value><string>zapier</string></value>
    </param>
    <param>
        <value><string>monkey</string></value>
    </param>
  </params>
</methodCall>

Order list:

<?xml version="1.0"?>
<methodCall>
  <methodName>call</methodName>
  <params>
    <param>
        <value>
            <string>884e467da9850...

Creating a Datetime attribute that stores time

Magento has a Datetime backend model but formats a Zend_Date object without the time. So if you want to store datetime (actually with time) you will need to setup your own backend model.

Here is how i've done it:

```
class Namespace_Module_Model_Entity_Attribute_Backend_Datetime extends Mage_Eav_Model_Entity_Attribute_Backend_Datetime
{
const DATETIME_DATEPICKER_FORMAT = 'd/m/Y H:i';

/**
 * Prepare date for save in DB
 *
 * @param   string | int $date
 * @return  string
 */
public function formatDate($dat...

Admin Grids - Filtering A Joined Column

Often, you'll want to add a column to a collection used in a grid, and to do so you'd use _prepareCollection():

protected function _prepareCollection()
{
    $collection = Mage::getResourceModel($this->_getCollectionClass());
    $this->setCollection($collection);

    $collection->getSelect()
       ->joinLeft(
           array('table_alias' => 'some_long_table_name'),
           'main_table.something = table_alias.something',
           array('some_column' => 'table_alias.some_column')
       );

Adding A Column to a Flat Table

Handy to add attributes to sales_flat_order:

$installer->getConnection()->addColumn(
    $this->getTable('sales/order'),
    'some_attribute',
    [
        'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
        'length' => 1,
        'comment'=> 'Comment'
    ]
);

UK Tax / VAT Setup Script

This script sets up everything for UK VAT from a default 1.9.1.0 install.

<?php
/* @var $installer Mage_Core_Model_Resource_Setup */
$installer = $this;
$installer->startSetup();

/**
 * Define VAT band names
 */
define('VAT_STANDARD', 'VAT Standard');
define('VAT_REDUCED', 'VAT Reduced');
define('VAT_ZERO', 'VAT Zero');

/**
 * Remove current rules, rates and product classes
 */
$taxCalculation = Mage::getModel('tax/calculation');
foreach (Mage::getModel('tax/calculation_rule')->g...

Generate Test Products

I took this script from somewhere (sorry I forgot where!) but it didn't work for 1.9.1.0, so I fixed it up. Really basic, but useful, I used it to test pagination:

<?php
require 'app/Mage.php';
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
for ($i = 0; $i < 100; $i++) {
    Mage::getModel('catalog/product')
        ->setWebsiteIds(array(1))
        ->setAttributeSetId(4)
        ->setTypeId('simple')
        ->setSku($i)
        ->setStatus(1)
        ->setTaxClassId(2)
  ...

Get Value of Product Attribute

This resolves the value of the attribute, so rather than supplying you with a value ID, it will supply you with the associated value, via the source model:

$_product->getAttributeText('brand');

Non-Required Category Attribute Not Set in Global Scope

When a category is created whilst in a store scope, and a value is set against an attribute which has is_required set to false, and has a scope more specific than global, then a value is not set against the global scope, resulting in the store scope having a value, but the global scope having no value. This also has the effect of causing the flat category table for the store in question to have a null value for the attribute, even in the store scope that it is set in.

On this install, the attribute in question is display_as_link:

!…

Draft

Magento Extension Companies

A work-in-progress, this is a list of companies and thoughts about each.

Company Type Comments
AheadWorks General  
Mageworx General  
Amasty General  
Aitoc General  
Magestore General  
Xtento General  
WebShopApps Shipping  
Wyomind General  
Fooman General

Get Methods of Class

Yes, very dirty, but it works a treat! Save this file in your Magento root directory, then fire up a command line and run whatever.php Mage_Core_Model_App (or some other class) and you should see the output.

Output looks like below:

$ ./classmethods.php Varien_Db_Adapter_Pdo_Mysql
__construct                      Zend_Db_Adapter_Abstract      lib/Zend/Db/Adapter/Abstract.php:43
__destruct                       Varien_Db_Adapter_Pdo_Mysql   lib/Varien/Db/Adapter/Pdo/Mysql.php:30
__sleep                          Zend_Db_Ada...

Getting the Theme In Use

How to get the theme for each component, works on the active store:

Mage::getSingleton('core/design_package')->getTheme('locale');
Mage::getSingleton('core/design_package')->getTheme('template');
Mage::getSingleton('core/design_package')->getTheme('skin');
Mage::getSingleton('core/design_package')->getTheme('layout');
Mage::getSingleton('core/design_package')->getTheme('default');

Layout Loading and Misc Notes

Layout XML files are loaded here via this stack - here we are loading the layout update for the rwd/default design package, for the CMS home page. I've put a dashed line on the demarcation between layout code and other code:

Mage_Core_Model_App->run(Array)
Mage_Core_Controller_Varien_Front->dispatch()
Mage_Core_Controller_Varien_Router_Standard->match(Mage_Core_Controller_Request_Http)
Mage_Core_Controller_Varien_Action->dispatch('index')
Mage_Cms_IndexController->indexAction()
Mage_Cms_Helper_Page->renderPage(Mage_C...

Magento PHP & HTTPD Timeouts

nginx

fastcgi_read_timeout

php-fpm

request_terminate_timeout

php:

max_execution_time

varnish:

.first_byte_timeout
.between_bytes_timeout

Resetting File & Folder Permissions

You might want to do this on media or elsewhere, handy cut-and-paste job:

find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;

Or with an xargs version (which should be faster):

find media -type d -print0 | xargs -0 chmod 0755
find media -type f -print0 | xargs -0 chmod 0644
This website uses cookies to improve usability and analyze traffic.
Accept or learn more