Devdocs: Describe needed parameters for a factory create

Created on 8 Sep 2020  路  7Comments  路  Source: magento/devdocs

General issue

Description:

The example below shows the construction of a Magento\Search\Model\Autocomplete\Item object by passing in an array of parameters to a factory:

$resultItem = $this->itemFactory->create([
  'title' => $item->getQueryText(),
  'num_results' => $item->getNumResults(),
]);

How do we know which parameters we can pass to the Factory create method?
I looked up the class Magento\Search\Model\Autocomplete\Item and it only has a method "getTitle" so why did the autor added num_results ?

https://devdocs.magento.com/guides/v2.4/extension-dev-guide/factories.html

Possible solutions:

Additional information:

Help Wanted done

All 7 comments

Hi @Eddcapone. Thank you for your report.
To help us process this issue please make sure that you provided sufficient information.

Please, add a comment to assign the issue: @magento I am working on this


@Eddcapone - Can you please either rename this Issue OR better, merge it with #7836 - The issue can simply be to improve this one page for multiple reasons - then we can have one PR to deal.

@BarnyShergold Those are two unrelated feedbacks though, sure that I should merge it?

As I said - if you don't want to merge them - can you give them different and more meaningful titles? At the moment we have 2 issues with exactly the same name - gets confusing. People should have an idea about what an issue is by just reading the title and not having to open it - there are a lot of issues :)

Sure, the title was auto generated.

Related Issue - #6011

It is resolved and merged

Was this page helpful?
0 / 5 - 0 ratings