Category tree for left sidebar

Hi, I’m trying to build a category tree for the left sidebar. Therefore my plan was to always get the current category id:

 public function getCurrentCategoryId() { return $this->layerResolver->get()->getCurrentCategory()->getId(); } 

And get the current categoryId passed in to the category factory to get the corresponding children.

 public function getChildCategories($categoryId) { $category = $this->categoryFactory->create(); $categoryCollection = $category->load($categoryId); //Get category collection return $categoryCollection->getCollection() ->addNavigationMaxDepthFilter() ->addUrlRewriteToResult() ->addIsActiveFilter() ->addAttributeToFilter('include_in_menu', 1) ->addAttributeToSelect('*') ->setOrder('position', 'ASC') ->addIdFilter($categoryCollection->getChildren()); } 

In the .phtml, I simply loop through:

<?php $currentCategoryId = $this->getCurrentCategoryId(); $categories = $this->getChildCategories($currentCategoryId); ?> <?php foreach ($categories as $category): ?> <div class=""> <a href="<?= $block->escapeUrl($category->getUrl()) ?>" class=""><span><?= $block->escapeHtml(__($category->getName())) ?></span> </a> </div> <?php endforeach; ?> 

This is working. However, I’m quite not there, because on the last level I want to show all categories of the last level.

Example of structure:

-category level 0 -category level 1 -category level 1 -category level 2 -category level 2 

At the moment it’s like this:

Click on category level 0 in topmenu -> it will show all category level 1 in sidebar: That’s good

Click on category level 1 in sidebar -> it will show all category level 2 in sidebar: That’s good

Click on category level 2 in sidebar -> it will show nothing anymore in sidebar: That’s bad, because here I want to show all level 2 categories so that users can switch between these categories of the last level.

Maybe my approach is wrong but since I’m almost there, I don’t think I’m on the complete wrong path, am I? Just need to fix this last issue.

Any help would be appreciated. Thanks

submitted by /u/zlep
[link] [comments]

Somewhat Magento related

What percentage of annual revenue do you generally see committed to development in terms of £ / $ / €? Both for support and for feature development?

The reason I consider it more of a Magento question than a generic ecommerce question, is SFCC dev for example is more expensive, Shopify ones cheaper. So how much do you typically see get allocated to dev?

I appreciate it’s a weird question, and likely a £10mil turnover site with an AOV of £1 will require more dev and support than a £10mil turnover site with an AOV of £500, but what is the rough benchmark?

submitted by /u/mr_acronym
[link] [comments]

I created an extension for filtering “in stock” products

As the normal stock attribute doesnt seem to work with the default magento2 filter, I created an extension. It iterates over all simple products with a configurable cronjob and sets a newly created “filter_stock” attribute according to the stock-status of the product. Maybe there is some use for it:
https://github.com/nordcomputer/magento2-stockfilter

submitted by /u/nordcomputer
[link] [comments]

Magento 1 Users, Check Out OpenMage – 20k live sites!

Hey guys,

for anyone still using Magento 1, OpenMage is a great option to migrate to.

There are around 19500 live sites using OpenMage.

The community is very active and would love your input, thoughts and contributions. Check out the

There are continual bug fixes and improvements to the platform. If you have ever thought “man I wish M1 did this” or something similar, then now is your chance to get involved and make it happen.

Migrating to OpenMage 19.4.14 (code here https://github.com/OpenMage/magento-lts/releases/tag/v19.4.14) can be a fairly painless process. This is the simplest and easiest way to move to OpenMage.

Any questions just drop them below 🙂

submitted by /u/Shyiesty1
[link] [comments]

Import/Export Function issues in admin panel [M2]

Hey guys,

I’m having some issues importing my product catalog back in to magento 2 after trying to bulk update some attributes – checking the data returns heaps of incorrect values for attributes.

I tried to see where I went wrong, I exported the product catalog then immediately went in and imported the exact file the Magento generated – and it still gives me errors even though I haven’t modified what Magento has given me. See imgur link below

https://imgur.com/iBpUquD

FYI I only have access to the admin control panel, our website hosts deal with all the commandline/other stuff, but all they have said to me regarding the import issue is that they just manually go in to the file and make the necessary changes to make the error go away, which in my opinion is a waste of their time as they charge out at a pretty expensive rate and doesn’t address magento exporting a faulty file.

Any help is greatly appreciated 🙂

submitted by /u/new_ads
[link] [comments]

I need urgent help in solving this issue at my store. I am not a developer.

main.CRITICAL: Invalid method MagentoFrameworkUrl::__parseUrl {“exception”:”[object] (Magento\Framework\Exception\LocalizedException(code: 0): Invalid method Magento\Framework\Url::__parseUrl at /home/user/public_html/vendor/magento/framework/DataObject.php:399)”} []

last night I was setting up a cart price and then testing out the rule at checkout before I discovered the the following error. Maybe it was already there and we did not realised.
I get the following error: ” internal error. details are available in the Magento log file. report id: webapi-60f242605fbe9″

After checking the exception log, I see this:

[2021-05-17 07:56:03] main.CRITICAL: {“error”:{“root_cause”:[{“type”:”illegal_argument_exception”,”reason”:”Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [identification_value] in order to load field data by uninverting the inverted index. Note that this can use significant memory.”}],”type”:”search_phase_execution_exception”,”reason”:”all shards failed”,”phase”:”query”,”grouped”:true,”failed_shards”:[{“shard”:0,”index”:”magento2_product_1_v917″,”node”:”UvHB7On_QwWWxrU4r1zVGg”, _________

We then increase the ram, thinking that it was an elastic search issue. The error disappeared but the server spikes and slow loading continued.

The next issue was now another error. We are using the shipperHq module for shipping which requires you to allow a backup shipping method in case shipperhq fails. So we activate the webkul MP fixed rate shipping module and we started getting the error below and no shipping method will be available at checkout. The error disappears if the Webkul module is disabled.

Original Message: [2021-07-17 09:55:20] main.CRITICAL: Report ID: webapi-60f2a908652d1; Message: Notice: Undefined offset: 404 in /home/user/public_html/app/code/Webkul/MpFixedRateshipping/Model/Carrier.php on line 297 {“exception”:”[object] (Exception(code: 0): Report ID: webapi-60f2a908652d1; Message: Notice: Undefined offset: 404 in /home/user/public_html/app/code/Webkul/MpFixedRateshipping/Model/Carrier.php on line 297 at /home/user/public_html/vendor/magento/framework/Webapi/ErrorProcessor.php:208, Exception(code: 0): Notice: Undefined offset: 404 in /home/user/public_html/app/code/Webkul/MpFixedRateshipping/Model/Carrier.php on line 297 at /home/user/public_html/vendor/magento/framework/App/ErrorHandler.php:61)”} []

After doing a hard reboot, the ram and cpu consumption dropped back to normal. I checked the elasticsearch and it was not active ( i had to activated it).

I cannot tell what the issue is or if its still there.

Magento 2.4.2.

Any help will be welcome.

submitted by /u/figonju
[link] [comments]

Magento v Other Platforms

Hi,

I am a MBA student doing a research project on B2B eCommerce platforms at a mid-enterprise scale. Specifically, I am looking at various platforms and their ability to host a marketplace with >1M SKUs and various sellers on the marketplace. I have been trying to compare the functionalities of Magento to others and would love for the community’s insight. I have a list of categories for comparing the solutions and would appreciate any detail or a rating of High, Medium, Low, No support.

  1. Primary User bases & Scenarios (SSO/New users/New locations)
  2. Integrated Product & Service Requisitioning (Split shipments/Ad hoc shipping/Inventory Visibilty)
  3. Simplified Sourcing (RFx, Auction, BOM capabilities)
  4. Integrated Supplier Portal (Onboarding/Registration)
  5. Flexible Analytics & Reporting (Ad hoc & out of the box)
  6. Configurable integration across ERPs/WIMS systems
  7. Integrated Catalogs: Federated Search & Multi-SKU (Punchout/Hosted Catalogs/Non-Catalog Reqs)
  8. Issue Tracking and Supplier Scorecards
  9. Flexible Billing and Payment
  10. Notification and Message Capability
  11. Collaboration and Online Support
  12. Avg Go-Live Time
  13. Differentiator
  14. Pricing Model
  15. International

Thanks for any and all insight!!

submitted by /u/thanks_forthehelp
[link] [comments]