Skip to main content

Posts

Magento 2: Get product attribute’s select option id,label for all products from root folder

First create test.file in root folder place below code <?php echo '<pre>'; require __DIR__ . '/app/bootstrap.php'; $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); /** @var \Magento\Framework\App\Http $app */ $obj = $bootstrap->getObjectManager(); $state = $obj->get('Magento\Framework\App\State'); $state->setAreaCode('frontend'); /** @var \Magento\Framework\App\Http $app */ $app = $bootstrap->createApplication('TestApp'); $bootstrap->run($app); After that create  loaded application file with name of Testapp (bold letter) place the below code <?php class TestApp extends \Magento\Framework\App\Http implements \Magento\Framework\AppInterface {     public function launch() {         echo "<pre>"; //die("here");         $objectManager = \Magento\Framework\App\ObjectManager::getInstance();         $orderDatamodel = $objectManager->get('Mag...

Magento 2 upgrade 2.1.4 to 2.1.7 process

Use below command to update MAGENTO 2 version from old version to latest version from  root directory. I ended up trying to do the upgrade from the command line and it worked 1>  composer require magento/product-community-edition 2.1.7 --no-update 2> composer update 3> php bin/magento setup:upgrade

How to put the code google remarketing

 View.phtml Paste the below code on your product view template. You can find the file inside the catalog folder. <? php $_product = Mage :: registry ( "current_product" );?> <? php if ( $_product && $_product -> getId ()): ?> <script> dataLayer . push ({ "event" : "fireRemarketingTag" , "google_tag_params" : { "ecomm_prodid’: " <? php echo $_product -> getSku (); ?> ", "ecomm_pagetype’: " product ", "ecomm_totalvalue’: <? php echo $_product -> getfinalprice (); ?> } }); </script> <script type="text/javascript"> /* <![CDATA[ */ var google_conversion_id = XXXXXXXXXXX; var google_custom_params = window.google_tag_params; var google_remarketing_only = true; /* ]]> */ </script> <script type="text/javascript" src="// www.googleadservices.com/pagead/conversion.js "...

Magento 2: How to truncate customers, products, reviews and orders table

NOTE ::  Please take database backup prior to executing these queries. SET FOREIGN_KEY_CHECKS=0; Truncate order tables # Clean order history TRUNCATE TABLE `sales_bestsellers_aggregated_daily`; TRUNCATE TABLE `sales_bestsellers_aggregated_monthly`; TRUNCATE TABLE `sales_bestsellers_aggregated_yearly`; # Clean order infos TRUNCATE TABLE `sales_creditmemo`; TRUNCATE TABLE `sales_creditmemo_comment`; TRUNCATE TABLE `sales_creditmemo_grid`; TRUNCATE TABLE `sales_creditmemo_item`; TRUNCATE TABLE `sales_invoice`; TRUNCATE TABLE `sales_invoiced_aggregated`; TRUNCATE TABLE `sales_invoiced_aggregated_order`; TRUNCATE TABLE `sales_invoice_comment`; TRUNCATE TABLE `sales_invoice_grid`; TRUNCATE TABLE `sales_invoice_item`; TRUNCATE TABLE `sales_order`; TRUNCATE TABLE `sales_order_address`; TRUNCATE TABLE `sales_order_aggregated_created`; TRUNCATE TABLE `sales_order_aggregated_updated`; TRUNCATE TABLE `sales_order_grid`; TRUNCATE TABLE `sa...

How to create shipment programmatically in magento2

if we need to programmatically create shipment for an order then you can create by following way. // Load the order $order = $this->_objectManager->create('Magento\Sales\Model\Order') ->loadByAttribute('increment_id', '302372359'); OR $order = $this->_objectManager->create('Magento\Sales\Model\Order') ->load('1079'); // Check if order can be shipped or has already shipped if (! $order->canShip()) { throw new \Magento\Framework\Exception\LocalizedException( __('You can\'t create an shipment.') ); } // Initialize the order shipment object $convertOrder = $this->_objectManager->create('Magento\Sales\Model\Convert\Order'); $shipment = $convertOrder->toShipment($order); // Loop through order items foreach ($order->getAllItems() AS $orderItem) { // Check if order item has qty to ship or is virtual if (! $orderItem->getQtyToShip() || $o...

Understanding Magento Block and Block Type

For understanding more about magento block types following are some built-in block types which are widely used in layout. core/template : This block renders a template defined by its  template  attribute. The majority of blocks defined in the layout are of type or subtype of  core/template . page/html : This is a subtype of  core/template  and defines the root block. All other blocks are child blocks of this block. page/html_head : Defines the HTML head section of the page which contains elements for including JavaScript, CSS etc. page/html_header : Defines the header part of the page which contains the site logo, top links, etc. page/template_links : This block is used to create a list of links. Links visible in the footer and header area use this block type. core/text_list : Some blocks like  content ,  left ,  right  etc. are of type  core/text_list . When these blocks are rendered, all their child blocks are rendered automa...