Skip to main content

Posts

Showing posts from September, 2019

Magento 1: Slider

Magento 1 slider (Gourav Slider) If you want to add images slider to your magento 1 store, you can download slider module from the following location: https://marketplace.magento.com/gourav-gouravslider.html  

Magento 2: How to Get all categories name?

To get all categories name of your magento 2 store, use following code: $_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $categoryCollection = $_objectManager->get('\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory'); $categories = $categoryCollection->create()->addAttributeToSelect('*'); foreach ($categories as $category) {    echo $category->getName()."<br/>"; }

Magento 2: Print Invoice PDF or Shipment PDF is not working : sh: 1: xvfb-run: not found

Some times in Magento 2, while we try to print Invoice PDF or Shipment PDF or any other PDF, then it displays following message: sh: 1: xvfb-run: not found To resolve this issue, first login to your project through SSH and run following commands on the root location of your project: sudo apt-get install --fix-missing -y xvfb sudo apt-get update sudo apt-get install xvfb libfontconfig wkhtmltopdf   

Magento 2: Rule is not applying on checkout page while select payment method

There may be n number of reasons to reflecting this issue but one of them is Rewards module of Mirasvit . To resolve this issue install FixRules module of MagestyApps. and edit select-payment-method.js file in Rewards module, this file location is: app/code/Mirasvit/Rewards/view/frontend/web/js/checkout/override/select-payment-method.js and add the following code in this file after this line: quote.paymentMethod(paymentMethod); ------------------------------------------------------ fullScreenLoader.startLoader();             jQuery.ajax('/magestyapps_fixrules/checkout/applyPaymentMethod', {                 data: {payment_method: paymentMethod},                 complete: function () {                ...

Magento 2: How to add custom script to head tag?

There are two ways to add custom script to head tag in Magento 2: add custom script through admin-panel add custom script through XML If you want to add custom script in head tag through admin-panel, just login to the admin and browse the navigation Content => Design => Configuration , Now click on edit link of current theme and Go to HTML Head tab and inside scripts and style sheets text-area you can enter your custom script.  If you want to add custom script through XML, just create a XML file on following location: app/design/frontend/packagename/themename/Magento_Theme/layout/default_head_blocks.xml and add the following code in this XML to call template file: <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body>         <referenceBlock name="head.additional">    ...

Magento 2: How to get all products collection programatically?

To get all products collection in magento 2 use following code: $_objectManager = \Magento\Framework\App\ObjectManager::getInstance();     $productCollection = $_objectManager->create('Magento\Catalog\Model\ResourceModel\Product\CollectionFactory'); $collection = $productCollection->create() ->addAttributeToSelect('*') ->addAttributeToFilter('status', '1') ->load();

Magento 2: How to get root directory path of your project programatically?

To get root directory path in magento 2 use following code: $objectManager = \Magento\Framework\App\ObjectManager::getInstance();        $directory = $objectManager->get('\Magento\Framework\Filesystem\DirectoryList'); echo $rootdirPath  =  $directory->getRoot(); using following code you can get the other directories path also like: echo $mediadirPath  =  $directory->get P ath('media'); echo $vardirPath  =  $directory->get P ath('var'); echo $pubdirPath  =  $directory->getPath('pub');  

Magento 2: Get simple products from configurable product programatically

Use following code to get simple or child products from configurable product: $config_product_id = 1; $_objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $config_product = $_objectManager->get('Magento\Catalog\Model\Product')->load($config_product_id); $configChilds = $product->getTypeInstance()->getUsedProductIds($config_product); foreach ($configChilds as $child){     $child->getId().","; } This code will print all simple products id of given config product.

Magento 2: Reset customer password programatically

There are 2 ways to reset customer password programmatically in Magento2: 1) By creating a php file on root directory of project: Create a new php file on root directory of your project and place the following code in that file: and change these two varaibles in this code: $passwordhash for new password $email for customer email use Magento\Framework\App\Bootstrap; require 'app/bootstrap.php'; $params = $_SERVER; $bootstrap = Bootstrap::create(BP, $params); $objectManager = $bootstrap->getObjectManager(); class MyEncryptor extends \Magento\Framework\App\Http implements \Magento\Framework\AppInterface {     private $encryptor;     public function __construct(         \Magento\Framework\App\State $state,         \Magento\Framework\Encryption\EncryptorInterface $encryptor,         \Magento\Framework\App\Response\Http $response  ...

Magento 2: How to integrate unicommerce with magento 2?

To integrate unicommerce with magento 2 use following steps: 1- Login to adminpanel and click on System => Integrations menu 2- Now click on add new integration button and fill the integation tab info: Name, email, and leave blank to callback url field and in identity link url field just enter admin and enter you admin password 3- Now click on API tab and for resource access select ALL option and click on save. 4- Now you can see the Integration details: consumer key, consumer secret, access token, access token secret has been generated under integrations menu. 5- Now copy the access token and enter this in unicommerce panel under channel => channel name => access token field and in username field enter magento 2 admin user name and site URL.

Magento 2: How to enable or disable a module?

To disable or enable a module in magento 2 we have to take the following steps: 1- Just go to your project root directory and open config.php file from following location: app/etc/config.php 2- Now search for the module in this file, which one you want to enable or disable. 3- if you want to enable the module then set the value 1 of that module. 4- if you want to disable the module then set the value 0 of that module. 5- Finally save the file and run upgrade command.