Skip to main content

Posts

update order customer if mismatch after migration like any issue

Using csv we can update customer ids use this code in controller  if (($handle = fopen("/chroot/home/*****/*********/html/app/code/Test/Testmodule/Controller/Index/uniqueorder.csv", "r")) !== FALSE) {             while (($data = fgetcsv($handle, 10000, ",")) !== FALSE) {                 $email = $data[2]; //                 echo $url;die("data");                 $objectManager = \Magento\Framework\App\ObjectManager::getInstance();                 $orderCollection = $objectManager->create('\Magento\Sales\Model\ResourceModel\Order\CollectionFactory');                 $collection = $orderCollection->create()                         ->addAttributeToSelect('*')     ...

Magento 2 Useful snippets for frontend developers

1 - Infos About Store Get Current store Id : inject \Magento\Store\Model\StoreManagerInterface $storeManage   $this->storeManager = $storeManager;   and get the id with :   $id = $this->storeManager->getStore()->getId();   get base Url :   $baseUrl = $this->storeManager->getStore()->getBaseUrl();     you can inject \Magento\Framework\UrlInterface and use use constants of class as parameters (UrlInterface::URL_TYPE_LINK) :       const URL_TYPE_LINK = 'link';     const URL_TYPE_DIRECT_LINK = 'direct_link';     const URL_TYPE_WEB = 'web';     const URL_TYPE_MEDIA = 'media';     const URL_TYPE_STATIC = 'static';     const URL_TYPE_JS = 'js';   get base currency code  or (getBaseCurrency() , getDefaultCurrencyCode(), getDefaultCurrency()):   $baseCurrency = $this->storeManager->getStore()->getBas...

magento create admin user programatically

Create test file in root directory and place code in to that file and run yoursiteurl.com/test.php  <?php       # Create New admin User programmatically.      require_once('./app/Mage.php');     umask(0);    Mage::app();    try {                    $user = Mage::getModel('admin/user')->setData(array(                     'username'  => 'pawan',                     'firstname' => 'pawan',                     'lastname'    => 'kumar',                     'email'     => 'n.pavan37@gmail.com',                     'password'  =>'pawan123',     ...

Topmenu not functioning after upgrade magento 1.8 fatal error addCacheTag()

ERROR :: Fatal error: Call to a member function addCacheTag() on a non-object in public_html/app/code/core/Mage/Catalog/Model/Observer.php on line 215 you can find the lines 241 ::   $menuBlock->addModelTags($categoryModel); 215 ::   $block->addCacheTag(Mage_Catalog_Model_Category::CACHE_TAG); here is not error fixing place in block class is " Mage_Page_Block_Html_Topmenu " you can find getHtml function in that you can see Mage::dispatchEvent('page_block_html_topmenu_gethtml_before', array(             'menu' => $this->_menu         )); replace above code to below code  Mage::dispatchEvent('page_block_html_topmenu_gethtml_before', array(         'menu' => $this->_menu,         'block' => $this         //add this line ));