Add attribute name to configurable select option in Magento2?

Open the file

magento/vendor/magento/module-configurable-product/view/frontend/web/js/configurable.js

and find this line

element.options[0].innerHTML = this.options.spConfig.chooseText

repleace the line with below code

var attribute_lable = this.options.spConfig.attributes[element.id.replace(/[a-z]*/, '')]['label'];
element.options[0].innerHTML = this.options.spConfig.chooseText + attribute_lable;

On page load change dropdown label,
Open the file

vendor\magento\module-configurable-product\view\frontend\templates\product\view\type\options\configurable.phtml

and find the line

<option value=""><?= /* @escapeNotVerified */ __('Choose an Option...') ?></option>

repleace the line with below code

<?php 
$attrlabel = array();(Declared before loop)
$attrlabel[$i] = $_attribute->getProductAttribute()->getStoreLabel();?>
<option value=""><?phpecho 'Choose '.$attrlabel[$i];?></option>

How to get configurable attribute label and value in magento 2?

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$product = $objectManager->create('Magento\Catalog\Model\Product')->load(**product id**);

$productTypeInstance = $objectManager->get('Magento\ConfigurableProduct\Model\Product\Type\Configurable');
$productAttributeOptions = $productTypeInstance->getConfigurableAttributesAsArray($product);
foreach ($productAttributeOptions as $key => $value) {

    $tmp_option = $value['values'];
    if(count($tmp_option) > 0)
    {
        echo "<h3>".$value['label']."</h3>";
        echo "<select id='".$key."_".$value['label']."'>";
        foreach ($tmp_option as $tmp) 
        {
            echo "<option value='".$key."_".$tmp['value_index']."'>".$tmp['label']."</option>";
        }
        echo "</select>";
    }
}

Blank admin page after installing Magento 2

Step 1:

open file /vendor/magento/framework/View/Element/Template/File/Validator.php in magento install dir , find

$realPath = $this->fileDriver->getRealPath($path)

replace with :

$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));

Step 2:
open file app/etc/di.xml in magento install dir, find

agento\Framework\App\View\Asset\MaterializationStrategy\Symlink

and replace with

Magento\Framework\App\View\Asset\MaterializationStrategy\Copy

Step 3:
Then go to var/cache , delete all folder / file

Step 4:
refresh the page, done.

NGINX server SSL installation and SSL upgrade

Please follow the below steps to Install and Upgrade the SSL in nginx server:

Step1:  Open putty SSH

Step2: Redirect to Domain Config file to find / create the SSL key and SSL crt location.

Step3: Please follow the below step to find view/edit the domain config file.
 — Once logged into SSH.
 — From current folder, redirect to root folder using below comment.
     Comment:  cd ..
     Also, please check the below image.
    

—From root folder, redirect to /etc/nginx/conf.d folder to reach the domain.conf file.
    Comment: cd etc/nginx/conf.d

— From conf.d folder, list out the all files using below comment to find the domain config file name.
     Comment: ls -a (It will list all files)

— Edit the particular domain config file using below comment.
     Comment: vi domainname.com.conf

— It will open the Edit view, there we could add SSL key and SSL crt location and Edit. Files name should be domainname.com.crt and domainname.com.key
     Please find the below image for more information.

— Click i key to enable the insert mode to edit the file.
— Update the ssl_certificate and ssl_certificate_key path based on your need.
— Click “Esc” and “!wq” and “Enter” to save the changes.

— Create / Go to the SSL folder “etc/nginx/ssl” folder

— Create or edit certificate key file “domainname.com.key” and add the Privare key value as like below image and use below comment.
   Comment: vi domainname.com.key
                       Enable Insert using i key
                       Add private key
                       Click Esc key
                       Enter :wq and click Enter to save the file.
   As like below image.

— Same process to add three CERTIFICATE key in same file called “domainname.com.crt”.

— Finally restart the nginx server 
      Comments for Debian/Ubuntu/RHEL/CentOS Linux
      # /etc/init.d/nginx restart 
     OR
     # /etc/init.d/nginx reload
     OR
      # service nginx restart
      OR
      # service nginx reload

DONE!!!
 

Magento Migration One Domain to Another Domain

Step1: Change the ‘secure’ and ‘unsecure’ url in your database ‘core_config_data’ table’

Using Below query or Change manually:

UPDATE core_config_data SET value="http://newhost.com/" WHERE path="web/unsecure/base_url";
UPDATE core_config_data SET value="https://newhost.com/" WHERE path="web/secure/base_url";

 

Step2: Change the ‘local.xml’ file database configuration file path: yourdomain\app\etc

Note: Don’t Backup the local.xml file same folder,remove the older files in that folder.

Step3: Clear the cache and session folder

File path: yourdomain\var\cache, yourdomain\var\session

Step4: Change the .htaccess file configure

Notes:

1.Check the ‘Old Domain’ urls in your Full Database and Files and replace with ‘Live Url’.

