CSS Media Queries for iPads & iPhones

Sometimes we got very confusion while developing responsive work. When we apply the breakpoints for iPad and iPhone that does not works properly. As per my experience while searching on the Internet I found some useful information regarding the media queries. I applied those and that works fine for me. So today I am going to add the media queries here for the same.

iPad Media Queries

iPad Media Queries (All generations – including iPad mini)

 

iPad in portrait & landscape


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px) { /* STYLES GO HERE */}

iPad in landscape


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape) { /* STYLES GO HERE */}

iPad in portrait


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait) { /* STYLES GO HERE */ }

Retina iPad in landscape


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 2) { /* STYLES GO HERE */}

Retina iPad in portrait


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait)
and (-webkit-min-device-pixel-ratio: 2) { /* STYLES GO HERE */ }

iPad mini Media Queries

iPad mini in portrait & landscape


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (-webkit-min-device-pixel-ratio: 1) { /* STYLES GO HERE */}

iPad mini in landscape


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : landscape)
and (-webkit-min-device-pixel-ratio: 1) { /* STYLES GO HERE */}

iPad mini in portrait


@media only screen
and (min-device-width : 768px)
and (max-device-width : 1024px)
and (orientation : portrait)
and (-webkit-min-device-pixel-ratio: 1) { /* STYLES GO HERE */ }

iPad mini Resolution


Screen Width = 768px (CSS Pixels)
Screen Height = 1024px (CSS Pixels)

Screen Width = 768px (Actual Pixels)
Screen Height = 1024px (Actual Pixels)

Device-pixel-ratio: 1

iPhone Media Queries

iPhone 6 Media Queries

iPhone 6 in portrait & landscape


@media only screen
and (min-device-width : 375px)
and (max-device-width : 667px) { /* STYLES GO HERE */}

iPhone 6 in landscape


@media only screen
and (min-device-width : 375px)
and (max-device-width : 667px)
and (orientation : landscape) { /* STYLES GO HERE */}

iPhone 6 in portrait


@media only screen
and (min-device-width : 375px)
and (max-device-width : 667px)
and (orientation : portrait) { /* STYLES GO HERE */ }

How to Change Magento 2 Favicon

Today I will show you how you can change favicon on magento2 site. Follow the below steps :

1- go to Content -> Design -> Configuration
2- Click on HTML Head settings tab
3- Upload your favicon and save configuration.
4- Refresh the Cache

How to Export Magento Product Database

In this tutorial I will show you how you can export entire Magento product database.
Most people can find their way to the standard Export options under System -> Import/Export, but that often doesn’t produce the results they’re expecting. A better approach is to use the Dataflow – Profiles that Magento provides. These out-of-the-box export “profiles” take care of a lot of the configurations you will need to make if you use the standard Magento Export option. Depending on the data you wish to export there are options for customers, products and stock.
In this post, we are going to look specifically at the Export All Products option.

We are going to use Magento Data-Profiles to Export your entire product database:

1-Navigate to System -> Import/Export -> Data-Profiles

2- Select Export All Products:

3- Review your options in the Profile Wizard. You may wish to change the name of your export file under File Information -> File Name.

4. To define which product attributes you wish to export for each product, under Profile Wizard -> Data Format -> Export you can choose to export All Fields, or select specific product attributes you wish to export by selecting Only Mapped Fields and selecting your required attributes.

5. To define a specific range of products you wish to export under Profile Wizard -> Export Filters -> you can filter your products by name, sku, product type, attribute set, price, stock quantity, visibility or status. Save and Continue Edit, and we’re ready to export.

6. Now that the parameters for your export are set, choose the Run Profile tab and click the Run Profile in Popup button. Your export will start automatically in a pop up window.

7. Once your export is complete, you now need to retrieve it from your server via SFTP. If you are unsure of how to connect to your server, please contact your hosting provider or web support. We recommend Filezilla as a good FTP program you could use.

8. Once logged into ftp, you will find you exported csv file waiting for you inside the var/export folder. Download the file, and there you have it!

How to put Magento in Maintenance Mode only for Front end

In this tutorial we will show you how to put your Magento online store in maintenance mode only for front end site. The admin can access the site without any issue

To put a Magento site in maintenance mode, you need to create an empty maintenance.flag file and upload it to the root folder of your site.

When you will upload maintenance.flag file then your website will be down and will show the error message

Service temporarily unavailable.

So for this message will show for all types of users. Now we will come to point and restrict the above message only for front users. For this follow the below instructions :

You need to replace the below code in index.php file (keep in mind when you will upgrade the site site then you must revert this process).

if (file_exists($maintenanceFile)) {
include_once dirname(__FILE__) . ‘/errors/503.php’;
exit;
}

To this

if (file_exists($maintenanceFile) && strpos($_SERVER[‘REQUEST_URI’], ‘/admin/’) === false) {
include_once dirname(__FILE__) . ‘/errors/503.php’;
exit;
}

Please note the the code above is quick and dirty hack and I just check if /admin/ exists in url. If you have another url then you should replace with that.

How to change sign-up fee text in WooCommerce Subscriptions

Try this:

function change_subscription_product_string( $subscription_string, $product, $include )
{
if( $include['sign_up_fee'] ){
$subscription_string = str_replace('sign-up fee', 'your text', $subscription_string);
}
return $subscription_string;
}
add_filter( 'woocommerce_subscriptions_product_price_string', 'change_subscription_product_string', 10, 3 );

