The product image resizing goes through a few layers of abstraction, so I thought I’d add a quick UML diagram showing composition through the layers. The resizing ultimately gets done by the gd PHP extension.
Ever wondered what they do? Basically they disable and then enable foreign key checks, and set the SQL mode to NO_AUTO_VALUE_ON_ZERO, then back to the old SQL mode. Below is the code taken fromVarien_Db_Adapter_Pdo_Mysql:
/**
* Run additional environment before setup
*
* @return Varien_Db_Adapter_Pdo_Mysql
*/
public function startSetup()
{
$this->raw_query("SET SQL_MODE=''");
$this->raw_query("SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0");
$this->raw_query("SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO'");
return $this;
}
/**
* Run additional environment after setup
*
* @return Varien_Db_Adapter_Pdo_Mysql
*/
public function endSetup()
{
$this->raw_query("SET SQL_MODE=IFNULL(@OLD_SQL_MODE,'')");
$this->raw_query("SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS=0, 0, 1)");
return $this;
}
Attribute Source Model
Used when you want to use a multiselect or select dropdown box on an EAV entity, such as products or categories.
This doesn’t really go here, but hey ho. Magento’s functions injs/Mage/cookies.js are not very good.
/**
* Get a cookie value
*
* @param String name The cookie name
*
* @return String The cookie value
*/
getCookie: function(name)
{
var val = '';
var cookies = document.cookie.split('; ');
for (i = 0; i < cookies.length; i++) {
nameVal = cookies[i].split('=');
if (nameVal[0] == name) {
val = unescape(nameVal[1]);
}
}
return val;
}
/**
* Set a cookie, or unset it by passing -1 as the expires param
*
* It is very important to pass *exactly* what was used to set the cookie in
* the first place - this means same name, path, domain and secure. If the
* cookie is host-only (had no domain passed in when set) then pass null as
* the domain parameter, however if a domain was used when the cookie was
* set then it will need a peiod prefix (.www.whatever.com) as the domain
*
* @param String name The cookie name
* @param String value What to set to, use '' to unset
* @param Int expires Expiry in seconds, -1 to unset
* @param String path The path, when unsetting must be exactly as when set
* @param String domain The domain, when unsetting must be exactly as when set
* @param Bool secure Secure or not, when unsetting must be exactly as when set
*
* @return void
*/
setCookie: function(name, value, expires, path, domain, secure)
{
var cookieStr = name + "=" + escape(value) + "; ";
if (expires) {
var expiresDate = new Date(new Date().getTime() + expires * 24 * 60 * 60 * 1000);
cookieStr += "expires=" + expiresDate.toGMTString() + "; ";
}
if (path) {
cookieStr += "path=" + path + "; ";
}
if (domain) {
cookieStr += "domain=" + domain + "; ";
}
if (secure) {
cookieStr += "secure; ";
}
document.cookie = cookieStr;
}
<?php
/**
* Yourcompany.com
*
* PHP Version 5
*
* @category Namespace
* @package Namespace_Module
* @author Your Name <your.name@yourcompany.com>
* @copyright 2012 yourcompany.com
* @license http://www.yourcompany.com/license.txt Your license
* @link N/A
*/
/**
* A description of the controller
*
* @category Namespace
* @package Namespace_Module
* @author Your Name <your.name@yourcompany.com>
* @license http://www.yourcompany.com/license.txt Your license
* @link N/A
*/
class Namespace_Module_SomeController extends Mage_Core_Controller_Front_Action
{
/**
* Index action
*
* @return void
*/
public function indexAction()
{
$this->loadLayout();
$this->renderLayout();
}
}
Paypal Express Flow
The PayPal Express Checkout Integration Guide is a great source of well-written information for anything relating to the Express checkout, including information regarding all of the API calls. Also, the PayPal Express Checkout flow diagram illustrates the process well:
The same information as contained in the diagram above is also in the table below:
Provides much of the base functionality for the two controllers
Mage_Paypal_ExpressController
Standard (US?) express controller
Mage_PaypalUk_ExpressController
UK express controller
Mage_Paypal_Model_Express
Express payment method
Mage_Paypal_Model_Express_Checkout
?
Mage_Paypal_Model_Api_Nvp
PayPal Name-Value Pair API Wrapper
Allowing Import Of Invisible Attributes
By setting a Product Attributeto be invisible via thevisible property, you stop the ability to import that attribute unless you alter the_forcedAttributesCodesproperty of the relevant product type. The class names are:
The best method is probably to subclass the relevant product import class, then overwrite the property. It would be far better to use the constructor to append to the property rather than just overwrite it to make future upgrades as smooth as possible, but Magento, in all their wisdom, have marked the constructor as final so you cannot do this, and we have no events to take advantage of.
These are the core set of route parameters, you can be fairly sure that any call togetUrl() which accepts route parameters will come through this method, so any of these parameters should work.
Param
Type
Does
_store
string, int
Use a stores config, numeric or string code
_type
string
Using the relevant types URL, either link, direct_link, js. media or skin
_secure
bool
Use the secure URL if allowed
_forced_secure
bool
Force using the secure URL
_use_rewrite
bool
Resolves the link to a rewritten SEO URL
_nosid
bool
Prevents the SID query param from being added
_absolute
bool
No effect as URLs are always generated as absolute.
_current
bool
Uses the current module, controller, action and parameters
_direct
string
Appended to the base URL, apparently (really?)
_fragment
string
Sets the fragment (#whatever) component
_escape
bool
Uses & instead of & for querystring parameters
_query
string, array
Sets the query parameters
_store_to_url
bool
Adds ___store to the query parameters
Mage_Catalog_Model_Product_Url::getUrl()
These are extra parameters only noticed by the product URL method.
No comments:
Post a Comment