New answers tagged

0

following code will help you to get category collection by url key and store code. protected $_storeManager; public function __construct( \Magento\Store\Model\StoreManagerInterface $storeManager, $data = [] ) { $this->_storeManager = $storeManager; parent::__construct($data); } $pfCategoryId = $this->categoryFactory->create() -&...


1

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


0

Try this :- namespace NameSpace\Module\Block; class FeaturedCategories extends \Magento\Framework\View\Element\Template { protected $categoryCollectionFactory; public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory $...


1

Try to use below line in your phtml file, and replace category_lpage_products with your attribute code. <?php $title = $this->helper('Magento\Catalog\Helper\Output')->categoryAttribute($block->getCurrentCategory(), $block->getCurrentCategory()->getCategoryLpageProducts(), 'category_lpage_products') ?> Update You can create one ...


0

Google is very smart now in days, They using AI to detect and handle On-page SEO elements for the site, Let me come to your answer: The 302 redirect means that the page has been moved temporarily and the other, 301, means that a new page has taken over permanently as per you have mention details in your page its not permanent redirect so I would recommend ...


0

Followup of @chris Incase you, like me, have gotten the task to save a shop which has migrated their store completely wrong here's a functioning script which takes a categoryId and attempt to recreate the category url_rewrite from the category request path to magento's internal mapping of category id. You can use this in combination with Magento\Catalog\...


0

To make it full width in the bottom of product list, edit catalog_category_view.xml or make new one -- if not exist. <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="columns"...


0

In your layout or template file, you need to add an attribute to the body tag, like this: <body> <attribute name="class" value="my-css-class"/> ... Hope that Helps


0

already custom class add in body tag, you can use that class https://drops.meetanshi.com/H0s5yj


0

/app/design/frontend/your_theme/template/catalog/product/list.phtml


0

I have show it by add code to file list.phtml: <?php $_objectManager= \Magento\Framework\App\ObjectManager::getInstance(); $productTypeInstance = $_objectManager->get('Magento\ConfigurableProduct\Model\Product\Type\Configurable'); $productAttributeOptions = $productTypeInstance->getConfigurableAttributesAsArray($_product); if (!empty($...


1

Using Observer over Event layout_generate_blocks_after you can show product count at title Define an observer at events.xml 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"> <...


0

Let me share a basic idea for this task. You can achieve this using the below code in your list page template file. Please use proper dependency instead of objectmanager <?php $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $category = $objectManager->get('Magento\Framework\Registry')->registry('current_category'); ...


0

Just to mention, none of these answers are going to work from cron scope or admin scope. storeManager doesnt work properly in these scopes, i.e. it always resolves to the default scope e.g. $storeManager->getStore($storeId) -> works $storeManager->getStore() -> always returns default scope Its something to keep in mind when not working in ...


1

InstalData.php <?php namespace Vendor\Module\Setup; use Magento\Eav\Setup\EavSetupFactory; use Magento\Framework\Setup\ModuleContextInterface; use Magento\Framework\Setup\ModuleDataSetupInterface; use Magento\Framework\Setup\InstallDataInterface; class InstallData implements InstallDataInterface { /** * @var EavSetupFactory */ ...


0

Where do you want to hide your category ? If it's in the filter then it's the native magento behaviour to hide them when they have no products. If it's not there, then you probably just need to override the template calling the category like in your menu, and use a count condition on the category items. An other work around would bo to override the ...


0

Emili, I checked the Magento 2.3.5-p1 code base, The exception is thrown by an attribute that Backend model instance of Image. => Please review your EAV attributes (eav_attribute) which have backend model like '%image%', Check the before load, before save, after load, after save, makes sure the attribute's value afterload isn't instance of an array.


0

I think the below code will help you to fix the serialization error. namespace M2\Mage24Fix\Framework\Serialize\Serializer; /** * Class Title * * Fix fatal with serialize json for 2.4.0 version - https://magento.stackexchange.com/questions/286634/magento-2-3-xx-unable-to-serialize-value-error-malformed-utf-8-characters-pos */ class Json extends \...


0

This issue can be caused because of improper file permission ( generate ). If you are using redis try to flush it - redis-cli flushall Problem with your cache - Flush it and then try the last one make changes in Json.php ( Please first try the three above ) // Change unserialize function with this one public function unserialize($string){ if($this-&...


0

I got this error while trying to make category "is_anchor". Solution: Please click each of the error message (highlighted URL) and delete. Refresh the page and save category again.


-1

I got similar issue (no products listing) and solved by following command: php bin/magento index:reindex


Top 50 recent answers are included