Friday, 7 February 2020

Magento 2 get product custom option details in phtml file

protected $_customOption;

\Magento\Catalog\Model\Product\Option $customOption,

$this->_customOption = $customOption;

public function customOption($product)
{
$custom = $this->_customOption->getProductOptionCollection($product);

if(!empty($custom)):
foreach($custom as $option):
$values = $option->getValues();
if(!empty($values)):
foreach($values as $value):
$valueData[] = $value->getData();
endforeach;
return $valueData;
else:
return 'Product has no custom option value';
endif;
endforeach;
else:
return 'Product does not have custom options';
endif;
}

Thursday, 6 February 2020

How to remove product custom option '+' symbol in magento 2

/app/design/frontend/venderName/softtouch/Magento_Catalog/templates/product/view/options/type/select.phtml

<script>
  require([
   'jquery',
   'domReady!'
   ], function ($) {
       $(document).ready(function () {
           $('select.product-custom-option').change(function(){
               $('option').each(function(){
                   var selectedOption = $(this).text();
                 
                   if (selectedOption.indexOf('+') > -1) {
                        var replaced = selectedOption.replace('+', ' ');
                       // selectedOption = selectedOption.substring(0, selectedOption.indexOf('+'));
                        $(this).text(replaced);
                   } else if (selectedOption.indexOf('-') > -1) {
                        //selectedOption = selectedOption.substring(0, selectedOption.indexOf('-'));
                        var replaced = selectedOption.replace('+', ' ');
                        $(this).text(replaced);
                   }
               });   
           });   
       });
    });
</script>

Thursday, 16 January 2020

Monday, 13 January 2020

How To Migrate From Magento 1 To Magento 2 Without Breaking Anything.

You migration the latest magento 2 version . Mention the vertion for example data-migration-tool:2.3.3

composer config repositories.magento composer https://repo.magento.com
composer require magento/data-migration-tool:2.3.3


Edit config.xml file :-
Path: /vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.2.
 <source>
        <database host="localhost" name="rene_copy_db" user="root" password="nopass" />
    </source>
    <destination>
        <database host="localhost" name="rene_m2_db" user="root" password="nopass" />
    </destination>
Also added this value crypt_key (from magento 1.9):
<crypt_key>sony</crypt_key>

From version mention  for example :/opensource-to-opensource/1.9.2.4/config.xml

Path: /vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.2.4
map.xml

copy magento 1.9 media folder  to magento 2  media folder (pub/)

php bin/magento migrate:settings vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.2.4/config.xml
php bin/magento migrate:data -a vendor/magento/data-migration-tool/etc/opensource-to-opensource/1.9.2.4/config.xml




Saturday, 11 January 2020

Installing composer in Ubuntu / Linux

Step 1: sudo apt-get remove composer
Step 2: php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
Step 3: php -r "if (hash_file('sha384', 'composer-setup.php') === 'baf1608c33254d00611ac1705c1d9958c817a1a33bce370c0595974b342601bd80b92a3f46067da89e3b06bff421f182') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Step 4: php -r "unlink('composer-setup.php');"

Step 5: sudo service apache2 restart
Step 6: System restart 

Monday, 30 December 2019

How to solve product changes not reflecting on frontend after updating from admin in Magento 2

Please execute below queries if you are not able to fix the issue using bin/magento indexer:reindex command

Please note : this is only tested for single stores

DELETE FROM catalog_product_entity_text where store_id != 0;
DELETE FROM catalog_product_entity_datetime where store_id != 0;
DELETE FROM catalog_product_entity_decimal where store_id != 0;
DELETE FROM catalog_product_entity_int where store_id != 0;
DELETE FROM catalog_product_entity_varchar where store_id != 0;