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 / opcache.ini
Last active September 2, 2022 16:24
OpCache settings for Magento on PHP 5.5.14. Store this file as /etc/php.d/opcache.ini
; Enable Zend OPcache extension module
zend_extension=opcache.so
; Determines if Zend OPCache is enabled
opcache.enable=1
; Determines if Zend OPCache is enabled for the CLI version of PHP
;opcache.enable_cli=0
; The OPcache shared memory storage size.
@tegansnyder
tegansnyder / find-products-without-images.sql
Created January 16, 2014 21:58
Magento - finding products without images. Raw SQL.
SELECT *
FROM `catalog_product_entity` AS a
LEFT JOIN `catalog_product_entity_media_gallery` AS b ON a.entity_id = b.entity_id
WHERE b.value IS NULL
@tegansnyder
tegansnyder / pyspark error.md
Created January 6, 2017 15:59
pyspark error

I'm recieving a strange error on a new install of Spark. I have setup a small 3 node spark cluster on top of an existing hadoop instance. The error I get is the same for any command I try to run on pyspark shell I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/opt/spark/python/pyspark/rdd.py", line 1041, in count
    return self.mapPartitions(lambda i: [sum(1 for _ in i)]).sum()
  File "/opt/spark/python/pyspark/rdd.py", line 1032, in sum
    return self.mapPartitions(lambda x: [sum(x)]).fold(0, operator.add)
  File "/opt/spark/python/pyspark/rdd.py", line 906, in fold
@tegansnyder
tegansnyder / magedev_db.sh
Last active April 8, 2022 04:00
For those times when you don't have n98-magerun handy and you need a stripped down database dump using pure bash and mysqldumps. This creates a database dump without any production data or customers. Essentially the same thing as @development striped option in n98-magerun db:dump.
#!/bin/bash -
#title :magedev_db.sh
#description :For those times when n98-magerun db:dump is unavailable
#author :Tegan Snyder
#notes :dev db backups in Magento via bash (no production data)
#==============================================================================
current_time=$(date "+%Y.%m.%d-%H.%M.%S")
# clean up tmp files
@tegansnyder
tegansnyder / abandon-cart.sql
Created June 16, 2014 20:04
Abandon cart Magento MySQL query example
SELECT `main_table`.*, (main_table.base_subtotal_with_discount*main_table.base_to_global_rate) AS `subtotal`, `cust_email`.`email`, `cust_fname`.`value` AS `firstname`, `cust_lname`.`value` AS `lastname`, CONCAT_WS(' ', cust_fname.value, cust_lname.value) AS `customer_name` FROM `sales_flat_quote` AS `main_table`
INNER JOIN `customer_entity` AS `cust_email` ON cust_email.entity_id = main_table.customer_id
INNER JOIN `customer_entity_varchar` AS `cust_fname` ON cust_fname.entity_id = main_table.customer_id AND cust_fname.attribute_id = 5
INNER JOIN `customer_entity_varchar` AS `cust_lname` ON cust_lname.entity_id = main_table.customer_id AND cust_lname.attribute_id = 7 WHERE (items_count != '0') AND (main_table.is_active = '1') AND (main_table.created_at >= '2014-06-15 00:00:00') ORDER BY updated_at DESC
@tegansnyder
tegansnyder / manual-dataflow-profile.php
Created January 28, 2014 17:23
Running a Magento Dataflow profile manually
<?php
/*
Author: Tegan Snyder <tsnyder@tegdesign.com>
Example of running a Dataflow profile via command line
you can change the profile_id to the one you want to
run and issue:
time php manual-dataflow-profile.php
note you may need to increase the memory_limit in php cli's php_cli.ini
RHEL linux copy /etc/php.ini to /etc/php_cli.ini and make changes there then restart Apache.
@tegansnyder
tegansnyder / httpd.conf
Last active April 7, 2021 00:41
Example of bringing Magento's .htaccess file into your Apache http.conf file.
#NameVirtualHost *:80
<VirtualHost *:80>
ServerName "www.domain.com"
ServerAlias domain.com
ErrorLog logs/error_log
TransferLog logs/access_log
LogLevel warn
ServerAdmin admin@domain.com
DocumentRoot /sites/magento
DirectoryIndex index.php index.html
@tegansnyder
tegansnyder / Magento 2 Programmatically Ship an Order with Tracking Details outside of Magento.md
Created March 29, 2021 04:39
Magento 2 Programmatically Ship an Order with Tracking Details outside of Magento

Create a file called abstract.php and place it in your root Magento folder:

abstract.php
<?php
use \Magento\Framework\AppInterface as AppInterface;
use \Magento\Framework\App\Http as Http;

use Magento\Framework\ObjectManager\ConfigLoaderInterface;
use Magento\Framework\App\Request\Http as RequestHttp;
@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>';
@tegansnyder
tegansnyder / abandon-cart.sql
Created July 30, 2014 14:27
Abandon Cart example
SELECT `main_table`.*,
(main_table.base_subtotal_with_discount*main_table.base_to_global_rate) AS `subtotal`,
`cust_email`.`email`,
`cust_fname`.`value` AS `firstname`,
`cust_lname`.`value` AS `lastname`,
CONCAT_WS(' ', cust_fname.value, cust_lname.value) AS `customer_name`
FROM `sales_flat_quote` AS `main_table`
INNER JOIN `customer_entity` AS `cust_email` ON cust_email.entity_id = main_table.customer_id
INNER JOIN `customer_entity_varchar` AS `cust_fname` ON cust_fname.entity_id = main_table.customer_id
AND cust_fname.attribute_id = 5