Magento – Show Inventory Levels on Product Pages

Today I will show you how we can add Quantity on hand information on the product detail page.Normal Magento shows ‘Availability-In Stock’ by default. We need to change that Qty on hand like the below image

qtyonhand

For this you need to do the below steps :
Go to app/design/frontend/base/default/template/catalog/product/view/type/default.phtml.
Get a copy of that file and move it to your custom theme, making sure to add folders as needed to maintain the correct path. Here is the code snippet for adding Quantity on Hand to your product pages.

Replace below code

<?php if ($_product--->isAvailable()): ?>

with

<?php if ($_product--->isAvailable()): ?>
<?php $quantity1 = intval(Mage::getModel('cataloginventory/stock_item')--->loadByProduct($_product)->getQty()); ?>

<div class=”add-to-box”>

<?php if($quantity1 > 0) { ?>

<p class=”availability in-stock”>
<?php echo $this->__(‘Qty on Hand:’) ?>
<?php echo $quantity1;?>
</span>
</p>

<?php } elseif($quantity1 == 0) { ?>
<p class=”availability in-stock”><?php echo $this—>__(‘Qty on Hand:’) ?></p>
<?php foreach ($_product ->getTypeInstance(true)->getUsedProducts ( null, $_product) as $simple) { $stock = intval(Mage::getModel(‘cataloginventory/stock_item’)->loadByProduct($simple)->getQty()); echo $simple->getName().” “.$simple->getSize().” have a stock of $stock”; echo ‘<br>’; } ?>
</p>
<?php } ?>
</div>

How to change the Magento Admin URL

Here is a quick guide on how to change admin url path in Magento. To protect your Magento backend against hackers and brute-force attacks, we recommend that you change the default URL to the Magento Admin Panel is must. It is a quick and easy way to add an extra layer of security to your site.

Generally, Magento have ‘admin’ as the administrator path. So, the admin URL will be http://www.example.com/admin/

Here is process how you can do this :

1) Changing local.xml
– Open app/etc/local.xml
– Find the following:-

<admin>
<routers>
<adminhtml>
<args>
<frontName><![CDATA[admin]]></frontName>
</args>
</adminhtml>
</routers>
</admin>

– Go to this line
<frontName><![CDATA[admin]]></frontName>

and change “admin” as you desired the admin path like

<frontName><![CDATA[siteadmin]]></frontName>

and then upload file. After file update clear magento cache.

The process is now complete and you can login your magento with new url path

http://www.example.com/siteadmin/

Magento – Delete System Attribute

If you want to delete an attribute. But there is no delete option while you edit the attribute. This means that the attribute is system attribute. System attributes cannot be deleted. Only user defined attributes can be deleted.

To delete the attribute, you have to make it user defined. Follow the below instructions :

– Go to phpmyadmin
– Select magento database
– Go to eav_attribute table
– Browse table with attribute_code ‘YOUR_ATTRIBUTE_CODE’ OR browse the table with the attribute_id of your attribute (‘your attribute’ means the attribute which you want to remove as system attribute)
– Edit the table row of your attribute
– Find the field ‘is_user_defined’
– Set it to 1

Now your attribute no longer remains System Attribute
Now you can delete it from Attribute manager

Magento – Delete System Attribute

delete system attribute, magento system attribute

Magento – Show Inventory Levels on Product Pages

One of our client needed to display their actual quantity on hand inventory, rather that the normal ‘Availability-In Stock’. on product detail page. For this you need to look on this file.

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

If you do not have the above in the directory then you should copy that from the base folder and put in custom template. Approach the below code :

<?php if ($_product->isAvailable()): ?>
<?php $quantity1 = intval(Mage::getModel(‘cataloginventory/stock_item’)->loadByProduct($_product)->getQty()); ?>
<div class=”add-to-box”>
<?php if($quantity1 > 0) { ?>
<p class=”availability in-stock”>
<?php echo $this->__(‘Qty on Hand:’) ?>
<?php echo $quantity1;?>
</span>
</p>
<?php } elseif($quantity1 == 0) { ?>
<p class=”availability in-stock”>
<?php echo $this->__(‘Qty on Hand:’) ?><br/><br/><span>
<?php foreach ($_product->getTypeInstance(true)->getUsedProducts ( null, $_product) as $simple) {
$stock = intval(Mage::getModel(‘cataloginventory/stock_item’)->loadByProduct($simple)->getQty());
echo $simple->getName().” “.$simple->getSize().” have a stock of $stock”;
echo ‘<br/>’;
} ?></span>
</p>
<?php } ?>
</div>
<?php else: ?>
<p class=”availability out-of-stock”><?php echo $this->__(‘Availability:’) ?> <span><?php echo $this->__(‘Out of stock’) ?>

Fatal Error Declaration Of Zend Pdf FileParserDataSource File __construct in magento

If you will get this issue on magento while printing invoice pdf

Fatal Error: ‘Declaration of Zend_Pdf_FileParserDatasource_File::__contruct() must be compatible with Zend_Pdf_FileParderDatasource::__construct() in /…/lib/Zend/Pdf/FileParserDataSource/File.php

Then here is the simple solution.

Replace

abstract public function __construct();

to

abstract public function __construct($filePath);

in /lib/Zend/Pdf/FileParserDataSource.php