Skip to content

Instantly share code, notes, and snippets.

@vishy93
vishy93 / update_prices.php
Last active February 26, 2019 15:05
Script to update product prices from CSV
<?php
$mageFilename = '../app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('admin');
Mage::register('isSecureArea', 1);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
@vishy93
vishy93 / prodsnotinanycategory.sql
Created February 26, 2019 14:43
SQL statement to get a list of enabled products that are not in any categories
SELECT cpe.entity_id,
cpe.sku
FROM catalog_product_entity AS cpe
LEFT JOIN catalog_category_product AS ccp
ON cpe.entity_id = ccp.product_id
LEFT JOIN catalog_product_entity_int AS cpi
ON cpe.entity_id = cpi.entity_id
WHERE category_id IS NULL
AND attribute_id = (SELECT attribute_id
FROM `eav_attribute`
@vishy93
vishy93 / tierpricing.php
Created February 26, 2019 14:38
Script to add tiered pricing from an csv file
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
$proxy = new SoapClient('http://www.MYSITESURL.co.uk/index.php/api/soap/?wsdl');
$sessionId = $proxy->login('SOAPUSER', 'SOAPPASS');
$row = 1;
$errors = 0;
$handle = fopen('tier.csv', 'r');
@vishy93
vishy93 / state.php
Created February 26, 2019 14:34
Change state of an order
<?php
//get the remote host IP
$szRemoteIP = $_SERVER['REMOTE_ADDR'];
//this is the array holding the allowed IP's list;
$arrAllowedIPs = array("xxxxx","xxxxxx");
if (!in_array($szRemoteIP, $arrAllowedIPs))
{
//if IP's is not in the list, deny access
@vishy93
vishy93 / prodsareincat.php
Created February 26, 2019 14:30
See by product id if product in category, if so which ones. Else not in any.
<?php
require '../app/Mage.php';
umask(0);
Mage::app('admin');
error_reporting(1);
set_time_limit(0);
ini_set('memory_limit', '2048M');
@vishy93
vishy93 / completeorderstate.php
Last active February 26, 2019 14:31
Script to mark processing state orders between certain date as completed
<?php
$mageFilename = '../app/Mage.php';
require_once $mageFilename;
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('admin');
Mage::register('isSecureArea', 1);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
@vishy93
vishy93 / clonecategory.php
Last active February 26, 2019 14:33
Script to duplicate a target category along with it's sub-categories and products under another category.
<?php //can be run as root script
require '../app/Mage.php';
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
$categoryId = 864; //Target Cat to copy
$baseCategoryId = 240; //Category to appear under
$category = Mage::getModel('catalog/category')->load($categoryId);
@vishy93
vishy93 / noImage.php
Created February 6, 2019 13:40
Quick script to see which products has no images/ placeholders
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once('../app/Mage.php');
Mage::app();
error_reporting(1);
set_time_limit(0);
ini_set('memory_limit', '2048M');
@vishy93
vishy93 / all_attribute_options
Created January 31, 2019 15:52 — forked from pierreandreroy/all_attribute_options
Get all possible value (dropdown options) of a product attribute in Magento.
<?php
//Possible color value
$attribute = Mage::getModel('eav/config')->getAttribute('catalog_product', 'color'); //"color" is the attribute_code
$allOptions = $attribute->getSource()->getAllOptions(true, true);
foreach ($allOptions as $instance) {
$id = $instance['value']; //id of the option
$value = $instance['label']; //Label of the option
}
?>
@vishy93
vishy93 / My_Module.xml
Created January 25, 2019 15:31 — forked from AndresInSpace/My_Module.xml
Magento Product Attribute Setup Installer - Add New Product Attribute & Add to All Attribute Sets to Specified Group - Full List of available params used for catalog_product addAttribute installation
filepath: app/etc/modules/
<?xml version="1.0"?>
<config>
<modules>
<My_Module>
<active>true</active>
<codePool>local</codePool>
</My_Module>
</modules>
</config>