Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

Magento 2, Magento Development, Customization, Extension Development and Integration, Optimization, SEO and Responsive Design

How to extract zip files on ftp server using php script

We are not able to extract zip file in FTP. So we must need to connect control panel for extracting zip file.
If you want to extract your zip file on sever without opening your control panel you can you this simple php script.

class zlib_class {
     private $log_class = NULL;
     public function extractContents($source_file, $destination)
    {
           echo "in";
           $retval = false;
           $zip = new ZipArchive;
           if ($zip->open($source_file) === true)
          {
                 if ($zip->extractTo($destination))
                {
                     echo "if";
                     $retval = true;
                 }
                 else
                {
                        $error = array(
                        "error_class" => "zlib_class",
                        "error_code" => -2,
                        "error_description" => "Destination file could not be created."
                         );
                }
                $zip->close();
               }
               else
               {
                      $error = array(
                      "error_class" => "zlib_class",
                      "error_code" => -1,
                      "error_description" => "Source file could not be opened."
                      );
               }
               echo $retval;
               die();
               return $retval;
       }
}

$zip = new zlib_class();
if ($zip->extractContents("magento-1.7.0.2.zip","demo"))
{
         $output = array("task" => "Zip extraction completed.");
         //$log_class->logEvent($output);
}
else
{
         print("gotoskateorgohome.com Cron: Failure (2)");
}

How to get wishlist collection in Magento


If you want to get all details of your wishlist product to anywhere in your magento you can get it easily.
For that you need to get current login user details like user name or user id, because we can load wishlist collection from user id, that is why we first we must need to get login details from session.

<?php
 $customer = Mage::getSingleton('customer/session')->getCustomer();
 if($customer->getId())
{
     $wishlist = Mage::getModel('wishlist/wishlist')->loadByCustomer($customer, true);
     $wishListItemCollection = $wishlist->getItemCollection();
     foreach ($wishListItemCollection as $item)
     {
           echo $item->getName()."</br>";
           echo $item->getId()."</br>";
           echo $item->getPrice()."</br>";
           echo $item->getQty()."</br>"; 
           $item = Mage::getModel('catalog/product')->setStoreId($item->getStoreId())->load($item->getProductId());
          if ($item->getId()) :
?>
<img src="<?php echo Mage::helper('catalog/image')->init($item, 'small_image')->resize(113, 113); ?>" width="113" height="113" />
<?php endif; } } ?>

jQuery Print Specific div Content demo


You can see here how this example work for printing Specific div content. If you want to implement this you need to check my previous post.


Div you want to print. Only this div will be printed when you click on print button.
This will not be printed.
Nor will this.


Magento jquery Image slider Demo


This is the demo of magento jQuery simple images slider. If you want to implement this in your site, check the following post there is a step by step explanation given.

Image slider for Magento

  • Magento blog demo of images slider
  • Magento blog demo of images slider
  • Magento blog demo of images slider
  • Magento blog demo of images slider
  • Magento blog demo of images slider
  • Magento blog demo of images slider

Get Simple product details of configurable products like ID, SKU, Product Name

If you want to get Simple product details of configurable product like simple product Id, sku, product name etc. you can get using my simple module.

Magento Simple product details of configurable products

Before using this module you need to add simple script for getting simple product id from configurable product. Check my previous post Get Simple product of configurable product.

In that script you just need to change following ajax code instead of alert box.
Note: You must need to add jQuery library in your page if library is not already added before using ajax code.

jQuery.ajax({
    type: "POST",
    url: "<?php echo $this->getBaseUrl()?>productdetails/index/optiondetails/",
    data:"id="+currentSimpleProductId,
    success: function(msg)
    {
        alert(msg);
        //var data = JSON.parse(msg);
        //alert(data.id);
    }
});

Download Source

How to add custom qty field to custom option of simple product magento

By default in magento there is no qty field of simple product for custom option. If you want to add qty as per your custom option you can add now using this post.

Suppose you have custom option 'Color: Red, Blue, White' of your simple product and you want to add different qty option for your color option you can do it now.

magento custom options quantity

1. go to app\design\adminhtml\default\default\template\catalog\product\edit\options\type\select.phtml

Find the below code:
'<th class="type-sku"><?php echo Mage::helper('catalog')->__('SKU') ?></th>'+

Now add following code just after above code.
'<th class="type-qty"><?php echo Mage::helper('catalog')->__('Qty') ?></th>'+

Find the below code:
'<td><input type="text" class="input-text" name="product[options][{{id}}][values][{{select_id}}][sku]" value="{{sku}}"></td>'+

Now add following code just after above code.
'<td><input type="text" class="input-text" name="product[options][{{id}}][values][{{select_id}}][qty]" value="{{qty}}"></td>'+

2. go to app\code\core\Mage\Adminhtml\Block\Catalog\Product\Edit\Tab\Options\Option.php

Find the below code:
$value['sku'] = $this->htmlEscape($option->getSku());

Now add following code just after above code.
$value['qty'] = $this->htmlEscape($option->getQty());

Find the below code:
'sku' => $this->htmlEscape($_value->getSku()),

Now add following code just after above code.
'qty' => $this->htmlEscape($_value->getQty()),

3. Add field in “catalog_product_option_type_value” table
`qty` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'Qty',

Now clear your cache and check in you magento admin. You can hit below if post is help full for you.

 

Copyright @ 2017 HKBlog.