Skip to content

Instantly share code, notes, and snippets.

View VIVEKLUCKY249's full-sized avatar

VS VIVEKLUCKY249

View GitHub Profile
public function mycoolAction()
{
/* ... Some code ...*/
$update = $this->getLayout()->getUpdate();
/* ... Some code ...*/
$this->addActionLayoutHandles();
/* ... Some code ...*/
$this->loadLayoutUpdates();
/* ... Some code ...*/
/* My stuff, add pure XML like you do from XML layout files <img src="http://inchoo.net/wp-includes/images/smilies/icon_smile.gif" alt=":)" class="wp-smiley"> */

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
<?php
namespace Pokus;
class Exception extends \Exception
{
}
function tttt($string)
{
try {
@VIVEKLUCKY249
VIVEKLUCKY249 / exception.php
Created January 28, 2017 06:41
Magento How To Show Full Error/Exception Message Instead of Truncated One
<?php
function getExceptionTraceAsString($exception) {
$rtn = "";
$count = 0;
foreach ($exception->getTrace() as $frame) {
$args = "";
if (isset($frame['args'])) {
$args = array();
foreach ($frame['args'] as $arg) {
if (is_string($arg)) {
@VIVEKLUCKY249
VIVEKLUCKY249 / magento-code-snippets.md
Created January 28, 2017 06:40 — 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

Magento Code Snippets

Download extension manually using mage

./mage config-set preferred_state stable
./mage clear-cache
./mage sync
./mage download community Module_Name
@VIVEKLUCKY249
VIVEKLUCKY249 / robots.txt
Created January 28, 2017 06:39 — forked from vkathirvel/robots.txt
Magento Robots.txt
########################################################################################
# Kathir 'Sid' Vel's robots.txt file for Magento websites
########################################################################################
User-agent: *
Allow: /
#Disallow: /
########################################################################################
# Do not crawl development files and folders
@VIVEKLUCKY249
VIVEKLUCKY249 / MagentoImagesDelete.php
Created January 28, 2017 06:39 — forked from vkathirvel/MagentoImagesDelete.php
Magento Delete Unused Images
<?php
/*
If your products have been deleted but not your media gallery images you
can use the following SQL statement to remove these dormant records.
Please make sure you backup your installation and database before running this
SQL statement. It has been used on Mage 1.8.1 system:
@VIVEKLUCKY249
VIVEKLUCKY249 / Magento-Customer-Export.php
Created January 28, 2017 06:37 — forked from vkathirvel/Magento-Customer-Export.php
Saves a CSV file containing all customers' data
<?php
require_once('app/Mage.php');
umask(0);
Mage::app();
$customers = Mage::getModel('customer/customer')->getCollection();
$customers->addAttributeToSelect('*');
$customersArray[0] = array(
@VIVEKLUCKY249
VIVEKLUCKY249 / .htaccess
Created January 28, 2017 06:36 — forked from vkathirvel/.htaccess
htaccess Non-WWW WWW Redirects
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^content\.(.*)$ [NC]
RewriteCond %{HTTP_HOST} !^themes\.(.*)$ [NC]
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.(.*)$ [NC]