2.Take your Old Database Backup with out old caches

3.Magento 1.9 version need the php5 and above version not php7

 

 

 

Windows server HTTP Error 500.50 – URL Rewrite Module Error while accessing the image

Hi All

We faced the problem while upload the image in windows server!

Image uploaded fine into server , but its not accessible from user-end through browser. Error displayed “500.50 – URL Rewrite Module Error

Reason:
The problem happens, when you use PHP to upload a file.  When you upload a file or image, PHP sends the file to a temporary directory on the hard drive (C:\Windows\Temp) and then copies it over to it’s intended directory(into site location).  Once the file has landed in the temporary directory, it is assigned the permissions of that directory. The problem is when Windows copies that file, it keeps the temporary directory’s permissions and doesn’t inherit your web directory’s permissions.

Solution:
1. Change the permissions on the temp folder(C:\Windows\Temp) giving IIS_IUSRS – write/modify. Find below image.

2. Change the path of the temp folder in the PHP.ini file to a folder that does have IIS_IUSRS write/modify permission.

windows temp folder permission change - 500.50 - URL Rewrite Module Error

Increase Upload File Size in PhpMyAdmin and WordPress

Increase the PhpMyAdmin Upload File Size  through php.ini file:

Step1:  xampp -> open php folder and select ‘php.ini’  file

Step2:  Increase memory limit find the word ‘memory_limit‘  in that  file and update the value ‘500M’

Step3: Increase post max size  find the word ‘post_max_size‘  in that  file and update the value ‘500M’

Step4: Increase upload max size  find the word ‘upload_max_filesize‘  in that  file and update the value ‘450M’

Step5:  Increase execution time find the word ‘max_execution_time‘  in that  file and update the value ‘3000’

Step6:   Increase input time find the word ‘max_input_time‘  in that  file and update the value ‘4000’

Step7: Save the file  and restart your xampp server

Increase the WordPress Upload File Size  through php.ini file:

memory_limit = 500M
post_max_size = 500M
upload_max_size = 500M
upload_max_filesize = 450M
max_input_time = 3000
max_execution_time = 3000
max_input_vars = 4000

Increase the WordPress Upload File Size  through .user.ini file:

memory_limit = 500M
post_max_size = 500M should be larger than upload_max_filesize and smaller than memory_limit.
upload_max_size = 500M
upload_max_filesize = 450M
max_input_time = 3000
max_execution_time = 3000
max_input_vars = 4000

Increase the WordPress Upload File Size  through wp-config.php file:

define( 'WP_MEMORY_LIMIT', '64M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' );

Increase the WordPress Upload File Size  through CPanel:

Step1:  cpanel-> ‘Software and Services’ ->  Select PHP Version

Step2:  Find php Version

Step3:  Find  upload_max_filesize’ option select box and change the value

Get latitude | longitude using address in Goolge Map

Step  1

Include  Google map api with  key and libraries
<script                                                                                                                                                                                                     src=”https://maps.googleapis.com/maps/api/js?key=AIzaSyAzXoaC9OV09c- sTdIWWR1hWzUcJppx_g8&libraries=places”></script>

Step 2

Create div tag for map with id

<div id=”location_map” style=”width:500px; height:500px;”></div>

Step 3

Create Address input field with latitude and longitude

<div>Address</div>
<div><input type=”text” name=”loc_address” id=”loc_address” value=”” style=”width:400px; height:40px;” /> </div>

<div>Latitude</div>
<div> <input type=”text” name=”loc_latitude” id=”loc_latitude” value=”” style=”width:300px; height:40px;” /> </div>

<div>Longitude</div>
<div> <input type=”text” name=”loc_longitude” id=”loc_longitude” value=”” style=”width:300px; height:40px;” /> </div>

Step  4

Include this script

<script>
Location_map();
function Location_map() {

var Loc_map = new google.maps.Map(document.getElementById(‘location_map’), {
center: {lat: 34.8375, lng: -106.2370},
zoom: 10
});
var location_input = (document.getElementById(‘loc_address’));

var autocomplete = new google.maps.places.Autocomplete(location_input);
autocomplete.bindTo(‘bounds’, Loc_map);

var loc_marker = new google.maps.Marker({
map: Loc_map,
anchorPoint: new google.maps.Point(0, -29)
});

autocomplete.addListener(‘place_changed’, function() {

loc_marker.setVisible(false);
var place = autocomplete.getPlace();

if (place.geometry.viewport) {

Loc_map.fitBounds(place.geometry.viewport);
}
else {
Loc_map.setCenter(place.geometry.location);
Loc_map.setZoom(17);
}
loc_marker.setPosition(place.geometry.location);
loc_marker.setVisible(true);

$(‘#loc_latitude’).val(place.geometry.location.lat());
$(‘#loc_longitude’).val(place.geometry.location.lng());

});

}

</script>

Step  5

when  type in address field,  address will be loaded automatically and latitude and longitude will be placed in input fields for searching address.

 

Completed