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
Showing posts with label Product Custom Option. Show all posts
Showing posts with label Product Custom Option. Show all posts

Product Custom Option (Pro) with Option Swatches

In my previous post there is a solution to display product custom option on list page.

Option Swatches For Magento 2

I have developed new module Option swatches that allow to display option swatches on product details page and product list page by replacing drop-down custom options or configurable product's options.

Product Custom Option (Pro) with Option Swatches

Using Option swatches you can directly add your product to cart from list page with selected option, no need to go on product detail page.


Product Custom Option (Pro) with Option Swatches

Option swatches convert product's custom option such as color, size etc. into thumbnail images.
It will also display your configurable product drop-down into thumbnail images on product details page.

Product Custom Option (Pro) with Option Swatches


Option swatches is compatible with Magento version 1.5 to 1.8.

If you are using Magento 1.9, Contact us to get the code for your vesrion or you can download module source here.

I would love to hear your feedback about this extension.

If you are using Magento 2, Download my latest extension for Magento 2.

Option Swatches For Magento 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; } } ?>

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.

How to Get Product Custom Option In Product Listing Page in Magento


Using this post you can set your product custom option on product listing page. If you want to show available product custom option on you product listing page or category page to your customer, you can easily do using this post. 

You can set your custom options like color, size etc. to your product listing page or category page. You can also add your product to cart with selected option from list page. For that you just need to change in your list.phtml file of your current THEME. There is no need to change in your php file. 

Our module is also available on magento connect for free. You can download here.
Check our latest module  Product Custom Option (Pro)

How to Get Product Custom Option In Product Listing Page in Magento

Add following code in your list.phtml after <?php $i=0; $h=0; foreach ($_productCollection as $_product): ?> line:

<?php
     //$productSku = $_product->getSku();
     //$product = Mage::getModel('catalog/product');
     //$productId = $product->getIdBySku( $productSku );
     $product = Mage::getModel("catalog/product")->load($_product->getId());
     $attVal = $product->getOptions();
     $optStr = "";
?>

Replace <div class="actions"> with following code in same page.

<div class="actions">
<?php if($_product->isSaleable()):?>
 <form action="<?php echo $this->helper('checkout/cart')->getAddUrl($_product)?>" method="post" id= "product_addtocart_form" <?php if($_product->getOptions()):?> enctype="multipart/form-data"<?php endif;?>>
<div style='float: left; width: 100px;'>
 <?php foreach($attVal as $optionKey => $optionVal)
{
     $optStr.= "<select style='display:block; clear:both;' name='options[".$optionVal->getId()."]'>";           foreach($optionVal->getValues() as $valuesKey => $valuesVal)
{
      $optStr.= "<option value='".$valuesVal->getId()."'>".$valuesVal->getTitle()."</option>";
}
$optStr.= "</select>";
}
echo($optStr );?>

 <!--Change click action in button -->
 <button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="this.form.submit();"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
</div>
<?php else:?>
     <p class="availability out-of-stock"><span><?php echo $this->__('Out of stock')?></span></p>
 <?php endif;?>
<ul class="add-to-links">
<?php if ($this->helper('wishlist')->isAllow()) :?>
<li>
     <a href="<?php echo $this->helper('wishlist')->getAddUrl($_product)?>" class="link-wishlist">
            <?php echo $this->__('Add to Wishlist')?>
     </a>
</li>
<?php endif;?>
<?php if($_compareUrl=$this->getAddToCompareUrl($_product)):?>
<li>
     <span class="separator">|</span>
     <a href="<?php echo $_compareUrl?>" class="link-compare"><?php echo $this->__('Add to     Compare')?>
     </a>
</li>
<?php endif;?>
</ul>
 </form>
 </div>

I would love to hear from you about this post!


 

Copyright @ 2017 HKBlog.