Monday, 16 May 2016

Magento : Default to the first item for all required options

Stick the code into 

app/design/frontend/default/theme/template/catalog/product/view/options.phtml

near the end of the file look for this line: 


var opConfig = new Product.Options(<?php echo $this->getJsonConfig() ?>);


and replace with this:


var opConfig = new Product.Options(<?php echo $this->getJsonConfig() ?>);Event.observe(window'load', function() {$$('.product-options select').each(function(element{
element
.selectedIndex 1;opConfig.reloadPrice();});});


Refresh cache and load a product on the frontend which has custom options - after the page loads an option should automatically be selected.

Magento : How to remove Custom Options +Price($10.00)



Using the comment from user "R.S" above I was able to fix this issue for my website. Here is a screenshot from my website showing the fix works






Find the file
/app/code/core/Mage/Catalog/Block/Product/View/Options/Type/Select.php
Go to lines 70 - 74
Remove this code from line 72
. ' ' . $priceStr . ''
OR comment out the code
$_value->getTitle() /*. ' ' . $priceStr . ''*/,
be sure to leave the "," at the end of the statement. My code now looks like this and works fine.
$select->addOption(
              $_value->getOptionTypeId(),
                $_value->getTitle() /*. ' ' . $priceStr . ''*/,
                array('price' => $this->helper('core')->currencyByStore($_value->getPrice(true), $store, false))
            );
I hope this helps you and other who are looking for the same fix!

Saturday, 7 May 2016

Magento : Unknown cipher in list: TLSv1 [duplicate]




Go to downloader/lib/Mage/HTTP/Client/Curl.php,

            Edit Curl.php in notepad++ go line no. 377 or find

$this->curlOption(CURLOPT_SSL_CIPHER_LIST, 'TLSv1');

    to

$this->curlOption(CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);

Done! :)

Saturday, 23 April 2016

Magento : STOCK QUANTITY ON MAGENTO PRODUCT PAGE

Warning: This is a quick-n-dirty hack and will not work on all product types.

Instead of just showing the “in stock” and “out of stock” messages, we want to have an in-between message to show that stock levels are running low. This is easily done, by editing the following file:

app/design/frontend/base/default/template/catalog/product/view/type/default.phtml

We change the contents of the file to the following:

<?php
$_product = $this->getProduct();
$_quantity = intval(Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty());
?>

<?php if ($_product->isAvailable()): ?>
  <?php if ( intval($_quantity) < 10 ): ?>
    <p class="availability last-stock"><?php echo $this->__('Availability:') ?>
      <span><?php echo $this->__('Only '); echo $_quantity; echo $this->__(" left"); ?></span>
    </p>
  <?php else : ?>
    <p class="availability in-stock"><?php echo $this->__('Availability:') ?>
      <span><?php echo $this->__('In stock') ?></span>
    </p>
  <?php endif; ?>
<?php else: ?>
  <p class="availability out-of-stock"><?php echo $this->__('Availability:') ?>
    <span><?php echo $this->__('Out of stock') ?></span></p>
<?php endif; ?>

<?php echo $this->getChildHtml('product_type_data_extra') ?>
<?php echo $this->getPriceHtml($_product) ?>


That’s it!

We just created a warning-type level once stock drops to less than 10 items. Meanwhile, both the “in-stock” and “out-of-stock” messages are preserved. This can be easily styled using CSS. Note we added the class “last-stock” to our new p-tag

Magento : Disable/ Remove “Estimate Shipping and Tax”

We can solve this issue two way.
First way :
Create local.xml file with below code and upload your theme layout folder
<?xml version=”1.0″ encoding=”UTF-8″ ?>
<layout>
<checkout_cart_index>
<reference name=”content”>
<block name=”checkout.cart”>
<remove name=”checkout.cart.shipping”/>
</block>
</reference>
</checkout_cart_index>
</layout>
Second way :
Remove the following code from /app/design/frontend/yourtheme/layout/checkout.xml
<block type=”checkout/cart_shipping” name=”checkout.cart.shipping” as=”shipping” template=”checkout/cart/shipping.phtml”/>
Done! :)

Sunday, 20 March 2016

Magento : How to Rename the Attribute Code?

Connect to your Magento database using your favourite database GUI (PHPMyAdmin, HeidiSQL, MySQL Workbench, etc.).
Caution: backup your database
Go to the table eav_attribute and edit the column attribute_code. You can rename the attribute code here.
Once you have renamed the attribute code in the database, go to the Magento admin and re-index (System > Index Management) all indexes.

Magento : Get Logged In Customer’s Group ID

<?php
/* Check if customer is logged in */
$isLoggedIn = Mage::getSingleton('customer/session')->isLoggedIn();
/* If customer is logged in */
if($isLoggedIn) :
    /* Get the logged in customer's group ID */
    $customerGroupId = Mage::getSingleton('customer/session')->getCustomerGroupId();
    /* Check if the logged in customer's group ID matches with the ID you are after */
    /* Customer group IDs are listed against each group under Admin > Customers > Customer Groups */
    if($customerGroupId == 3) :
        echo 'Welcome Retailer';
    endif;
endif;
?>

You can also write static blocks or custom variables to contain group specific information. You can name the static block identifier based on the $customerGroupId and retrieve it on the front end.