How to order reference in admin on rest - admin-on-rest

is there a way to order a reference inside a document in admin on rest?
Example: i have a product page with many categories (ReferenceArrayInput). is there a way to order the reference?
Thanks

Yes you can use the sort prop: https://marmelab.com/admin-on-rest/Inputs.html#referencearrayinput

Related

What is the best way to get nested relationships in Laravel Nova?

I have 3 tables with relationships; Feedback has one Type and a Type has multiple Answers:
Feedback->Type->Answers
In Nova, I want to display all Answers to the currently Type on the Feedback page. What is the best way to achieve this? Using using Pivot Fields?
Nova/Feedback:
HasOne::make('Type', 'answer', Type::class),
shows error: call to undefined urikey. my models also match nova relationships
Nova/Type:
HasMany::make('Answer'),
Nova/Answer:
BelongsTo::make('Type'),
Is it only to display or also to add while creating a model?
What we mostly use is this packages:
https://novapackages.com/packages/yassi/nova-nested-form
and we extend where needed in specific usecases.

Create new product relation / custom product relation magento 2

I am trying to create a new tab in the admin area for product details where I can use a custom product relation. I am already using Upsell, Related and Cross-sell but would need an extra relation between products.
Just wondering if anyone else has come against this issue/requirement and can point me in the right direction on creating a new product relation.
Thanks!
For this type of requirements you need to get developed an extension which is generated tab, database table to hold main product and their relation.
Thanks,
sagar
There is a good sample in Magento 1 version here. However, in Magento 2, there are some notes if we're trying to follow the logic from this guide:
--Replaced event catalog_product_prepare_save with controller product initialization helper that can be customized via plugins - Magento/Catalog/Model/Product/Initialization/Helper/ProductLinks.php.
--Replaced event catalog_model_product_duplicate with composite Product\Copier model. However, we don't use this event.
--We need to override the \Magento\Catalog\Model\Product\Link\Proxy - can find it under var/generation.
We can read more here.

How do you query the category id or name in Opencart 1.5.5.1 Joomla 3.3.0

So I am modifying a module and I've successfully queried the product ID. So if I am browsing products and go into the product details page, I can see my product ID using
JRequest::getInt('product_id');
but for some reason I cannot get the category ID. I've tried.
JRequest::getInt('category_id');
and it always comes out to zero no matter what category I go to. Anyone else experience this? I could get it from the nonSEF url but there's gotta be another way. My goal is to basically query the category ID when I am browsing that category or if I am in the product details of a product.
I assume, you're using some OpenCart component for Joomla. In this case, you have to look into controller and model files for OpenCart. It's not THAT easy to get certain values sometimes, because these are 2 different engines.
In short, you may have to use VQMod for OpenCart, add category_id to data array and only then JRequest it. Solely depends on task.

Is this possible to get categories sorted by RAND()?

I want to display product categories in random order.
Is that possible?
How can I achieve this?
I'm using custom theme, and categories are fetch by:
$_categories = $this->getStoreCategories();
Maybe it will be easier to use php shuffle function?
After you have got the collection of the categories, do you want to try using this
$arrCategories->getSelect()->order(new Zend_Db_Expr('RAND()'))->limit('5');
I have used this on a different collection of items, so I am not sure if this can work on Categories. But I think its worth trying..It is just writing a select query with Order by RAND().
Hope it works.
Cheers,
Swapna

Search by product name and sku [duplicate]

I am working on a Magento site, and i would like to edit the default search result.
Editing search result is not editing the appearance of search result but the actual search results generated.
The idea is, if the Magento search does not return any value then i need to do a search in my custom table to fetch some relative products.
Could anyone help me to edit the default Magento search??
Thanks a lot in advance.
You will need to modify some of the models in catalogsearch module, this link has a good explanation of how to override Core classes. In your case you will need to add your logic somewhere in the Query model or its resource or collection models.
This CMS Search extension will provide an excellent example of how to extend the default search. It adds extra content into the search index and allows you to control how those results are presented to the searcher.

Resources