Skip to content

Instantly share code, notes, and snippets.

View elisei's full-sized avatar
:octocat:
Isto fica feliz em ser útil!

Bruno elisei

:octocat:
Isto fica feliz em ser útil!
View GitHub Profile
@elisei
elisei / hhvm_magento_setup.md
Created June 4, 2016 01:51 — forked from tegansnyder/hhvm_magento_setup.md
HHVM Magento Server Setup

I've had the opertunity to try a variety of different server configurations but never really got around to trying HHVM with Magento until recently. I thought I would share a detailed walkthrough of configuring a single instance Magento server running Nginx + Fast CGI + HHVM / PHP-FPM + Redis + Percona. For the purpose of this blog post I'm assuming you are using Fedora, CentOS, or in my case RHEL 6.5.

Please note: I'm 100% open to suggestions. If you see something I did that needs to be done a different way, please let me know. I haven't included my Perconca my.conf file yet. I will shortly. Also I plan on trying this same test with HHVM 3.3 and PHP 7.

Install the EPEL, Webtatic, and REMI repos

rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
@elisei
elisei / Category.sql
Created August 10, 2016 20:12 — forked from ticean/Category.sql
A series of queries for selecting Magento entity EAV attributes, and their values. Lots of union here...
SET @entityid = '3';
SELECT ea.attribute_id, ea.attribute_code, eav.value AS 'value', 'varchar' AS 'type'
FROM catalog_category_entity e
JOIN catalog_category_entity_varchar eav
ON e.entity_id = eav.entity_id
JOIN eav_attribute ea
ON eav.attribute_id = ea.attribute_id
WHERE e.entity_id = @entityid
UNION
@elisei
elisei / magento-code-snippets.md
Created August 10, 2016 20:21 — forked from arosenhagen/magento-code-snippets.md
[magento] - code snippets

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name
@elisei
elisei / Sales-by-category.sql
Created January 20, 2017 19:17 — forked from tegansnyder/Sales-by-category.sql
Finding the category that has the most sales in Magento
SELECT cat_id, SUM(row_total) as total_sales_by_cat, cv.value FROM (
SELECT c2.entity_id as cat_id, si.row_total
FROM catalog_category_product c1
INNER JOIN catalog_category_entity_varchar c2 ON (c1.category_id = c2.entity_id)
INNER JOIN catalog_product_entity c3 ON (c1.product_id = c3.entity_id)
INNER JOIN sales_flat_order_item si ON (si.product_id = c3.entity_id)
WHERE c2.attribute_id = (SELECT attribute_id FROM eav_attribute WHERE attribute_code = 'name' AND entity_type_id = 3)
ORDER BY si.created_at DESC
) main
INNER JOIN catalog_category_entity_varchar cv ON (cv.entity_id = cat_id)
@elisei
elisei / Magento-Average-Orders-Average-Discounts-Totals-by-Month-Year.sql Magento get average order, discount, item count, and order amount break down by month and year with direct SQL
SELECT sub_query.month_ordered,
sub_query.year_ordered,
AVG(sub_query.base_subtotal) AS average_base_subtotal,
AVG(sub_query.discount_amount) AS average_discount_amt,
AVG(sub_query.order_qty) AS average_total_item_count,
COUNT(sub_query.entity_id) AS total_orders
FROM
(SELECT so.entity_id,
MONTH(so.created_at) AS month_ordered,
YEAR(so.created_at) AS year_ordered,
@elisei
elisei / Magento-new-customer-sales-by-month-year.sql
Created January 20, 2017 19:17 — forked from tegansnyder/Magento-new-customer-sales-by-month-year.sql
Magento - New Customer Sales Averages and Totals by Month and Year - direct sql
SELECT sub_query.month_ordered,
sub_query.year_ordered,
AVG(sub_query.base_subtotal) AS average_base_subtotal,
AVG(sub_query.discount_amount) AS average_discount_amt,
AVG(sub_query.order_qty) AS average_total_item_count,
COUNT(sub_query.entity_id) AS total_orders
FROM
(SELECT so.entity_id,
MONTH(so.created_at) AS month_ordered,
YEAR(so.created_at) AS year_ordered,
@elisei
elisei / email-test.php
Created January 20, 2017 19:59 — forked from tegansnyder/email-test.php
email testing SMTP outbound relay on Magento
<?php
/**
* email-tester.php
* A tool to test if the SMTP relay is working
*
* @category Mmm
* @package EmailTester
* @author Tegan Snyder
*
*/
@elisei
elisei / abandon-cart.sql
Created January 20, 2017 20:02 — forked from tegansnyder/abandon-cart.sql
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
<?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();
?>
@elisei
elisei / Get-OrderIncrementID-recurring-profiles-success-page.php
Created January 20, 2017 20:29 — forked from tegansnyder/Get-OrderIncrementID-recurring-profiles-success-page.php
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>';