Strategic Growth and Marketing Blog
Adding a File Upload Field to the Magento System.xml Configuration
[xml] <upload_file translate=”label tooltip comment”> <label>Upload File</label> <comment>Add comments here</comment> <tooltip>Add a tooltip that appears on hover</tooltip> <frontend_type>file</frontend_type> <backend_model>adminhtml/system_config_backend_file</backend_model> <upload_dir config=”system/filesystem/media” scope_info=”1″>admin-config-uploads</upload_dir> <base_url type=”media” scope_info=”1″>admin-config-uploads</base_url> <sort_order>1</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> <show_in_store>1</show_in_store> </upload_file>…
Magento – Programmatically Get Order Details by Increment ID
[php] <?php $order = Mage::getModel(‘sales/order’)->loadByIncrementId($incrementId); ?> [/php]
Magento – Force HTTPS for Product’s Add to Cart URL
[php] <?php echo $this->getAddToCartUrl($_product, array(“_secure” => true)); ?> [/php]
Run Sentry’s Migration When Running Laravel’s Migration
[php] <?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; class CreateSentryTables extends Migration { /** * Run the migrations. * * @return void */ public function up() { Artisan::call(‘migrate’, [‘–package’ => ‘cartalyst/sentry’]); }…
Magento’s Core HTTP Helper Class – Get Remote IP Address
Have you ever wanted to get the remote IP address of your Magento website’s visitors, the referring website’s address or even validate an IP address? Magento’s Core HTTP helper class…
Magento’s Scriptaculous Folder Went Missing After An Upgrade
All the following Scriptaculous JavaScript files from Magento’s JS library disappeared after I performed an upgrade of a Magento eCommerce website. I figured that the updater must done something naughty by deleting the…
Magento – Check, Find and Get the Product Type (Simple, Configurable, Grouped, etc.)
The standard product types in Magento are Simple, Configurable, Grouped, Virtual, Bundle, and Downloadable. Have you ever wanted to change the look and feel of a product based on the…
Magento – Flash / Session Notification Messages
Magento offers an inbuilt flash message class and functions to display success, error, warning and notice messages. You would have seen a message similar to the one below, when submitting…
Laravel – Validate Multiple Models and Combine All Error Messages
[php] <?php $validateUser = Validator::make(Input::all(), User::$rules); $validateRole = Validator::make(Input::all(), Role::$rules); if ($validateUser->fails() OR $validateRole->fails()) : $validationMessages = array_merge_recursive($validateUser->messages()->toArray(), $validateRole->messages()->toArray()); return Redirect::back()->withErrors($validationMessages)->withInput(); endif; ?> [/php]
Magento – Run an Event or Function After System Configuration Save
Open the config.xml of your module and add an event within the global declaration. <global> <events> <admin_system_config_changed_section_nameofyoursection> <observers> <yourmodule> <type>singleton</type> <class>yourmodule/observer</class> <method>adminSystemConfigChangedSectionNameofyoursection</method> </yourmodule> </observers> </admin_system_config_changed_section_nameofyoursection> </events> </global> Now create a…
Magento – Check if Product Exists by Getting Product ID from SKU
[php] $productSku = ‘SKU-Of-The-Product’; // Get Magento product ID by providing the SKU $productId = Mage::getModel(‘catalog/product’)->getIdBySku($productSku); // Check if a product ID was returned if ($productId) { // Product with…
Magento – Get Current Store Details (ID, Code, Name and Status)
[php] // Gets the current store’s details $store = Mage::app()->getStore(); // Gets the current store’s id $storeId = Mage::app()->getStore()->getStoreId(); // Gets the current store’s code $storeCode = Mage::app()->getStore()->getCode(); // Gets…