Skip to main content

Posts

Showing posts from November, 2014

[magento] Direct sql

<?php //Table names and table prefixes $tableName = Mage :: getSingleton( ' core/resource ' ) getTableName( ' catalog_product_entity ' ); // if prefix was 'mage_' then the below statement // would print out mage_catalog_product_entity echo $tableName ; //Accessing the database connection resource $read = Mage :: getSingleton( ' core/resource ' ) -> getConnection( ' core_read ' ); $write = Mage :: getSingleton( ' core/resource ' ) -> getConnection( ' core_write ' ); //For a list of functions available, copy the following code into a Magento template. $read = Mage :: getSingleton( ' core/resource ' ) -> getConnection( ' core_read ' ); echo ' <pre> ' ; print_r ( get_class_methods ( $read )); echo ' </pre> ' ; exit ; //Reading data from the database $read = Mage :: getSingleton( ' core/resource...

[prestashop] update domain when migrating

// Local UPDATE ps_shop_url SET domain = 'localhost'; UPDATE ps_shop_url SET domain_ssl = 'localhost'; UPDATE ps_configuration SET value = 'localhost' WHERE `id_configuration`='232'; UPDATE ps_configuration SET value = 'localhost' WHERE `id_configuration`='233'; // Dev UPDATE ps_shop_url SET domain = 'dev.localhost; UPDATE ps_shop_url SET domain_ssl = 'dev. localhost ’; UPDATE ps_configuration SET value = 'http://dev. localhost ' WHERE `id_configuration`='232'; UPDATE ps_configuration SET value = 'https://dev. localhost ' WHERE `id_configuration`='233'; // Live UPDATE ps_shop_url SET domain = 'domain.com’; UPDATE ps_shop_url SET domain_ssl = ' domain .com’; UPDATE ps_configuration SET value = 'http:// domain .com' WHERE `id_configuration`='232'; UPDATE ps_configuration SET value = 'https:// domain .com' WHERE `id_configuration`='233...

[magento] Product Collection Bible

Magento Product Collection Bible Adam   Moss   Last Updated 14th Mar '14 Published 3rd Feb '14 Any developer who uses Magento will have at some point found themselves deep in model collections, and none more so than the product resource collection. In this post I cover all the angles with regards to loading your product collections, filtering, sorting and modifying them. This is the Magento Product Collection Bible. Amen to that. Load Product Collection There are two basic ways of loading your product collection. Either call method getCollection() on your product model instance or load collection class in the factory method ‘getResourceModel’. 1 $collection = Mage::getModel( 'catalog/product' )->getCollection(); 1 $collection = Mage::getResourceModel( 'catalog/product_collection' ); Add Attributes To Collection The product model is an enormous data set, and the more attributes we include in the lo...