Skip to content

Instantly share code, notes, and snippets.

View ZaneCEO's full-sized avatar

Dr. Gianluigi "Zane" Zanettini ZaneCEO

View GitHub Profile
@azhararmar
azhararmar / Symfony - Manual User Authentication
Last active June 16, 2023 15:35
Manually Authenticate User In Symfony
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
// Manually authenticate user in controller
$token = new UsernamePasswordToken($user, null, 'main', $user->getRoles());
$this->get('security.token_storage')->setToken($token);
$this->get('session')->set('_security_main', serialize($token));
@aurire
aurire / get_attribute_set_id.php
Last active December 17, 2019 11:14
Magento. Get Catalog Product Entity Type ID, instead of using 4 (MAGIC NUMBER). Works the same, for getting other entity type id by name.
$entityTypeId = Mage::getModel('eav/entity')->setType('catalog_product')->getTypeId();
//Alternative
$entityTypeId = Mage::getSingleton('ceav/config')->getEntityType(Mage_Catalog_Model_Product::ENTITY)->getId();
@dvrensk
dvrensk / redsys_result_codes.rb
Created February 4, 2015 17:02
These are the result codes from Spanish payment gateway Redsys (formerly Sermepa) that I've managed to collect. The list is no doubt incomplete, and I'll be happy to update it if you have any more codes.
RESULT_CODES = (<<-EOT).split(/\r?\n/).reject {|s| s.match(/^( *#.*)?$/)}.map { |s| s.sub(/^ +/,'').split(/ +/,2) }.to_h
# Copied from http://dwalins.com/2014/codigo-de-respuesta-de-sermepa-redsys/
0101 Tarjeta Caducada
0102 Tarjeta en excepción transitoria o bajo sospecha de fraude
0104 Operación no permitida para esa tarjeta o terminal
0106 Intentos de PIN excedidos
0116 Disponible Insuficiente
0118 Tarjeta no Registrada
0125 Tarjeta no efectiva
0129 Código de seguridad (CVV2/CVC2) incorrecto
@jedarlington
jedarlington / Magento HTML sitemaps generated for category and product at this url (Product sitemap link included in category sitemap)
Created January 21, 2014 15:52
Magento HTML sitemaps generated for category and product at this url (Product sitemap link included in category sitemap)
@aleron75
aleron75 / gist:7304592
Last active May 18, 2018 15:57
Programmaticalli create a Yes/No Magento Category Attribute
<?php
/** @var Mage_Eav_Model_Entity_Setup $installer */
$installer = $this;
$installer->startSetup();
$this->addAttribute(
'catalog_category',
'my_custom_attribute',
array(
'group' => 'General Information',
@jreinke
jreinke / gist:6508802
Created September 10, 2013 12:36
Magento: get attribute id by code
<?php
$attributeId = Mage::getResourceModel('eav/entity_attribute')
->getIdByCode('catalog_product', 'color');
@mukundthanki
mukundthanki / col-left.phtml
Last active September 23, 2019 14:09
Magento: How to get current category in magento
<?php
// Using singleton
$_category = Mage::getSingleton('catalog/layer')->getCurrentCategory();
// Using Model
$_category = Mage::getModel('catalog/layer')->getCurrentCategory();
// Using Registry
$_category = Mage::registry('current_category');
?>
@bekapod
bekapod / block.html
Created September 3, 2012 09:16
MAGENTO: Include skin image on CMS block
<img src={{skin url="images/logo.png"}} alt="alt text" />
@mayconbordin
mayconbordin / progress_bar.php
Created June 2, 2012 23:55
PHP CLI progress bar in 5 lines of code
<?php
function progress_bar($done, $total, $info="", $width=50) {
$perc = round(($done * 100) / $total);
$bar = round(($width * $perc) / 100);
return sprintf("%s%%[%s>%s]%s\r", $perc, str_repeat("=", $bar), str_repeat(" ", $width-$bar), $info);
}