Add code

Thursday 8 October 2020

New order confirmation email is not being sent on Magento website

We have 2 methods to send the confirmation emails from our Magento 1 website.

  1. Using Cron
  2. Avoiding Cron

If you want to avoid the Cron :

Open the file order.php file from the following path:

app/code/core/Mage/Sales/Model/Order.php

Line#1356,1450

Change the following

    //$mailer->setQueue($emailQueue)->send(); 

to the following:

    $mailer-> send();

In the following path `app/design/frontend/base/default/template/checkout/success.phtml`:

add the following line Top success page for sending mail direct

    $order = Mage::getModel('sales/order');

    $incrementId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); 

    $order->loadByIncrementId($incrementId);

    try{ 

    $order->sendNewOrderEmail();

    } catch (Exception $ex) { 

    echo "Email Not Sent..."; 

    }

    $customer = Mage::getSingleton('customer/session')->getCustomer();

    $email = $customer->getEmail();

    //End Email Sending

Friday 2 October 2020

Magento 2: How to remove decimal points from the price

 You need to override vendor/magento/module-catalog/view/base/web/js/price-utils.js and change the value of precision on line 38:

from

    var precision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision,

to

    var precision = 0

Magento2: How to get list of category's dropdown attributes?

Let's say that `$category` is the instance of the current category;


    $collection = $category->getProductCollection()->addAttributeToSelect(['manufacturer', 'color']);

    $manufacturers = [];

    $colors = [];

    foreach ($collection as $product) {

        $manufacturer = $product->getData('manufacturer');

        if ($manufacturer && !isset($manufacturers[$manufacturer])) {

             $manufacturers[$manufacturer] = $product->getAttributeText('manufacturer');

        }

        $color = $product->getData('color');

        if ($color && !isset($colors[$color])) {

             $colors[$color] = $product->getAttributeText('color');

        }

    }


after this, `$manufacutrers` and `$colors` should contain all the values you need. The key is the id, and the value is the option label.  

But this may cause performance issues if you have a large product collection.

Thursday 1 October 2020

What is Magento ?

  1.  Magento is an open-source e-commerce platform written in PHP.
  2. It uses multiple other PHP frameworks such as Laminas and Symfony.
  3. Magento source code is distributed under Open Software License v3.0.
  4. Magento was acquired by Adobe Inc in May 2018 for $1.68 Billion USD.

Initial release date31 March 2008
Developer(s)Magento, Inc
LicenseOSL v3, AFL v3

How do I find my Magento Theme name?

Look at the HTML source in your browser ("View Source") and search for skin/frontend, which is followed by PACKAGE/THEME, where PACKAGE is usually the name of the theme and THEME is usually default or contains site-specific changes.

Which version of Magento is best?

 Magneto 2 runs approximately 20% faster than Magento 1, which can lead to improved SEO and increased sales. All of the content from a static page can be cached, thus increasing site performance and drastically reducing the server load. This makes the Magento 2 platform more scalable for large eCommerce stores.

Wednesday 30 September 2020

Magento 1.9 Import products issue

Question:

I am trying to import some products, Magento performs everything right, but when I look at the catalog, there is no imported product     

    Starting profile execution, please wait...

         Warning: Please do not close the window during importing/exporting data
         Starting Mage_Dataflow_Model_Convert_Parser_Csv :: parse
         Found 453 rows.
         Starting catalog/convert_adapter_product :: parse
        Processed 100% 453/453 records
        Imported 453 records
         Please wait while the indexes are being refreshed.
         Finished profile execution.

The message below shows that it was 100% successful, but there is no product.

One Possible Solution:

It seems a Re-index issue.

Please run the following commands

    php bin/magento indexer:reindex

    php bin/magento cache:flush

Thursday 31 May 2018

Magento 1 : Hide other shipping methods when free shipping is available

To prevent other shipping options to display when Free Shipping is available, add the following code to your template:



Open :
/app/design/frontend/[Your_package]/[Your_theme]/template/checkout/onepage/shipping_method/available.phtml




<?php
if ( array_key_exists('freeshipping', $_shippingRateGroups )) {
unset($_shippingRateGroups["flatrateperproduct"]);
}
?>

Then ,  flatrateperproduct Method will be remove from the shipping method.

Tuesday 15 May 2018

How to add Buy Now At Product Page in Magento - 1 version ?

If you want both Add to Cart and Buy now, add the buy now button to addtoCart.phtml

Go to
/app/design/frontend/[package name]/[themename]/template/ajaxcart/catalog/product/view/addtoCart.phtml

<button type="button" 
        title="<?php echo $buttonTitle ?>"
        class="button btn-cart" 
        onclick="productBuyNowForm.submit(this)">
    <span><span>Buynow</span></span>
</button>

On that buttons onlick event, a custom VarienForm is used, productBuyNowForm.submit(this), which will submit this form and redirect to checkout onepage.

To define this custom form, add the following JavaScript code at view.phtml

Go to
/app/design/frontend/[package name]/[theme name]/template/catalog/product/view.phtml

<script>
var productBuyNowForm = new VarienForm('product_addtocart_form');
productBuyNowForm.submit = function (button, url) {
    if (this.validator.validate()) {
        var form = this.form;
        var oldUrl = form.action;
        alert(form.action);
        if (url) {
            form.action = url;
        }

        /* add return Url */
        var inputreturn= document.createElement("input");
        inputreturn.type = "hidden";
        inputreturn.name = "return_url";
        inputreturn.value = "<?php echo Mage::getUrl('checkout/onepage')?>";
        document.getElementById('product_addtocart_form').appendChild(inputreturn);
        /* add return Url */
        // Append a line break 
        var e = null;
        try {
            this.form.submit();
        } catch (e) {
        }
        this.form.action = oldUrl;
        if (e) {
            throw e;
        }

        if (button && button != 'undefined') {
            button.disabled = true;
        }
    }
}.bind(productBuyNowForm);

</script>

Saturday 1 July 2017

How to add custom attribute for category

Follow bellow steps

Step : 1 app\etc\modules\TEJA_Dbchange.xml

    <?xml version="1.0"?>
    <config>
        <modules>
            <TEJA_Dbchange>
                <active>true</active>
                <codePool>local</codePool>
            </TEJA_Dbchange>
        </modules>
    </config>

Step : 2 app\code\local\TEJA\Dbchange\etc\config.xml

    <?xml version="1.0"?>
    <config>
        <modules>
            <TEJA_Dbchange>
                <version>0.1.0</version>
            </TEJA_Dbchange>
        </modules>
        <global>
            <resources>
                <teja_dbchange_setup>
                  <setup>
                       <module>TEJA_Dbchange</module>
                       <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
                  </setup>
              </teja_dbchange_setup>
            </resources>
        </global>
    </config>

Step : 3 app\code\local\TEJA\Dbchange\sql\teja_dbchange_setup\mysql4-install-0.1.0.php

    <?php
 
    $installer = $this;
    $installer->startSetup();
       
    $attribute  = array(
        'group'                     => 'General',
            'input'                     => 'select',
            'type'                      => 'int',
            'label'                     => 'Testing',
            'source'                    => 'eav/entity_attribute_source_boolean',
            'global'                    => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_GLOBAL,
            'visible'                   => 1,
            'required'                  => 0,
            'visible_on_front'          => 0,
            'is_html_allowed_on_front'  => 0,
            'is_configurable'           => 0,
            'searchable'                => 0,
            'filterable'                => 0,
            'comparable'                => 0,
            'unique'                    => false,
            'user_defined'              => false,
            'default'           => '0',
            'is_user_defined'           => false,
            'used_in_product_listing'   => true
    );
    $installer->addAttribute('catalog_category', 'testing', $attribute);
    $installer->endSetup();
 
    ?>

Step : 4 After refresh all magento cache by going System -> Cache Management
Step : 5 Logout  and login again.

Wednesday 21 June 2017

What is the difference between convention and configuration?

  1. Configuration - would have been manually mapping controllers to use specific views, almost like a code behind scenario.
  2. Convention - A Controller method named Index most likely wants to use a View called the same, so the framework goes and looks for that.

Wednesday 14 June 2017

Difference among Order Invoice, Cancel, Void, Hold and Ship in Magento

Pending. - Placing new order. it is default status is pending

Processing - You are raise a invoice from Magento admin status is change to

On Hold - This status can only be assigned manually. You can put any order on hold.

Cancelled - This status is assigned manually by you or, on some payment gateways, when customer does not pay within the specified time.

Complete - This status means that order is crated, paid and shipped to customer.

Closed - Closed orders are orders that have had a credit memo assigned to it and the customer has been refunded for their order.

Pending Payment - This is the status used if order is created and PayPal or similar payment method is used. This means that customer has been sent to payment gateway website but no return information has been received yet. This status will change when customer pays. Some gateways do cancel abandoned orders automatically after some 'idle' time. If order had this status for a long time, you should cancel it manually to free product stock.

Magento : 404 error is showing admin page

Hello, Sometimes we may get the error on admin page once done with the Magento installation. In that scenario, we have to do the following: ...