Magento 2.3.4 size swatch displayed for products with salable quantity 0 - magento2

We are using latest version of Magento 2.3.4.
Whenever a customer is creating an order a salable quantity for product (child of configurable product) is decreased - which is a correct behavior. The problem is that, a bought size is still available until order is shipped.
The customer can see size - while trying to add (just sold) size to bucket, he gets information that requested QTY is not available.
I would like to disable (grey out or cross out) unavailable size.
Can I achieve this using magento settings ? Or do I have to write a custom plugin ?

You could do multiple things:
Find the template of the dropdown and break into it with objectmanager and a custom (raw) query that checks the stock for the size and disables the option. This is fastest but bad especially if you don't have caching, the queries make the template slow to load.
Make a nice extension that overrides the templates trough xml file. Also override the php files (model/controller) and change the logic to acheive what you want. This is better practice. It has been done here i think, didnt test it myself:
https://magento.stackexchange.com/questions/216373/magento-2-2-how-to-show-out-of-stock-in-configurable-product
Find an extension from 3th party.
If you have a sample of code I can also help with it.

Related

Will adding all attrbiutes to PreImage/PostImage to plugin step have impact on performance?

When registering plugin images and selecting all attributes to the image, the Plugin Registration Tool says that
"This plug-in will execute on all changes to the attributes associated to this message type!. This can create performance issues for your application and it is recommended that you filter your step registration to trigger on only the attributes you care about".
I set filtering attributes for the step.
So will setting filtering attributes save me from what that caution says?
For Example if you have Plugin on Update of Contact and filtering attribute is set to All, It will run on any field change on contact and this will definitely cause performance issue.
Now when you have filtering attribute set to only few fields for example fist name, last name and so on it will restrict to fire your plugin only on those field.
You can get all the attributes in pre image and post image but best case it to select only those attributes you need in your transaction.
Adding all fields in Pre and Post image will not add much burden/impact on your performance, but it will definitely add performance issue if your filtering attribute has all the fields selected.

Is there a way to permanently add a box displaying points of students in the navbar

So I am working on a project that awards points to students for submitting assignments or participating in forums, these points are then exposed as an Http resource using Flask.
The points are calculated by looking at the events triggered for each student.
One of the requirements right now is to add a box next to the student's name that shows the total amount of points they have. I have two ways of accessing the points, either by an http request from moodle or by storing and retrieving the points from moodle's database.
My question is what is the best approach of creating this "box", I have tried using moodle blocks and hacking the code but nothing seems to be working. Is creating a plugin for this the only solution or is there a simpler way to do it (if it is even possible)?
To answer your question properly you should have provided at least the theme and the Moodle version you work with. Should this box be displayed everywhere? Is the score calculated for every course individually?
Two proposals that came into my mind:
You could create a custom plugin of type block. There you can display the score of the user of the session and the top ten for example (If the score is calculated for each course individually). A disadvantage is that every teacher of a course could remove that block easily, if he or she wants to.
If the score counts system-wide you could put that box at the start page of your Moodle website, where only people with higher rights will be able to remove it.
If you use boost you could display the score in the navbar right next to the users name. For that you will have to create a new child theme of boost and overwrite navbar.mustache of theme_boost which get's it's information from columns2.php because it's included into columns2.mustache. In this PHP file you can include your logic and display it with the HTML which you put into navbar.mustache.
Of course these are not really simple ways to do that. But at the moment I doubt that an easy solution exists for this problem.

Best Product Listing Option for Concrete5

I'm going to be creating a Concrete5 website that will feature product listings. The listing system must offer all your typical ecommerce features, minus the ability to purchase items. It's strictly for browsing purposes only.
For example:
- Browse by category
- Search products
- Listings/results page with thumbnails and brief information (title, description, price in US/CAD, manufacturer, maker, etc.)
- Products single page (with detailed information, attributes and gallery/images)
All the things you'd expect to find in a listing system.
My issue is I can't find a specific add-on for something like product listings. This leaves me thinking that it may be best to use the e-commerce add on and do my best to hide anything related to the cart/payment process. That way it could just be used for everything else it offers.
What are your thoughts on this? Is there a better option?
Thanks for the advice!
Use the page list block. It has everything you need except for searching. But, in essence, that's what your requirements call for -- listing of pages.
Create a page type for your "product". The "brief information" can be in the Content block, or you can set as attributes. You'll probably want to make some minor changes to the block's view (by creating a new template) that displays the image as you want, the proper attributes, etc. Something similar to http://www.concrete5.org/documentation/how-tos/designers/styling-the-page-list-block/
There are several adanced page list blocks in the marketplace. You might want to start with those.
Right creat Page type.
After creat Page attributes.
Add a block page_list create a template for it and filter by attributes.
You can even use ajax to filter.
http://www.weblicating.com/doku/doku.php?id=cheatsheet/#.UbR7P0BmiSp
U can find here about page_list or read documentation Concrete5.

Symfony2 - How to populated a select field with a very large amount of data (nearly 40.000)

I use Symfony 2. I have so far 2 bundles. The first bundle is a called UserBundle and is build using FosUserBundle. The second bundle is called GeoBundle and contains one entity called France which's table contain almost 40.000 records. Each record refers to a city with postal code, regional code.... Basically I use this entity in my user registration form so that the user can select an appropriate city from the list. By the way I use an Entity Field Type to do that.
My problem is that everything is working fine with just a few records in the table but with the almost 40.000 records the page where my form is, is not even opening. I already extended my memory in php.ini to 256M and more but the page is still not opening.
So my question is simple. What would be the best solution to populate a select field with that many records? I am of course open to other solutions. Thank you in advance. Cheers. Marc
You're probably best using an autocomplete field. You can find plenty of solutions on Google. Or try a bundle like https://github.com/shtumi/ShtumiUsefulBundle
Simply don't load the full list, that would be bad for your server, your bandwidth and for the memory required by the client (if it's a mobile browser, forget it!)
I suggest to use jQuery UI Autocomplete, this is a jQuery plug-in that can load the elements required via Ajax from your server, so you don't have to load the hole thing. It's also well tested and easy to implement.
http://jqueryui.com/autocomplete/#remote-jsonp
Try using this Symfony2 bundle.
https://github.com/genemu/GenemuFormBundle/blob/master/Resources/doc/jquery/autocomplete/text.md
This is very helful and in Symfony2. It will save your time and have a look at its other extensions

Magento - Pagination with different number of elements displayed depending on the page number

I'm trying to achieve a non-standart behaviour in magento; Within products categories, I basically need to display a different number of products depending on the current page number.
I'm not quite sure that I can specify this just by a configuration settings in magento admin.
So I suppose I will need to hook into magento core to achieve this.
Any recommandation on where to start this / how to override default behaviour?
Thanks in advance
Yes. You'll have to override the _getProductCollection method in Mage_Catalog_Block_Product_List in order to achieve that.