working on it ...

Filters

Explore Public Snippets

Sort by

Found 28 snippets matching: magento1

    public by bobby  157342  2  4  0

    Returns Descriptions for all active Magento products

    Returns Descriptions for all active Magento products: Magento-active-product-descriptions.sql
    SELECT 
        e.entity_id,
        e.sku,
        eav.value AS 'description',
        IF(at_status.value_id > 0,
            at_status.value,
            at_status_default.value) AS `status`
    FROM
        catalog_product_entity e
            JOIN
        catalog_product_entity_text eav ON e.entity_id = eav.entity_id
            JOIN
        eav_attribute ea ON eav.attribute_id = ea.attribute_id
            INNER JOIN
        `catalog_product_entity_int` AS `at_status_default` ON (`at_status_default`.`entity_id` = `e`.`entity_id`)
            AND (`at_status_default`.`attribute_id` = '89')
            AND `at_status_default`.`store_id` = 0
            LEFT JOIN
        `catalog_product_entity_int` AS `at_status` ON (`at_status`.`entity_id` = `e`.`entity_id`)
            AND (`at_status`.`attribute_id` = '89')
            AND (`at_status`.`store_id` = 1)
    WHERE
        ea.attribute_code = 'description'
            AND IF(at_status.value_id > 0,
            at_status.value,
            at_status_default.value) = 1
    LIMIT 9999
    
                

    public by shebin512  3038  1  5  0

    Bash Script to clean magento 1.x Cache

    Magento 1.x cache clean Bash script. 1. Save the code in "/path/of/the/file/.sh" 2. Give executable permission for the file "chmod a+x /path/of/the/file/.sh" 3. Run the script from your magento document root like $ /path/of/the/file/.sh
    #!/bin/bash 
    # author Shebin Sheikh
    
    # function to remove the magento cache.
    function mageCacheClear {
    
    	local current_dir=$(pwd);
    	#echo $current_dir
    	#exit
    
    	if [[ -f "$current_dir/app/Mage.php" ]]; then
    		#echo "Inside Mage Doc root"
    		rm -vrf var/{cache,full_page_cache}/ media/{js,css}/
    	else
    		echo -e "Not inside A magento 1.X's document root!"
    		exit $?
    	fi
    
    }
    
    mageCacheClear # call the function

    public by shebin512  5121  1  8  1

    Magento get current controller ,current module , current action and route name

    Magento get current controller ,current module , current action and route name
    <?php
    
    /*
     *Magento get current controller ,current module , current action and route name
     */
    
    //1 . controller name
    Mage::app()->getRequest()->getControllerName();// will return controller name
    
    //2. action name
    Mage::app()->getRequest()->getActionName();//will return action name
    
    //3. module name
    Mage::app()->getRequest()->getModuleName();// will return module name
    
    //4. routes name
    Mage::app()->getRequest()->getRouteName();//will return routes name            

    external by amikitevich  114  0  2  0

    проблема сохранения даты magento1 admin

    проблема сохранения даты magento1 admin: gistfile1.txt
    Mage_Eav_Model_Entity_Attribute_Backend_Time_Created::beforeSave
    файл app/code/core/Mage/Eav/Model/Entity/Attribute/Backend/Time/Created.php
    
    http://magento.stackexchange.com/questions/18062/customer-created-at-date-off-by-months
    
    

    external by Steve Robbins  45  0  1  0

    Display what information we can about Magento1 objects that are ioncubed

    Display what information we can about Magento1 objects that are ioncubed: magento-ioncube-module-info.php
    <?php ini_set('display_errors', 1) ?>
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/styles/default.min.css">
    <script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.5/highlight.min.js"></script>
    <script>hljs.initHighlightingOnLoad();</script>
    <?php
    
    include 'app/Mage.php';
    
    $classes = array(
        'SFC_CyberSource_Helper_Gateway_Api',
        'SFC_CyberSource_Helper_Gateway_Exception',
        'SFC_CyberSource_Helper_Gateway',
        'SFC_CyberSource_Helper_Payment',
        'SFC_CyberSource_Helper_Tsvfile',
        'SFC_CyberSource_Model_Api_ExtendedSoapClient',
        'SFC_CyberSource_Model_Method',
        'SFC_CyberSource_Model_Observer',
        'SFC_CyberSource_Model_Session',
        'SFC_CyberSource_Model_Source_Cctype',
        'SFC_CyberSource_Model_Source_Month',
        'SFC_CyberSource_Model_Source_Year',
    );
    
    foreach ($classes as $class) {
        $rClass = new ReflectionClass($class);
        echo '<pre><code>&lt;?php';
        echo "\n# {$rClass->getFileName()} lines {$rClass->getStartLine()}-{$rClass->getEndLine()}";
        echo "\n\n" . htmlentities($rClass->getDocComment()) . "\n";
        echo 'class ' . $rClass->name;
        if ($rParent = $rClass->getParentClass()) {
            echo ' extends ' . $rParent->getName();
        }
        echo "\n{";
        foreach ($rClass->getMethods() as $method) {
            $rMethod = new ReflectionMethod($class, $method->getName());
            echo "\n\n    " . htmlentities($rMethod->getDocComment()) . "\n    ";
            if ($rMethod->isPrivate()) {
                echo 'private';
            } elseif ($rMethod->isProtected()) {
                echo 'protected';
            } else {
                echo 'public';
            }
            echo ' function ' . $rMethod->getName() . '(';
            $paramString = '';
            foreach ($rMethod->getParameters() as $rParam) {
                if ($rParam->isPassedByReference()) {
                    $paramString .= '&';
                }
                $paramString .= '$' . $rParam->getName();
                // try {
                //     if ($default = $rParam->getDefaultValue()) {
                //         $paramString .= ' = ' . $default;
                //     }
                // } catch (Exception $e) {
                //     // intentionally left blank
                // }
                $paramString .= ', ';
            }
            echo trim($paramString, ', ');
            echo ")\n    {\n";
            echo "    }";
        }
        echo "\n}</code></pre>";
    }
    
    
    

    external by amacgregor  253  0  3  0

    Magento1 Product class constructor

    Magento1 Product class constructor: Product.php
    PHP
    <?php
    
    class Mage_Catalog_Model_Product extends Mage_Catalog_Model_Abstract
    {
        /**
         * Initialize resources
         */
        protected function _construct()
        {
            $this->_init('catalog/product');
        }
    
    

    external by chickenland  173  0  2  0

    Magento1 - Create category attribute

    Magento1 - Create category attribute: create-category-attribute.php
    <?php
    
    //XML <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
    
    /* @var $installer Mage_Core_Model_Resource_Setup */
    $installer = $this;
    
    $installer->startSetup();
    
    $entityTypeId     = $installer->getEntityTypeId('catalog_category');
    $attributeSetId   = $installer->getDefaultAttributeSetId($entityTypeId);
    $attributeGroupId = $installer->getDefaultAttributeGroupId($entityTypeId, $attributeSetId);
    
    $installer->addAttribute('catalog_category', 'banner_link',  array(
        'type'     => 'int',
        'label'    => 'Banner Link',
        'input'    => 'text',
        'global'   => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
        'visible'           => true,
        'required'          => false,
        'user_defined'      => false,
        'default'           => 0
    ));
    
    
    $installer->addAttributeToGroup(
        $entityTypeId,
        $attributeSetId,
        $attributeGroupId,
        'banner_link',
        '11'					//last Magento's attribute position in General tab is 10
    );
    
    $attributeId = $installer->getAttributeId($entityTypeId, 'banner_link');
    
    $installer->run("
    INSERT INTO `{$installer->getTable('catalog_category_entity_int')}`
    (`entity_type_id`, `attribute_id`, `entity_id`, `value`)
        SELECT '{$entityTypeId}', '{$attributeId}', `entity_id`, '1'
            FROM `{$installer->getTable('catalog_category_entity')}`;
    ");
    
    $installer->endSetup();
    
    

    external by Yaroslav Voronoy  118  0  2  0

    Generate Magento1 Test Data

    Generate Magento1 Test Data: m1fakedata.php
    #!/usr/bin/php
    <?php
    $mageFilename = 'app/Mage.php';
    require_once $mageFilename;
    Mage::setIsDeveloperMode(true);
    ini_set('display_errors', 1);
    umask(0);
    Mage::app('admin');
    Mage::register('isSecureArea', 1);
    Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
    
    
    $parentId = '2';
    $randomString = readable_random_string();
     try{
        $category = Mage::getModel('catalog/category');
        $category->setName($randomString);
        $category->setUrlKey($randomString);
        $category->setIsActive(1);
        $category->setDisplayMode('PRODUCTS');
        $category->setIsAnchor(1); //for active anchor
        $category->setStoreId(Mage::app()->getStore()->getId());
        $parentCategory = Mage::getModel('catalog/category')->load($parentId);
        $category->setPath($parentCategory->getPath());
        $category->save();
    } catch(Exception $e) {
        print_r($e);
    }
    
    
    $api            = new Mage_Catalog_Model_Product_Api();
    $attr_api       = new Mage_Catalog_Model_Product_Attribute_Set_Api();
    $attribute_sets = $attr_api->items();
    $prefix    = 'demo.';
    $tax_class = 2;
    $x = 1;
        $sku       = readable_random_string();
        $price     = 100;
        $weight    = rand(1,2);
        $productData = array();
        $productData['website_ids'] = array(1);
        $productData['categories'] = array($category->getId());
        $productData['status'] = 1;
        $productData['name'] = $sku;
        $productData['description'] = utf8_encode('This is a Demo Description for the Product: Demo ' . $sku);
        $productData['short_description'] = utf8_encode('This is a short Demo Description for the Product: Demo ' . $sku);
        $productData['price'] = $price;
        $productData['weight'] = $weight;
        $productData['tax_class_id'] = $tax_class;
        $new_product_id = $api->create('simple', $attribute_sets[0]['set_id'], $prefix . $sku, $productData);
        $stockItem = Mage::getModel('cataloginventory/stock_item');
        $stockItem->loadByProduct( $new_product_id );
        $stockItem->setData('use_config_manage_stock', 1);
        $stockItem->setData('qty', 100);
        $stockItem->setData('min_qty', 0);
        $stockItem->setData('use_config_min_qty', 1);
        $stockItem->setData('min_sale_qty', 0);
        $stockItem->setData('use_config_max_sale_qty', 1);
        $stockItem->setData('max_sale_qty', 0);
        $stockItem->setData('use_config_max_sale_qty', 1);
        $stockItem->setData('is_qty_decimal', 0);
        $stockItem->setData('backorders', 0);
        $stockItem->setData('notify_stock_qty', 0);
        $stockItem->setData('is_in_stock', 1);
        $stockItem->setData('tax_class_id', 0);
        $stockItem->save();
        $product = Mage::getModel('catalog/product')->load($new_product_id);
        $product->save();
    
    function readable_random_string($length = 6)
    {  
        $string     = '';
        $vowels     = array("a","e","i","o","u");  
        $consonants = array(
            'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 
            'n', 'p', 'r', 's', 't', 'v', 'w', 'x', 'y', 'z'
        );  
        // Seed it
        srand((double) microtime() * 1000000);
        $max = $length/2;
        for ($i = 1; $i <= $max; $i++)
        {
            $string .= $consonants[rand(0,19)];
            $string .= $vowels[rand(0,4)];
        }
        return $string;
    }
    
    
    

    external by Github  21  0  1  0

    Magento1 Redis Configuration

    Magento1 Redis Configuration: local.xml
    <config>
        <global>
     
            <!-- other configuration nodes -->
            
            <!-- example of redis cache -->
            <cache>
                <backend>Cm_Cache_Backend_Redis</backend>
                <backend_options>
                    <server>127.0.0.1</server> <!-- or absolute path to unix socket for better performance -->
                    <port>6379</port>
                    <database>0</database>
                    <password></password>
                    <force_standalone>0</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->
                    <connect_retries>1</connect_retries>    <!-- Reduces errors due to random connection failures -->
                    <automatic_cleaning_factor>0</automatic_cleaning_factor> <!-- Disabled by default -->
                    <compress_data>1</compress_data>  <!-- 0-9 for compression level, recommended: 0 or 1 -->
                    <compress_tags>1</compress_tags>  <!-- 0-9 for compression level, recommended: 0 or 1 -->
                    <compress_threshold>20480</compress_threshold>  <!-- Strings below this size will not be compressed -->
                    <compression_lib>gzip</compression_lib> <!-- Supports gzip, lzf and snappy -->
                    <persistent>1</persistent> <!-- persistence value, 0: not in use, > 0 used as persistence ID -->
                </backend_options>
            </cache>
    
            <!-- example of redis full page cache -->
            <full_page_cache>
                <backend>Cm_Cache_Backend_Redis</backend>
                <backend_options>
                    <server>127.0.0.1</server> <!-- or absolute path to unix socket for better performance -->
                    <port>6379</port>
                    <database>1</database>
                    <password></password>
                    <force_standalone>0</force_standalone>  <!-- 0 for phpredis, 1 for standalone PHP -->
                    <connect_retries>1</connect_retries>    <!-- Reduces errors due to random connection failures -->
                    <automatic_cleaning_factor>0</automatic_cleaning_factor> <!-- Disabled by default -->
                    <!-- in FPC data is already gzipped, no need to do this twice -->
                    <compress_data>0</compress_data>  <!-- 0-9 for compression level, recommended: 0 or 1 -->
                    <compress_tags>1</compress_tags>  <!-- 0-9 for compression level, recommended: 0 or 1 -->
                    <compress_threshold>20480</compress_threshold>  <!-- Strings below this size will not be compressed -->
                    <compression_lib>gzip</compression_lib> <!-- Supports gzip, lzf and snappy -->
                    <lifetimelimit>43200</lifetimelimit> <!-- set lifetime for keys without TTL -->
                    <persistent>2</persistent>
                </backend_options>
            </full_page_cache>
    
            <!-- example of redis session storage -->
            <session_save>db</session_save>
            <redis_session>                       <!-- All options seen here are the defaults -->
                <host>127.0.0.1</host>            <!-- Specify an absolute path if using a unix socket -->
                <port>6379</port>
                <password></password>             <!-- Specify if your Redis server requires authentication -->
                <timeout>2.5</timeout>            <!-- This is the Redis connection timeout, not the locking timeout -->
                <persistent></persistent>         <!-- Specify unique string to enable persistent connections. E.g.: sess-db0; bugs with phpredis and php-fpm are known: https://github.com/nicolasff/phpredis/issues/70 -->
                <db>0</db>                        <!-- Redis database number; protection from accidental loss is improved by using a unique DB number for sessions -->
                <compression_threshold>2048</compression_threshold>  <!-- Set to 0 to disable compression (recommended when suhosin.session.encrypt=on); known bug with strings over 64k: https://github.com/colinmollenhour/Cm_Cache_Backend_Redis/issues/18 -->
                <compression_lib>gzip</compression_lib>              <!-- gzip, lzf or snappy -->
                <log_level>1</log_level>               <!-- 0 (emergency: system is unusable), 4 (warning; additional information, recommended), 5 (notice: normal but significant condition), 6 (info: informational messages), 7 (debug: the most information for development/testing) -->
                <max_concurrency>6</max_concurrency>                 <!-- maximum number of processes that can wait for a lock on one session; for large production clusters, set this to at least 10% of the number of PHP processes -->
                <break_after_frontend>5</break_after_frontend>       <!-- seconds to wait for a session lock in the frontend; not as critical as admin -->
                <break_after_adminhtml>30</break_after_adminhtml>
                <bot_lifetime>7200</bot_lifetime>                    <!-- Bots get shorter session lifetimes. 0 to disable -->
            </redis_session>
            <!-- other configuration nodes -->
     
        </global>
    </config>
    
    

    external by Mehmet Emin Uygur  5  0  1  0

    Magento1 Reviews List for a Category

    Magento1 Reviews List for a Category: reviewsForCategory.php
    <?php 
        $_category = // INITIALIZED CATEGORY etc Mage::registry('current_category') or Mage::getModel('catalog/category)->load(##CATID##);
          
        $productCollection = Mage::getResourceModel('catalog/product_collection')
            ->addCategoryFilter($_category)
            ->getAllIds();
    
        $reviewcollection = Mage::getModel('review/review')->getCollection()
            ->addStoreFilter(Mage::app()->getStore()->getId())
            ->addStatusFilter(Mage_Review_Model_Review::STATUS_APPROVED)
            ->addFieldToFilter('entity_id', Mage_Review_Model_Review::ENTITY_PRODUCT)
            ->addFieldToFilter('entity_pk_value', array('in' => $productCollection))
            ->setDateOrder()
            ->addRateVotes();
    
        $items = $reviewcollection->getItems();
    ?>
    
    <?php if (count($items)):?>
    
    <div class="box-collateral box-reviews" id="customer-reviews">    
            <h2><?php echo $this->__('Customer Reviews') ?></h2>
            <?php echo $this->getChildHtml('toolbar') ?>
            <ol>
            <?php foreach ($items as $_review):?>
                <li>
                    <?php 
                        $_product = Mage::getModel('catalog/product')->load($_review['entity_pk_value']);
                        $image_link = Mage::helper('catalog/image')->init($_product, 'small_image')->resize(65,65);
                    ?>
                    <div class="avatar-image" img="<?php echo $image_link; ?>">
                        <?php /*<img src="<?php echo Mage::getDesign()->getSkinUrl("images/avatar.jpg"); ?>" width="65" height="65"/> */;?>
                        <a href="/<?php echo $_product->getUrlPath();?>"><img src="<?php echo $image_link;?>"></a>
                    </div>
                    <div class="review-area">
                        <strong class="review-title"><?php echo $this->htmlEscape($_review->getTitle()) ?></strong>
                        <span class="review-by"> <?php echo $this->__('review by %s', "<b>".$this->htmlEscape($_review->getNickname())."</b>") ?> <?php echo $this->__('on %s', $this->formatDate($_review->getCreatedAt()), 'long') ?></span>
                        <div class="ratings-list">
                        <?php foreach ($_review->getRatingVotes() as $_vote): ?>
                            <div class="rating-item">
                                <span class="label"><?php echo $_vote->getRatingCode() ?></span>
                                <div class="rating-box">
                                    <div class="rating" style="width: <?php echo $_vote->getPercent() ?>%;"></div>
                                </div>
                            </div>
                        <?php endforeach; ?>
                        </div>
                        <p><?php echo nl2br($this->htmlEscape($_review->getDetail())) ?></p>
                    </div>
                    <div class="clearer"></div>
                </li>
            <?php endforeach; ?>
        </ol>
        
    </div>
    
    <?php endif;?>
    
    
    • Public Snippets
    • Channels Snippets