Skip to content

Instantly share code, notes, and snippets.

View willboudle's full-sized avatar

Will Boudle willboudle

View GitHub Profile
<reference name="head">
<block type="core/text" name="your_external_csv">
<action method="setText">
<text><![CDATA[<link rel="stylesheet" type="text/css" href="http://www.broadwaymerchandiseshop.com/skins/www.broadwaymerchandiseshop.com/style.css?ver=14">]]>
</text>
</action>
</block>
</reference>
@willboudle
willboudle / createAttribs.php
Created December 22, 2015 23:10
Create Magento Attributes using API and CSV file
<?php
// Details
$SETTINGS = array(
"apiUser" => "your_api_username",
"apiKey" => "your_api_password",
"apiURL" => "http://magentohost/api/soap/?w…..&quot;,
"default_attr_set_id" => 4, // should always be 4
"api_ignore_errors" => false,
);
$csv_file = "path/to/your/csv_file.csv";
@willboudle
willboudle / exportAttr.php
Created December 22, 2015 23:11
Export Magento Attributes to csv
<?php
define('MAGENTO', realpath(dirname(__FILE__)));
require_once MAGENTO . '/app/Mage.php';
Mage::app();
$entity_type_id = Mage::getModel('catalog/product')->getResource()->getTypeId();
prepareCollection($entity_type_id);
function prepareCollection($ent_type_id){
$resource = Mage::getSingleton('core/resource');
@willboudle
willboudle / importAttr.php
Created December 22, 2015 23:12
Import Magento Attributes from CSV
<?php
define('MAGENTO', realpath(dirname(__FILE__)));
require_once MAGENTO . '/../app/Mage.php';
Mage::app();
// $fileName = MAGENTO . '/var/import/importAttrib.csv';
$fileName = 'importAttrib.csv';
// getCsv($fileName);
getAttributeCsv($fileName);
function getAttributeCsv($fileName){
@willboudle
willboudle / emailreport.php
Last active March 10, 2016 20:59
mage email report
<?php
require './app/Mage.php';
Mage::app();
$sendToEmailAddress = 'addressedto@test.com';
$sendToName = 'AddressedTo Name';
//I set date in php because I want to set it also in different format as email subject
$dateStart = mktime(0, 0, 0, date('m'), date('d')-7, date('Y'));
$dateEnd = mktime(23, 59, 59, date('m'), date('d'), date('Y'));
@willboudle
willboudle / mage-clear-cache.php
Created February 1, 2017 15:38
Magento Clear Cache Script
<?php
require_once '../app/Mage.php';
umask(0);
Mage::app('default');
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
try {
$allTypes = Mage::app()->useCache();
foreach($allTypes as $type => $value) {
@willboudle
willboudle / find_base64.php
Created August 22, 2017 18:33
Search All Files For base64_decode
<html><head><title>Find String</title></head><body>
<?php
// ini_set('max_execution_time', '0');
// ini_set('set_time_limit', '0');
find_files('.');
function find_files($seed) {
if(! is_dir($seed)) return false;
$files = array();
$dirs = array($seed);
while(NULL !== ($dir = array_pop($dirs)))
@willboudle
willboudle / clv.sql
Created January 7, 2018 08:24
CLV in Magento
SELECT DISTINCT customer_email, customer_firstname, customer_lastname,
SUM(subtotal_invoiced) AS Total
FROM `sales_flat_order` AS a
GROUP BY customer_email
ORDER BY SUM(subtotal_invoiced) DESC
@willboudle
willboudle / avgorderperday.sql
Created January 7, 2018 12:49
Average Orders Per Day sql magento
SELECT AVG( orders_num )
FROM (
SELECT created_at, COUNT( DISTINCT order_id ) orders_num
FROM `sales_flat_order_item`
WHERE created_at > "2016-07-01 00:00:00"
AND created_at < "2017-01-01 00:00:00"
GROUP BY CAST( created_at AS DATE )
)orders_per_day
@willboudle
willboudle / unbuffered_shell_example.php
Created May 30, 2018 02:48 — forked from cmtickle/unbuffered_shell_example.php
Use unbuffered SQL queries with Magento to reduce memory usage on large data sets.
<?php
require_once 'abstract.php';
class Cmtickle_Demo_Shell_Tool extends Mage_Shell_Abstract
{
private $_readConnection = null;
protected function _getReadConnection()
{