working on it ...

Filters

Explore Public Snippets

Sort by

Found 2,247 snippets matching: magento

    public by shebin512  937116  3  6  0

    Product Listing in Magento using SKUs

    Code to fetch Products in collection and useing SKU's and display the products
    <html>
      <body>
    <?php
    /**
    * Code to fetch Products in collection and useing SKU's and  display the products
    *
    */
    $pCollection = Mage::getModel('catalog/product')
        ->getCollection()
        ->addAttributeToFilter(
            'sku',
            array('in' => array(
    			    18811601,51361203,51360601,18811602,51361201,83545603,18811603// Test Sku's
            	//18807601,18807603,10264601,18792202,  83527701, 56821204// sku dev setup
    			  )
    		  )
        )	
        ->addAttributeToSelect('price')
        ->addAttributeToSelect('name')
        ->addAttributeToSelect('image')
    	  ->addAttributeToSelect('special_price');
    	  
    	  //Media model to fetch Image URL
    	  $productMediaConfig = Mage::getModel('catalog/product_media_config');
    	  ?>
    	  <div class="product-list owlCarousel">
    		<?php
    				if (count($pCollectionBolt)>0){
    					foreach ( $pCollectionBolt as $_product) {
                //Mage::Helper('training')->getProductDetails($_product); You can use helper to display the product details as you Wish
                //I'm adding code here itself
                $_pSku = $_product->getSku();
                $_pName = $_product->getName();
                $_pUrl = $_product->getProductUrl();
                $_pImageUrl = Mage::helper('catalog/image')->init($_product, 'image');
                //$_pPrice = $_product->getPrice();
                $_pPrice = $_product->getFinalPrice();
                echo "<div><a href='".$_pUrl."'><img src='".$_pImageUrl."' alt='".$_pName."' /></a>
                    <div class='productname-price'><a href='".$_pUrl."' style='min-height:0px;'>".$_pName."</a><span>&#8377;".$_pPrice."</span></div>
                  </div>";
    					}
    				}else{
    					echo "<span style='text-align:center'>No products in the List</span>";
    				}
    			?>
    		</div>
    	</body>
    </html>            

    public by fadzly  445746  70  5  0

    Magento - custom table join product eav table in a grid

    protected function _prepareCollection()
        {
    		//to join normal attributes; but not sku, type_id and others (see catalog_product_entity database table)
    		$productAttributesArray = array('product_name' => 'name', 'product_seller' => 'seller', 'product_supplier' => 'supplier');
    		$poTempModel = Mage::getModel('mymodule/modelone')->load($this->getRequest()->getParam('id'),'actual_id');
    		$collection = Mage::getModel('mymodule/modeltwo')->getCollection()->addFieldToFilter('parent_id',$poTempModel->getId());
    		foreach ($productAttributesArray as $alias => $attributeCode)
    		{
        		$tableAlias = $attributeCode . '_table';
        		$attribute = Mage::getSingleton('eav/config')->getAttribute(Mage_Catalog_Model_Product::ENTITY, $attributeCode);
    			//Add eav attribute value
        		$collection->getSelect()
    							->joinLeft(
    								array($tableAlias => $attribute->getBackendTable()),
    								"main_table.product_id = $tableAlias.entity_id AND $tableAlias.attribute_id={$attribute->getId()}",
    								array($alias => 'value')
    							);
        	}
    		//to join entity attributes such sku, type_id
    		$collection->join(
                'catalog/product',
                'product_id = `catalog/product`.entity_id',//note the ` . DO NOT USE '
                array('sku' => 'sku')
            );
    		$this->setCollection($collection);
    		return parent::_prepareCollection();
        }
    	
    	protected function _prepareColumns()
    	{
    		$this->addColumn('position', array(
    			'header'=> 'Position',
    			'width' => '50px',
    			'type'  => 'number',
    			'index'=>'position',
    			'sortable' => false
    		));
    		$this->addColumn('product_name', array(
    			'header'=> 'Name',
    			'type'  => 'text',
    			'index'=>'product_name',
    			'sortable' => false
    		));
    		$this->addColumn('sku', array(
    			'header'=> 'SKU',
    			'type'  => 'text',
    			'index'=>'sku',
    			'sortable' => false
    		));
    		$this->addColumn('poitemtemp_id', array(
    			'header'=> 'Action',
    			'align'	=> 'center',
    			'type'  => 'number',
    			'index'=>'poitemtemp_id',
    			'renderer' 	=> 'mymodule/adminhtml_editpo_elements_edit_gridscontainer_currentitemsrender',
    			'sortable' => false
    		));
    		return parent::_prepareColumns();
    	}            

    public by fadzly  209156  0  7  0

    Add product attribute to setup

    $catalog = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('catalog_setup');
    
    $catalog->addAttribute('catalog_product','pickuprate', array(
    		'type' => 'int',
    		'input'=> 'select',
    		'label' => 'Pick Up Rate',
    		'user_defined' => 1,
    		'required' => 0,
    		'group'=> 'Prices',
    		'source' => 'Marketplace_Mod_Model_Pickuprategrp'
    	));

    public by bobby  157341  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 simonwalker  99  0  3  0

    Magento 2 Customer Attributes Extension | FME

    Pursue a user experience design of the sign-up form by adding easy to answer attributes using Magento 2 Customer Attributes Extension. This extension empowers you to put 10 types of attributes on a registration form to intake data from users.Now the next thing is that you can apply validation on custom attributes to avoid errors while entering data
    // Enter here the actual content of the snippet.						

    public by shebin512  3037  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 simonwalker  265  1  5  0

    Magento 2 Call For Price Extension By FME

    Magento 2 Call for price extension allows you to hide product prices from selected user groups or store views. You can replace the price option with ‘Get a quote’ popup, an image, or an alternative page. Subsequently, you can hide other Calls-to-action like ‘Add to Cart’, ‘Add to Wishlist’, and ‘Add to compare.’ Set conditions to restrict the price
    // code here 						

    public by shebin512  5119  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            

    public by simonwalker  192  1  4  0

    Magento 2 Responsive E-Mail Template Extension By FME

    Magento 2 Email Templates extension helps you customize emails for better communication with the buyers and users of your eCommerce website. With 3 different themes, you can choose an appealing layout and design for the transactional emails. Magento email templates sets you free to select between Blue Lagoon, Black and Red Tux, and Orange Peak whic
    // Enter here the actual content of the snippet.						

    public by simonwalker  233  0  5  0

    Magento 2 Size Chart Extension By FME

    Magento 2 Size Chart extension allows you to display product size guide so that customers can select and order the right size. You can create, customize, and assign an unlimited number of size charts to your store items using Magento 2 size chart. Upload an image, enter data, or import size charts. Define rules to assign size charts to specific pro
    // Enter here the actual content of the snippet.												
    • Public Snippets
    • Channels Snippets