Skip to content

Instantly share code, notes, and snippets.

View willboudle's full-sized avatar

Will Boudle willboudle

View GitHub Profile
@willboudle
willboudle / Update Customer Group Price
Created January 13, 2014 01:22
Update Customer Group Price
<?php
// USAGE http://www.site.com/dev/updategroupprice.php?price=14.95&sku=ABC152X
require_once '../app/Mage.php';
umask(0);
//Mage::app('admin');
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$sku = $_GET['sku'];
@willboudle
willboudle / CSS TO HEADER
Created February 11, 2014 19:10
Add CSS to Header.
1. How to add a Magento CSS file to frontend
1.1. Create (Copy) a CSS file (or a CSS folder) in folder skin/frontend/default/default/css/ or skin/frontend/base/default/css/
Example: skin/frontend/default/default/css/magestore/mycss.css
Or: skin/frontend/default/default/css/mycustom.css
Or: skin/frontend/base/default/css/mycustom.css.
1.2. Add a CSS file from layout file
In the following examples, system firstly finds the declared magento CSS file in folder skin/frontend/default/default/css. If it can’t find in this folder, system automatically finds in folder skin/frontend/base/default/css. If the system fails to find in both above folders, it will report error or skip.
For comprehensive system (always add when layout files have not been loaded)
@willboudle
willboudle / iterator
Created September 8, 2014 13:28
Iterating over a complex Associative Array in PHP
//use:
iterator($n);
function iterator($arr){
foreach($arr as $key => $val){
if(is_array($val))iterator($val);
echo '<p>key: '.$key.' | value: '.$val.'</p>';
@willboudle
willboudle / magento walk method example
Last active August 12, 2019 15:42
Magento walk() method example - for large collection
public function uppercaseAction()
{
// get customer collection
$customers = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect(array('firstname'), 'inner');
// call iterator walk method with collection query string and callback method as parameters
Mage::getSingleton('core/resource_iterator')->walk($customers->getSelect(), array(array($this, 'customerCallback')));
}
// callback method
public function customerCallback($args)
@willboudle
willboudle / mage-add-products-api.php
Last active February 3, 2017 22:30
Add Product's Images using Magento API
<?php
// API Configuration
$this->APIUrl= "http://yourdomain.com/index.php/api/soap/?wsdl";
$this->APIUser="APIUser";
$this->APIKey= "APIKey";
function addAPIImages($product_id){
$sql ="SELECT * FROM YourDatabaseTable WHERE ProductID = $product_id";
$resultat=mysql_query($sql) or die('SQL error:'.mysql_error());
while ($row = mysql_fetch_array($resultat)) {
@willboudle
willboudle / gist:da081bfd0fc1ccf6dbef
Created October 16, 2014 19:05
Cron job to update database in magento
<?php
require_once 'app/Mage.php';
umask(0);
ini_set("memory_limit","1024M");
//$_SERVER['SERVER_PORT']='443';
Mage::app();
$profileId = 7; //put your profile id here
$logFileName= "import.log";
$recordCount = 0;
@willboudle
willboudle / mage-product-api.php
Last active February 3, 2017 22:29
Retrieve Product's info using API:
<?php
// Check product's status.
function getProductInfo($product_id){
$this->APIUrl= "http://yourdomain.com/index.php/api/soap/?wsdl";
$this->APIUser="APIUser";
$this->APIKey= "APIKey";
$proxy = new SoapClient($this->APIUrl);
$sessionId = $proxy->login($this->APIUser, $this->APIKey);
$exists = true;
@willboudle
willboudle / 0_reuse_code.js
Last active August 29, 2015 14:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@willboudle
willboudle / gist:16f0e84d6f877f5b107b
Created January 21, 2015 18:55
Get Amazon Order Id from M2E Pro
$order = Mage::getModel('sales/order')->load(entity_id);
$paymentInfo = Mage::helper('payment')->getInfoBlock($order->getPayment())
->setIsSecureMode(true);
$channelOrderId = $paymentInfo->getChannelOrderId();
Issue :
How to point a parked domain to a sub-directory of the main domain without any change in the URL ?
Fix :
This is like making the parked domain function like an add-on domain.
Assuming that the parked domain name is abc.com and the corresponding folder under the main domain is ‘abc’ .This can be achieved by putting the following in the .htaccess file for the main domain :
RewriteEngine On