Skip to content

Instantly share code, notes, and snippets.

View ViniciusAugusto's full-sized avatar

Vinícius Augusto ViniciusAugusto

View GitHub Profile
@ViniciusAugusto
ViniciusAugusto / delete.sql
Created September 28, 2015 17:46
Magento - Deletar todos os produtos via sql
SET FOREIGN_KEY_CHECKS = 0;
TRUNCATE TABLE `catalog_product_bundle_option`;
TRUNCATE TABLE `catalog_product_bundle_option_value`;
TRUNCATE TABLE `catalog_product_bundle_selection`;
TRUNCATE TABLE `catalog_product_entity_datetime`;
TRUNCATE TABLE `catalog_product_entity_decimal`;
TRUNCATE TABLE `catalog_product_entity_gallery`;
TRUNCATE TABLE `catalog_product_entity_int`;
TRUNCATE TABLE `catalog_product_entity_media_gallery`;
TRUNCATE TABLE `catalog_product_entity_media_gallery_value`;

Strings

String.prototype.*

None of the string methods modify this – they always return fresh strings.

  • charAt(pos: number): string ES1

    Returns the character at index pos, as a string (JavaScript does not have a datatype for characters). str[i] is equivalent to str.charAt(i) and more concise (caveat: may not work on old engines).

<?php
require_once('app/Mage.php'); //Path to Magento
error_reporting(E_ALL);
ini_set("display_errors", 1);
umask(0);
Mage::app();
@ViniciusAugusto
ViniciusAugusto / price.phtml
Created September 29, 2015 14:14
Magento: Show product discount percent
If you wish to show product discount percent next to product price or somewhere on a product page, here’s how you do it.
Open app/design/frontend/yourpackage/yourtheme/template/catalog/product/price.phtml
Find:
<?php endif; /* if ($_finalPrice == $_price): */ ?>
Past above it: