Skip to content

Instantly share code, notes, and snippets.

View scgoeswild's full-sized avatar

Simone Chinaglia scgoeswild

View GitHub Profile
@scgoeswild
scgoeswild / woo-change-addtocart-link.php
Last active November 12, 2020 11:24
Change the Add To Cart Link and Text on WooCommerce Archive Page
@scgoeswild
scgoeswild / utilities.php
Last active April 24, 2018 21:35
Woocommerce every 2 product the third (randomly) is free
<?php
add_action( 'wp', 'add_free_product_to_cart' );
function add_free_product_to_cart( ) {
if (!is_admin()) {
$count = 1;
$count_free = 0;
@scgoeswild
scgoeswild / exportCategories.php
Last active November 17, 2020 15:45
Magento 1.9 export categories with TreeModel
<?php
ini_set("memory_limit", "10000M");
require_once "app/Mage.php";
umask(0);
Mage::app();
$category = Mage::getModel('catalog/category');
$tree = $category->getTreeModel();
$tree->load();
$ids = $tree->getCollection()->getAllIds();
if ($ids) {
@scgoeswild
scgoeswild / exportAttributes.php
Created November 12, 2020 11:24
Magento 1.9 export attributes
<?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');
@scgoeswild
scgoeswild / Product.php
Last active November 21, 2020 11:08
Magento 1.9 export products by dataflow profile
<?php #to export category name instead of category Ids, you should unparse the file app/code/core/Mage/Catalog/Model/Convert/Parser/Product.php by copy and replace this lines (around at 402 line)
/**
* Unparse (prepare data) loaded products
*
* @return Mage_Catalog_Model_Convert_Parser_Product
*/
public function unparse()
{
$entityIds = $this->getData();
@scgoeswild
scgoeswild / remove-orders.sql
Created November 28, 2020 08:52
Remove all orders from Magento 1.9
--
-- This query delelets all customers and orders from your
-- Magento 1.* install. Handy, if you have a bloated
-- Magento database and you need to do a bit
-- of cleaning up for use on a local machine.
--
-- Replace PREFIX_ with your current Magento table prefix.
--
-- USE AT OWN RISK. ALWAY BACKUP YOUR DATABASE FIRST.
--
@scgoeswild
scgoeswild / filesystem.config
Created November 29, 2020 10:44
Elastic Beanstalk mount EFS volume and filesystem
#
# Replace FILESYSTEM-ID-HERE and REGION-ID-HERE
#
option_settings:
- option_name: EFS_VOLUME_ID
value: FILESYSTEM-ID-HERE
- option_name: EFS_REGION
value: REGION-ID-HERE
@scgoeswild
scgoeswild / ssl.config
Created November 29, 2020 12:53
LetsEncrypt SSL AWS Elastic Beanstalk
# (!) Based on : https://gist.github.com/tony-gutierrez/198988c34e020af0192bab543d35a62a
# Dont forget to set the env variable "CERTDOMAIN" and "EMAIL"
# Also note that this config is using the LetsEncrypt staging server, remove the flag when ready!
Resources:
sslSecurityGroupIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupId: {"Fn::GetAtt" : ["AWSEBSecurityGroup", "GroupId"]}
IpProtocol: tcp
@scgoeswild
scgoeswild / access
Created December 2, 2020 12:37
MySQL Access denied; you need (at least one of) the SUPER privilege(s) for this operation
#ERROR 1227 (42000) at line 374: Access denied; you need (at least one of) the SUPER privilege(s) for this operation
sed -i old 's/\DEFINER\=`[^`]*`@`[^`]*`//g' file.sql
@scgoeswild
scgoeswild / invoice.php
Last active December 2, 2020 17:31
Magento 1.9 add admin order comments to invoice.php
<?php
/* add these lines to /app/code/core/Mage/Sales/Model/Order/Pdf/invoice.php */
/* Add Comments */
$statusHistory = $order->getStatusHistoryCollection()->getData();
$order_comments = '';
foreach($statusHistory as $status) {
$new_comment = '';
if ($status['comment']) {