Skip to content

Instantly share code, notes, and snippets.

View dvdmierden's full-sized avatar

dvdmierden dvdmierden

View GitHub Profile
@arosenhagen
arosenhagen / magento-code-snippets.md
Last active April 8, 2024 09:21
[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
@molotovbliss
molotovbliss / gist:2562551
Last active September 7, 2022 20:18 — forked from davidalexander/gist:1086455
Magento Snippets

Magento Snippets

Set all categories to is_anchor 1

Find attribute_id

SELECT * FROM eav_attribute where attribute_code = 'is_anchor'

Update all of them with anchor_id from above (usually is ID 51)

UPDATE `catalog_category_entity_int` set value = 1 where attribute_id = 51
@centerax
centerax / create_user.php
Created June 26, 2014 14:50
Create New Magento admin User programmatically
<?php
// Create New admin User programmatically.
require_once('./app/Mage.php');
umask(0);
Mage::app();
try {
$user = Mage::getModel('admin/user')
->setData(array(
@sandermangel
sandermangel / price.phtml without Weee
Last active November 13, 2018 15:13
The price.phtml template without all the Weee stuff
<?php
/**
* Updated price.phtml without WEEE
*
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License
* It is available through the world-wide-web at this URL:
* http://opensource.org/licenses/mit-license.php
*
@litzinger
litzinger / create-magento-user.php
Created June 4, 2015 16:57
Create a Magento user via PHP script to get into admin area.
<?php
define( 'USERNAME', 'new.user' );
define( 'PASSWORD', 'password' );
define( 'FIRSTNAME', 'Excited' );
define( 'LASTNAME', 'Croc' );
define( 'EMAIL', 'new.user@magento.com' );
include_once( 'app/Mage.php' );
Mage::app( 'admin' );
try {
@molotovbliss
molotovbliss / create-order.php
Created May 2, 2016 11:35
Magento Orders Import/Export
<?php
require_once '../app/Mage.php';
Mage::app();
$id=1; // get Customer Id
$customer = Mage::getModel('customer/customer')->load($id);
$transaction = Mage::getModel('core/resource_transaction');
$storeId = $customer->getStoreId();
@shreyans94
shreyans94 / gist:05b10194cf2f57cf054a5cf3da3fd931
Created January 23, 2018 21:32
Display ACF for woocommerce variations in backend
// Render fields at the bottom of variations - does not account for field group order or placement.
add_action( 'woocommerce_product_after_variable_attributes', function( $loop, $variation_data, $variation ) {
global $abcdefgh_i; // Custom global variable to monitor index
$abcdefgh_i = $loop;
// Add filter to update field name
add_filter( 'acf/prepare_field', 'acf_prepare_field_update_field_name' );
// Loop through all field groups
$acf_field_groups = acf_get_field_groups();
foreach( $acf_field_groups as $acf_field_group ) {
@Aljullu
Aljullu / all-woocommerce-blocks.htm
Last active February 17, 2024 16:58
WC Blocks (all blocks). Ready to be copied (Ctrl+C) and pasted (Ctrl+Shift+V) into the editor.
<!-- wp:woocommerce/featured-product {"editMode":false,"productId":15} -->
<!-- wp:button {"align":"center"} -->
<div class="wp-block-button aligncenter"><a class="wp-block-button__link" href="https://ephemeral-aljullu-20200929.atomicsites.blog/product/beanie/">Shop now</a></div>
<!-- /wp:button -->
<!-- /wp:woocommerce/featured-product -->
<!-- wp:woocommerce/featured-category {"editMode":false,"categoryId":16} -->
<!-- wp:button {"align":"center"} -->
<div class="wp-block-button aligncenter"><a class="wp-block-button__link" href="https://ephemeral-aljullu-20200929.atomicsites.blog/product-category/clothing/">Shop now</a></div>
<!-- /wp:button -->
@AshlinRejo
AshlinRejo / Discount rules v2: Get applied discount rules
Created December 3, 2020 08:52
Discount rules v2: Get applied discount rules
add_action('woocommerce_before_cart', function (){
if(class_exists('\Wdr\App\Controllers\ManageDiscount') && class_exists('\Wdr\App\Controllers\DiscountCalculator')) {
if (!empty(\Wdr\App\Controllers\ManageDiscount::$calculator)) {
$calc = \Wdr\App\Controllers\ManageDiscount::$calculator;
$applied_rules = $calc::$applied_rules;
//$applied_rules -> here you get applied discount rules
}
}
});