66
77namespace Magento \Catalog \Model ;
88
9+ use Magento \Eav \Model \ResourceModel \Entity \Type \CollectionFactory ;
910use Magento \Framework \Serialize \SerializerInterface ;
1011
1112/**
1819 */
1920class Config extends \Magento \Eav \Model \Config
2021{
21- const XML_PATH_LIST_DEFAULT_SORT_BY = 'catalog/frontend/default_sort_by ' ;
22+ public const XML_PATH_LIST_DEFAULT_SORT_BY = 'catalog/frontend/default_sort_by ' ;
2223
2324 /**
2425 * @var mixed
@@ -84,43 +85,31 @@ class Config extends \Magento\Eav\Model\Config
8485 protected $ _scopeConfig ;
8586
8687 /**
87- * Eav config
88- *
8988 * @var \Magento\Eav\Model\Config
9089 */
9190 protected $ _eavConfig ;
9291
9392 /**
94- * Store manager
95- *
9693 * @var \Magento\Store\Model\StoreManagerInterface
9794 */
9895 protected $ _storeManager ;
9996
10097 /**
101- * Set collection factory
102- *
10398 * @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory
10499 */
105100 protected $ _setCollectionFactory ;
106101
107102 /**
108- * Group collection factory
109- *
110103 * @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory
111104 */
112105 protected $ _groupCollectionFactory ;
113106
114107 /**
115- * Product type factory
116- *
117108 * @var \Magento\Catalog\Model\Product\TypeFactory
118109 */
119110 protected $ _productTypeFactory ;
120111
121112 /**
122- * Config factory
123- *
124113 * @var \Magento\Catalog\Model\ResourceModel\ConfigFactory
125114 */
126115 protected $ _configFactory ;
@@ -130,7 +119,7 @@ class Config extends \Magento\Eav\Model\Config
130119 *
131120 * @param \Magento\Framework\App\CacheInterface $cache
132121 * @param \Magento\Eav\Model\Entity\TypeFactory $entityTypeFactory
133- * @param \Magento\Eav\Model\ResourceModel\Entity\Type\CollectionFactory $entityTypeCollectionFactory,
122+ * @param \Magento\Eav\Model\ResourceModel\Entity\Type\CollectionFactory $entityTypeCollectionFactory
134123 * @param \Magento\Framework\App\Cache\StateInterface $cacheState
135124 * @param \Magento\Framework\Validator\UniversalFactory $universalFactory
136125 * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
@@ -207,6 +196,8 @@ public function getStoreId()
207196 }
208197
209198 /**
199+ * Loads all Attribute Sets
200+ *
210201 * @return $this
211202 */
212203 public function loadAttributeSets ()
@@ -229,6 +220,8 @@ public function loadAttributeSets()
229220 }
230221
231222 /**
223+ * Returns Attribute's Set Name
224+ *
232225 * @param string|int|float $entityTypeId
233226 * @param float|int $id
234227 * @return false|string
@@ -249,6 +242,8 @@ public function getAttributeSetName($entityTypeId, $id)
249242 }
250243
251244 /**
245+ * Returns Attribute's Set ID
246+ *
252247 * @param string|int|float $entityTypeId
253248 * @param string|null $name
254249 * @return false|string|int
@@ -263,13 +258,15 @@ public function getAttributeSetId($entityTypeId, $name = null)
263258 if (!is_numeric ($ entityTypeId )) {
264259 $ entityTypeId = $ this ->getEntityType ($ entityTypeId )->getId ();
265260 }
266- $ name = strtolower ($ name );
261+ $ name = $ name !== null ? strtolower ($ name ) : '' ;
267262 return isset (
268263 $ this ->_attributeSetsByName [$ entityTypeId ][$ name ]
269264 ) ? $ this ->_attributeSetsByName [$ entityTypeId ][$ name ] : false ;
270265 }
271266
272267 /**
268+ * Loads all attribute Groups
269+ *
273270 * @return $this
274271 */
275272 public function loadAttributeGroups ()
@@ -292,6 +289,8 @@ public function loadAttributeGroups()
292289 }
293290
294291 /**
292+ * Returns the Attribute's Group Name
293+ *
295294 * @param float|int|string $attributeSetId
296295 * @param float|int|string $id
297296 * @return bool|string
@@ -313,6 +312,8 @@ public function getAttributeGroupName($attributeSetId, $id)
313312 }
314313
315314 /**
315+ * Returns the Attribute's Group ID
316+ *
316317 * @param float|int|string $attributeSetId
317318 * @param string $name
318319 * @return bool|string|int|float
@@ -328,13 +329,15 @@ public function getAttributeGroupId($attributeSetId, $name)
328329 if (!is_numeric ($ attributeSetId )) {
329330 $ attributeSetId = $ this ->getAttributeSetId ($ attributeSetId );
330331 }
331- $ name = strtolower ($ name );
332+ $ name = $ name !== null ? strtolower ($ name ) : '' ;
332333 return isset (
333334 $ this ->_attributeGroupsByName [$ attributeSetId ][$ name ]
334335 ) ? $ this ->_attributeGroupsByName [$ attributeSetId ][$ name ] : false ;
335336 }
336337
337338 /**
339+ * Loads all product types
340+ *
338341 * @return $this
339342 */
340343 public function loadProductTypes ()
@@ -356,6 +359,8 @@ public function loadProductTypes()
356359 }
357360
358361 /**
362+ * Returns ID of the Product Type
363+ *
359364 * @param string $name
360365 * @return false|string
361366 */
@@ -367,11 +372,13 @@ public function getProductTypeId($name)
367372
368373 $ this ->loadProductTypes ();
369374
370- $ name = strtolower ($ name );
375+ $ name = $ name !== null ? strtolower ($ name ) : '' ;
371376 return isset ($ this ->_productTypesByName [$ name ]) ? $ this ->_productTypesByName [$ name ] : false ;
372377 }
373378
374379 /**
380+ * Returns the name of Product Type
381+ *
375382 * @param float|int|string $id
376383 * @return false|string
377384 */
@@ -387,6 +394,8 @@ public function getProductTypeName($id)
387394 }
388395
389396 /**
397+ * Return Source option ID if exists
398+ *
390399 * @param \Magento\Framework\DataObject $source
391400 * @param string $value
392401 * @return null|mixed
@@ -468,8 +477,7 @@ public function getAttributesUsedForSortBy()
468477 }
469478
470479 /**
471- * Retrieve Attributes Used for Sort by as array
472- * key = code, value = name
480+ * Retrieve Attributes Used for Sort by as array: key = code, value = name
473481 *
474482 * @return array
475483 */
0 commit comments