Zend Anwar

Full stack web developer

Day: January 30, 2019

Magento 2 add simple product programmatically

just create a file like upload.php and run from root directory. <?php use \Magento\Framework\App\Bootstrap; include(‘app/bootstrap.php’); $bootstraps = Bootstrap::create(BP, $_SERVER); $object_Manager = $bootstraps->getObjectManager(); $app_state = $object_Manager->get(‘\Magento\Framework\App\State’); $app_state->setAreaCode(‘frontend’); $set_product = $object_Manager->create(‘\Magento\Catalog\Model\Product’); try{ $set_product->setWebsiteIds(array(1)); $set_product->setAttributeSetId(4); $set_product->setTypeId(‘simple’); $set_product->setCreatedAt(strtotime(‘now’)); $set_product->setName(‘BD product simple product’); $set_product->setSku(‘bd-pro-simple’); $set_product->setWeight(1.0000); $set_product->setStatus(1); $category_id= array(4,5,6,7); $set_product->setCategoryIds($category_id); $set_product->setTaxClassId(0); $set_product->setVisibility(4); $set_product->setManufacturer(29); $set_product->setColor(20); $set_product->setPrice(1999); $set_product->setCost(1800); $set_product->setMsrpDisplayActualPriceType(1); $set_product->setMetaTitle(‘BD product simple product’); […]

Read More

Magento 2 install with cli mode

Go to your root directory C:\xampp\htdocs\magento2> and run following command php bin/magento setup:install –base-url=”http://127.0.0.1/magento2/” –db-host=”localhost” –db-name=”databasename” –db-user=”databaseuser” –db-password=”databasepass” –admin-firstname=”Yourname” –admin-lastname=”Yourname” –admin-email=”borntowinanwar@gmail.com” –admin-user=”admin” –admin-password=”strongpassword” –backend-frontname=”admin”

Read More

Magento 2 after install shows blank page

Please below instruction hope it will resolve. Just got to vendor/magento/framework/View/Element/Template/File/validation.php And go to line 138 lines Replace  $realPath = $this->fileDriver->getRealPath($path); foreach ($directories as $directory) { if (0 === strpos($realPath, $directory)) { return true; } } With  $realPath = $this->fileDriver->getRealPath($path); foreach ($directories as $directory) { $directory = $this->fileDriver->getRealPath($path); if (0 === strpos($realPath, $directory)) { return […]

Read More