Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions
Collection Class Reference

Public Member Functions

 __construct (CollectionFactory $childCollectionFactory, ProductFactory $productFactory, SearchCriteriaBuilder $searchCriteriaBuilder, DataProvider $productDataProvider, MetadataPool $metadataPool)
 
 addParentId (int $id)
 
 addEavAttributes (array $attributeCodes)
 
 getChildProductsByParentId (int $id)
 

Detailed Description

Collection for fetching configurable child product data.

Definition at line 22 of file Collection.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( CollectionFactory  $childCollectionFactory,
ProductFactory  $productFactory,
SearchCriteriaBuilder  $searchCriteriaBuilder,
DataProvider  $productDataProvider,
MetadataPool  $metadataPool 
)
Parameters
CollectionFactory$childCollectionFactory
ProductFactory$productFactory
SearchCriteriaBuilder$searchCriteriaBuilder
DataProvider$productDataProvider
MetadataPool$metadataPool

Definition at line 71 of file Collection.php.

77  {
78  $this->childCollectionFactory = $childCollectionFactory;
79  $this->productFactory = $productFactory;
80  $this->searchCriteriaBuilder = $searchCriteriaBuilder;
81  $this->productDataProvider = $productDataProvider;
82  $this->metadataPool = $metadataPool;
83  }
$searchCriteriaBuilder

Member Function Documentation

◆ addEavAttributes()

addEavAttributes ( array  $attributeCodes)

Add attributes to collection filter

Parameters
array$attributeCodes
Returns
void

Definition at line 107 of file Collection.php.

107  : void
108  {
109  $this->attributeCodes = array_replace($this->attributeCodes, $attributeCodes);
110  }

◆ addParentId()

addParentId ( int  $id)

Add parent Id to collection filter

Parameters
int$id
Returns
void

Definition at line 91 of file Collection.php.

91  : void
92  {
93  if (!in_array($id, $this->parentIds) && !empty($this->childrenMap)) {
94  $this->childrenMap = [];
95  $this->parentIds[] = $id;
96  } elseif (!in_array($id, $this->parentIds)) {
97  $this->parentIds[] = $id;
98  }
99  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$id
Definition: fieldset.phtml:14

◆ getChildProductsByParentId()

getChildProductsByParentId ( int  $id)

Retrieve child products from for passed in parent id.

Parameters
int$id
Returns
array

Definition at line 118 of file Collection.php.

118  : array
119  {
120  $childrenMap = $this->fetch();
121 
122  if (!isset($childrenMap[$id])) {
123  return [];
124  }
125 
126  return $childrenMap[$id];
127  }
$id
Definition: fieldset.phtml:14

The documentation for this class was generated from the following file: