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 / Add Products to category by sku
Created January 13, 2014 01:16
Add Products to category by sku programmatically
<?php
// USAGE http://www.site.com/updategroupprice.php?price=14.95&sku=SKU123X
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 / New CMS Page
Last active January 3, 2016 01:59
Create CMS Page programmatically - Magento
<?php
// Create a new cms page for a .
$cmsPageData = array(
'title' => 'Test CMS Page Title',
'root_template' => 'one_column',
'meta_keywords' => 'meta,keywords',
'meta_description' => 'meta description',
@willboudle
willboudle / Update Default Attributes
Last active January 2, 2016 14:59
Uodate Magento Default attribute values
UPDATE `eav_attribute` SET `default_value` = 'container1' WHERE `eav_attribute`.`attribute_code`='options_container';
UPDATE `eav_attribute` SET `default_value` = '1' WHERE `eav_attribute`.`attribute_code`='is_active';
UPDATE `eav_attribute` SET `default_value` = '1' WHERE `eav_attribute`.`attribute_code`='is_anchor';
UPDATE `eav_attribute` SET `default_value` = '1' WHERE `eav_attribute`.`attribute_code`='status';
UPDATE `eav_attribute` SET `default_value` = '0' WHERE `eav_attribute`.`attribute_code`='weight';
UPDATE `eav_attribute` SET `default_value` = '2' WHERE `eav_attribute`.`attribute_code`='tax_class_id';
insert into core_config_data values ( null, 'default', 0, 'cataloginventory/item_options/is_in_stock', 1 );
insert into core_config_data values ( null, 'default', 0, 'cataloginventory/item_options/qty', 10 );
@willboudle
willboudle / Create Category Programmatically
Last active January 2, 2016 13:19
Create Category Programmatically
Create category dynamically:
$category = Mage::getModel('catalog/category');
$category->setStoreId(Mage::app()->getStore()->getId());
$cat['name'] = "Custom Category Name here";
$cat['path'] = "1/2/30"; //parent relationship..
$cat['description'] = "categorie's description";
$cat['is_active'] = 1;
$cat['is_anchor'] = 0; //for layered navigation
@willboudle
willboudle / Get category from product
Last active January 2, 2016 13:09
Magento get category from product
//$_product = Mage::getModel('catalog/product')->load($productID);
-----------------------------------
$catCollection = $_product->getCategoryCollection();
foreach($catCollection as $cat){
print_r($cat->getData());
//echo $cat->getName();
//echo $cat->getUrl();
}
@willboudle
willboudle / Update Magento Attribute Code
Last active January 2, 2016 12:49
Update Magento Attribute Code (or other value)
$installer = $this;
$installer->startSetup();
$installer->updateAttribute('catalog_product', 'old_attribute_code', array('attribute_code' => 'new_attribute_code'));
$installer->endSetup();
@willboudle
willboudle / Magento separate css per category
Last active December 23, 2015 20:28
Magento separate css per category
<reference name="head">
<action method="addCss">
<stylesheet>relativetobase/default/your.css</stylesheet>
<params>media="screen"</params>
</action>
</reference>
@willboudle
willboudle / Mage::cleanup.php
Last active February 3, 2017 22:34 — forked from mschultheiss83/Mage::cleanup.php
Magento what needs to be cleaned in database
<?php
/***************************************************
* Magento Log File Contents Monitor. GNU/GPL
* landau@fiascolabs.com
* provided without warranty or support
***************************************************/
/***********************
* Scan Magento local.xml file for connection information
// ## Note: If not in a module sql setup use the following 2 lines
require_once('app/Mage.php');
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
// ## Note: Setup the new category attribute
$installer = new Mage_Sales_Model_Mysql4_Setup;
$installer->startSetup();
$installer->addAttribute('catalog_category', 'additional_css', array(
'type' => 'text',
'backend' => '',
'frontend' => '',