Skip to content

Instantly share code, notes, and snippets.

View tegansnyder's full-sized avatar
💭
Stay'n cold in Minnesota

Tegan Snyder tegansnyder

💭
Stay'n cold in Minnesota
View GitHub Profile
@tegansnyder
tegansnyder / Magento-Customers-With-Multiple-Recurring-Profiles.php
Created December 14, 2012 01:50
Create a CSV of Magento Customers with more than one recurring profile attached to their account.
<?php
error_reporting(E_ALL | E_STRICT);
require_once 'app/Mage.php';
Varien_Profiler::enable();
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('default');
$collection = Mage::getModel('customer/customer')
@tegansnyder
tegansnyder / Magento-Recurring-Profile-CSV-Customers-Export.php
Created December 14, 2012 02:19
Produce a CSV of All Magento Customers with Recurring Profile Details
<?php
// Produce a CSV of All the Customers with Recurring Profile Details
error_reporting(E_ALL | E_STRICT);
require_once 'app/Mage.php';
Varien_Profiler::enable();
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('default');
@tegansnyder
tegansnyder / Magento-Reset-Discounts-By-IncrementId.php
Created December 14, 2012 17:45
Magento load an order by IncrementId and clear and discounts that applied on the order.
<?php
error_reporting(E_ALL | E_STRICT);
require_once 'app/Mage.php';
Varien_Profiler::enable();
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('default');
$order = Mage::getModel('sales/order')->loadByIncrementId('100126630');
@tegansnyder
tegansnyder / Magento-Get-Coupon-Codes-Used-on-Recurring-Profiles.php
Created December 17, 2012 22:52
Get a list of coupons used on recurring profiles in Magento
<?php
require_once 'app/Mage.php';
Varien_Profiler::enable();
Mage::setIsDeveloperMode(true);
ini_set('display_errors', 1);
umask(0);
Mage::app('default');
$profile = Mage::getModel('sales/recurring_profile')->getCollection();
@tegansnyder
tegansnyder / addExportButtonMagentoRecurringProfiles.php
Created December 31, 2012 16:16
To add a export button to Magento Recurring Profiles edit this file: /app/code/core/Mage/Adminhtml/controllers/Sales/Recurring/ProfileController.php
<?php
// ADD THIS CODE
/**
* Export order grid to CSV format
*/
public function exportCsvAction()
{
$fileName = 'subscriptions.csv';
@tegansnyder
tegansnyder / Get-OrderIncrementID-recurring-profiles-success-page.php
Created January 3, 2013 20:12
Get Order Increment ID on success.phtml file for recurring profiles
<?php
$order = Mage::getResourceModel('sales/order_collection')
->addFieldToFilter('customer_id', $customer_id)
->addRecurringProfilesFilter($profile->getProfileId())
->setOrder('entity_id', 'desc')
->getFirstItem();
echo '<pre>';
print_r($order->getData());
echo '</pre>';
<?php
$last_recurring_profile_id = $_SESSION['checkout']['last_recurring_profile_ids'][0];
$customer_id = Mage::getSingleton('customer/session')->getCustomerId();
$order = Mage::getResourceModel('sales/order_collection')
->addFieldToFilter('customer_id', $customer_id)
->addRecurringProfilesFilter($last_recurring_profile_id)
->setOrder('entity_id', 'desc')
->getFirstItem();
?>
@tegansnyder
tegansnyder / Mixpanel-Revenue-PHP.php
Created January 15, 2013 03:00
Here is an example of how to track Mixpanel Revenue Data using PHP and HTTP Post methods.
<?php
$params = array(
'$append' => array(
'$transactions' => array(
'$time' => '2013-01-03T00:58:05',
'$amount' => 125.34
),
),
'$token' => 'YOUR_MIX_PANEL_TOKEN',
@tegansnyder
tegansnyder / Magento-Abandon-Cart-Tied-To-Mixpanel-Engage-Like-A-Boss.php
Last active April 24, 2018 16:44
An example of creating an Abandon Cart report utilizing Mixpanel. This queries Magento for abandon carts then updates few people properties at Mixpanel. Then in Mixpanel you can create an "Engage" report that sends emails to folks that have "cart_created_at" less than 1 day and it will send emails to these people. Pretty niffted idea.
<?php
require_once('app/Mage.php');
umask(0);
Mage::app();
$log = '';
$db_conn = Mage::getSingleton('core/resource');
$r_conn = $db_conn->getConnection('core_read');
@tegansnyder
tegansnyder / GetMagentoCustomerIDbyEmail.php
Created February 19, 2013 18:34
Short example of getting customer_id of a Magento customer via email address outside of Magento via direct SQL
<?php
require_once('/site/app/Mage.php');
umask(0);
Mage::app();
//setup the direct sql db conn resource
$db_conn = Mage::getSingleton('core/resource');
$r_conn = $db_conn->getConnection('core_read');
$email = '[email protected]';