New answers tagged

0

You can get Category Image using this function $category->getImageUrl() You can use this in your code like.. <?php namespace Butterfly\Megamenu\Block; class Categorylist extends \Magento\Framework\View\Element\Template { protected $_categoryHelper; protected $categoryFactory; protected $_catalogLayer; protected $_categoryRepository; ...


2

I have same issue and its working with that, In my case its solved when i was set no from admin configuration under Google api "Enable Content Experiments" Configuration => Sales => Google API => Enable Content Experiments set no and save.


0

I once did it with an observer. First declare it in Namespace/ModuleName/etc/frontend/events.xml <?xml version="1.0" ?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd"> <event name="layout_load_before"> <observer name="...


0

I myself found a workaround for this problem. Rather than creating and saving categories from your custom controller, you can use the REST API that comes with Magento 2 to do the job for you. List of available endpoints There is even a cool interface that comes with all Magento installations where you can play around with it. It can be found in http://<...


0

Basically you need to create Symlinks for the same Directory. If you don't know, how to Symlinks then please refer this link: For Windows For Linux


0

Try this: File: app/code/{{vendorName}}/{{ModuleName}}/Setup/InstallData.php <?php namespace {{vendorName}}\{{ModuleName}}\Setup; use Magento\Framework\Setup\InstallDataInterface; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\Catalog\Setup\CategorySetupFactory; class ...


0

Add the below code in calatog_category_view.xml and replace the block name and template name with your custom block and template name <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="content">...


0

Please Add Below code in File Path :ModuleName/CategorySecondContent/view/adminhtml/ui_component/category_form.xml <?xml version="1.0" encoding="UTF-8"?> <form xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd"> <fieldset name="general"> ...


0

Add your xml code in app/code/Vendor/Module/view/adminhtml/ui_component/category_form.xml


0

Please try with add below code in your controller to get using your category id to get all parent categories.. $category = $categoryFactory->create()->load($categoryId); $parentCategories = $category->getParentCategories();


0

To get Category Image url: <?php echo $category->getImageUrl(); ?> And use it in <img> tag like <img src="<?php echo $category->getImageUrl(); ?>" /> And get Alternate Image url: echo $category->getImageUrl('category_alternate_image'); <img src="<?php echo $category->getImageUrl('category_alternate_image'); ?...


1

Please try below collection. $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $parentCategoryId = 2; $parentCategory = $objectManager->get('Magento\Catalog\Model\Category')->load($parentCategoryId); $collection =$objectManager->create("\Magento\Catalog\Model\CategoryFactory")->create()->getCollection()->...


0

I faced the same issue when flat_categories were enabled. You can load the normal category model instad of the flat category and delete it to get around this issue Mage::register('isSecureArea', true); $category = Mage::getModel('catalog/category', array('disable_flat' => true))->load($categoryId); $categoy->delete(); Referance: disable flat ...


1

You can do this in the category configuration from the Magento admin. Catalog > Category > Select category to change the layout. Please see attached screenshot for more information. Hope this helps!!!


0

The getAggregations function gets it's data from Magento's search framework, which works in a counter-intuitive way and fills the aggregation buckets for every search in advance. I suspect this is because it creates a temporary table each time and has to perform all operations before the transaction ends and disposes of the table. It doesn't use your product ...


0

First, you need to inject collection factory class public function __construct( ... \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory $collecionFactory ) { $this->_collectionFactory = $collecionFactory; parent::__construct(...); } After that inside your method, you can do this, $categoryTitle = 'Men'; $collection = $this-&...


1

1.Create a Custom Block Class in file name Categorylist.php PackageName\moduleName\Block\Categorylist.php Add below code <?php namespace PackageName\moduleName\Block; class Categorylist extends \Magento\Framework\View\Element\Template { protected $_categoryHelper; protected $categoryFactory; protected $_catalogLayer; protected $...


0

Please try this to get a solution <?php function categoryLoop($id){ $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $categories = $objectManager->create('Magento\Catalog\Model\Category')->load($id); if($categories->hasChildren()){ echo "<ul>"; $subcategories = explode(',', $categories->...


0

For the record - you most likely have duplicate product names. I had the same problem. You can check the error in var/log/exception.log to see exact url. Copy it. Then you can check your database for duplicates with the following query: select entity_id, request_path, store_id from url_rewrite where request_path like '%kreinik-metallic-very-fine-4-siulai%';...


0

Create Custom module with your PackageName and ModuleName 1.Create a registration.php file at PackageName/ModuleName/registration.php Add below code <?php \Magento\Framework\Component\ComponentRegistrar::register( \Magento\Framework\Component\ComponentRegistrar::MODULE, 'PackageName_ModuleName', __DIR__ ); 2.Create a module.xml file at ...


3

You can do it in the following way. Create the new product attribute set enable for redirect products. Now Create event using your custom module (NOTE: If you don't have any module then create new module and then create event in that) So in your events.xml add following code /app/code/Vendor/Module/etc/events.xml <?xml version="1.0" ?> <config ...


0

If you are encountering an issue with Magento 2.3.2 wherein the products won't show up on frontend even if on the backend it is showing, the cause of the issue is due to Multi-Source Inventory module of Magento 2. You might need to execute the following SQL command CREATE ALGORITHM=UNDEFINED SQL SECURITY INVOKER VIEW `inventory_stock_1` AS select ...


0

Interceptor is not created. A coworker had this problem and we resolved it by clearing caches manually. Try following commands in your magento root directory: php bin/magento deploy:mode:set developer after that rm -rf generated/code/* generated/metadata/* var/cache/* php bin/magento c:cl php bin/magento c:fl


0

Try to add store_id to your data. Maybe it will be helpful. Check keys value, because includeInMenu and parentId should be like parent_id / include_in_menu $category_data = [ 'store_id' => 0, 'parent_id' => 2, 'name' => 'NIMI', 'is_active' => 1, 'position' => 1, 'include_in_menu' => 1, 'category' => 1 ];


1

I guess, we can directly use $this->getRequest()->getFullActionName() in .phtml file to get current page action.


0

In Database Execute This Query SET GLOBAL innodb_lock_wait_timeout = 120;


0

You can use mysqldump to create a dump that either includes only named tables, or excludes specific tables. e.g. mysqldump -u magento_user -p magento_db catalog_product_entity, catalog_category_entity > products_and_categories.dump; mysqldump -u magento_user -p magento_db ignore_table=quote, ignore_table=sales_order > ...


0

You can use below code to fetch category and subcategory collection <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $categoryCollection = $objectManager->get('\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory'); $categoryHelper = $objectManager->get('\Magento\Catalog\Helper\Category'); $categories = $...


0

Please check if there is already some process running and that is holding the table catalog_category_entity. you can do so by running show processlist from mysql console. If yes then you need to wait for that process to complete or kill that process if that is some unwanted script. If no then you can try increasing the wait timeout for mysql


0

Try below code : protected $_productCollectionFactory; protected $_categoryFactory; protected $_productRepository; public function __construct( \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $productCollectionFactory, \Magento\Catalog\Model\ProductRepository $productRepository, \Magento\Catalog\Model\CategoryFactory $...


1

Try like this, $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $categoryCollection = $objectManager->get('\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory'); $productRepository = $objectManager->get('\Magento\Catalog\Model\ProductRepository'); $appState = $objectManager->get('\Magento\Framework\App\...


0

Step - 1 : Create an instance of your database. Then delete all orders by execute below query SET FOREIGN_KEY_CHECKS=0; # 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`;...


0

The Best solution is to upgrade the Magento 2.2.2 to the Magento 2.3.2 version. Please run the following commands php bin/magento maintenance:enable composer require magento/product-community-edition 2.3.2 --no-update composer update rm -rf <Magento install dir>/var/cache/ rm -rf <Magento install dir>/var/page_cache/ rm -rf <Magento ...


0

problem solve by my self may thanks :)


Top 50 recent answers are included