GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

extractWebsiteIds()   D
last analyzed

Complexity

Conditions 9
Paths 38

Size

Total Lines 36
Code Lines 17

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 36
rs 4.909
cc 9
eloc 17
nc 38
nop 2
1
<?php
2
/**
3
 * Copyright (c) 2013-2014 eBay Enterprise, Inc.
4
 *
5
 * NOTICE OF LICENSE
6
 *
7
 * This source file is subject to the Open Software License (OSL 3.0)
8
 * that is bundled with this package in the file LICENSE.md.
9
 * It is also available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * @copyright   Copyright (c) 2013-2014 eBay Enterprise, Inc. (http://www.ebayenterprise.com/)
13
 * @license     http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
14
 */
15
16
/**
17
 * Functions to help import EB2C attributes into Magento product attributes.
18
 *
19
 * Each function is passed a DOMNodeList of nodes matching the configured xpath expression and the product object currently being processed.
20
 *
21
 * @example: public function prototypicalMapFunction(DOMNodeList $nodes, Mage_Catalog_Model_Product $product);
22
 *
23
 * <code>
24
 * // Return the mapped type_id if the product doesn't already have one.
25
 * // Otherwise return the product's existing value.
26
 * public function getTypeIdIfNew(DOMNodeList $nodes, Mage_Catalog_Model_Product $product)
27
 * {
28
 *   return $product->getTypeId() ?: $nodes->item(0)->nodeValue;
29
 * }
30
 * </code>
31
 */
32
class EbayEnterprise_Catalog_Helper_Map
33
{
34
    const TYPE_GIFTCARD = 'giftcard';
35
36
    /** @var EbayEnterprise_MageLog_Helper_Data */
37
    protected $logger;
38
    /** @var EbayEnterprise_MageLog_Helper_Context */
39
    protected $context;
40
    /** @var EbayEnterprise_Eb2cCore_Helper_Data */
41
    protected $coreHelper;
42
    /** @var EbayEnterprise_Catalog_Helper_Data */
43
    protected $catalogHelper;
44
45
    /**
46
     * Map ownerDocuments to DomXPath objects to avoid recreating them.
47
     *
48
     * @var SplObjectStorage
49
     */
50
    protected $_splStorageDocMap = null;
51
    /**
52
     * Keep from having to reinstantiate this collection when doing the product imports.
53
     *
54
     * @var Mage_Catalog_Model_Resource_Category_Collection
55
     */
56
    protected $_categoryCollection = null;
57
58 View Code Duplication
    public function __construct(array $initParams = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
    {
60
        list(
61
            $this->coreHelper,
62
            $this->catalogHelper,
63
            $this->logger,
64
            $this->context
65
        ) = $this->checkTypes(
66
            $this->nullCoalesce($initParams, 'core_helper', Mage::helper('eb2ccore')),
67
            $this->nullCoalesce($initParams, 'catalog_helper', Mage::helper('ebayenterprise_catalog')),
68
            $this->nullCoalesce($initParams, 'logger', Mage::helper('ebayenterprise_magelog')),
69
            $this->nullCoalesce($initParams, 'context', Mage::helper('ebayenterprise_magelog/context'))
70
        );
71
    }
72
73
    /**
74
     * Type hinting for self::__construct $initParams
75
     *
76
     * @param  EbayEnterprise_Eb2cCore_Helper_Data
77
     * @param  EbayEnterprise_Catalog_Helper_Data
78
     * @param  EbayEnterprise_MageLog_Helper_Data
79
     * @param  EbayEnterprise_MageLog_Helper_Context
80
     * @return array
81
     */
82
    protected function checkTypes(
0 ignored issues
show
Unused Code introduced by
The method parameter $coreHelper is never used
Loading history...
Unused Code introduced by
The method parameter $logger is never used
Loading history...
Unused Code introduced by
The method parameter $context is never used
Loading history...
Unused Code introduced by
The method parameter $catalogHelper is never used
Loading history...
83
        EbayEnterprise_Eb2cCore_Helper_Data $coreHelper,
0 ignored issues
show
Unused Code introduced by
The parameter $coreHelper is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
84
        EbayEnterprise_Catalog_Helper_Data $catalogHelper,
0 ignored issues
show
Unused Code introduced by
The parameter $catalogHelper is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
85
        EbayEnterprise_MageLog_Helper_Data $logger,
0 ignored issues
show
Unused Code introduced by
The parameter $logger is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
86
        EbayEnterprise_MageLog_Helper_Context $context
0 ignored issues
show
Unused Code introduced by
The parameter $context is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
87
    )
88
    {
89
        return func_get_args();
90
    }
91
92
    /**
93
     * Return the value at field in array if it exists. Otherwise, use the default value.
94
     *
95
     * @param  array
96
     * @param  string $field Valid array key
97
     * @param  mixed
98
     * @return mixed
99
     */
100
    protected function nullCoalesce(array $arr, $field, $default)
101
    {
102
        return isset($arr[$field]) ? $arr[$field] : $default;
103
    }
104
105
    /**
106
     * check if the node list has item and if the first item node value equal to 'active' to return
107
     * the status for enable otherwise status for disable
108
     * @param DOMNodeList $nodes
109
     * @return string
110
     */
111
    public function extractStatusValue(DOMNodeList $nodes)
112
    {
113
        return ($nodes->length && strtolower($nodes->item(0)->nodeValue) === 'active')?
114
            Mage_Catalog_Model_Product_Status::STATUS_ENABLED:
115
            Mage_Catalog_Model_Product_Status::STATUS_DISABLED;
116
    }
117
    /**
118
     * extracts visibility from node list, returning an expected integer or translating an expected string
119
     * into an expected integer, returning null for unexpected values
120
     * @param DOMNodeList $nodes
121
     * @return int|null
122
     */
123
    public function extractVisibilityValue(DOMNodeList $nodes, Mage_Catalog_Model_Product $product)
124
    {
125
        $visibilityValues = [
126
            'Not Visible Individually' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE,
127
            'Catalog' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG,
128
            'Search' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_SEARCH,
129
            'Catalog, Search' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
130
        ];
131
132
        $visibility = $this->coreHelper->extractNodeVal($nodes);
133
134
        if (in_array($visibility, $visibilityValues)) {
135
            // If the value is an expected integer value, return that value
136
            return $visibility;
137
        } elseif (isset($visibilityValues[$visibility])) {
138
            // If the value is an expected string value, return the associated integer
139
            return $visibilityValues[$visibility];
140
        } else {
141
            // If the value is unexpected, return the current value
142
            return $product->getVisibility();
143
        }
144
    }
145
    /**
146
     * extract the first element of a dom node list make sure it is lower case
147
     * if there's no item in the DOMNodeList return the default simple product type constant value
148
     *
149
     * @param DOMNodeList $nodes
150
     * @param Mage_Catalog_Model_Product $product
151
     * @return string
152
     */
153
    public function extractProductTypeValue(DOMNodeList $nodes, Mage_Catalog_Model_Product $product)
154
    {
155
        $value = strtolower($this->coreHelper->extractNodeVal($nodes));
156
        $type = ($this->_isValidProductType($value))? $value : Mage_Catalog_Model_Product_Type::TYPE_SIMPLE;
157
        $product->setTypeId($type)
158
            ->setTypeInstance(Mage_Catalog_Model_Product_Type::factory($product, true), true);
159
        return $type;
160
    }
161
162
    /**
163
     * check if a given string is a valid product type value
164
     * @param string $value the value that must match one of magento product type
165
     * @return bool true the value match magento product type otherwise false
166
     */
167
    protected function _isValidProductType($value)
168
    {
169
        return in_array($value, array(
170
            self::TYPE_GIFTCARD,
171
            Mage_Catalog_Model_Product_Type::TYPE_SIMPLE,
172
            Mage_Catalog_Model_Product_Type::TYPE_BUNDLE,
173
            Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE,
174
            Mage_Catalog_Model_Product_Type::TYPE_GROUPED,
175
            Mage_Catalog_Model_Product_Type::TYPE_VIRTUAL,
176
        ));
177
    }
178
179
    /**
180
     * This should produce a serialized array of product links to be handled by
181
     * the product cleaner. Arrays should consist of
182
     *
183
     * @param DOMNodeList $nodes DOM nodes extracted from the feed
184
     * @return string Serialized array
185
     */
186
    public function extractProductLinks(DOMNodeList $nodes)
187
    {
188
        $links = array();
189
        foreach ($nodes as $linkNode) {
190
            $attrs = $linkNode->attributes;
191
            try {
192
                $linkType = $this->_convertToMagentoLinkType($attrs->getNamedItem('link_type')->nodeValue);
193
            } catch (Mage_Core_Exception $e) {
194
                // If the link_type in the feed dosn't match a known link type, do not
195
                // include it and move on to the next link.
196
                continue;
197
            }
198
            $links[] = array(
199
                'link_type' => $linkType,
200
                'operation_type' => $attrs->getNamedItem('operation_type')->nodeValue,
201
                'link_to_unique_id' => Mage::helper('ebayenterprise_catalog')->normalizeSku(
202
                    trim($linkNode->nodeValue),
203
                    $this->coreHelper->getConfigModel()->catalogId
0 ignored issues
show
Documentation introduced by
The property catalogId does not exist on object<EbayEnterprise_Eb..._Model_Config_Registry>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
204
                )
205
            );
206
        }
207
        return serialize($links);
208
    }
209
    /**
210
     * Convert the EB2C link types to link types Magento knows about through a
211
     * mapping in the product config.xml.
212
     * @param  string $linkType
213
     * @return string
214
     * @throws Mage_Core_Exception If the link type is not mapped to a Magento link type
215
     */
216
    protected function _convertToMagentoLinkType($linkType)
217
    {
218
        return Mage::helper('ebayenterprise_catalog')->getConfigModel()->getConfig(strtolower("link_types_$linkType"));
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $linkType instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
219
    }
220
221
    /**
222
     * extract the value in the nodelist and then passed it to helper
223
     * function to ensure the value has the right info
224
     * @param DOMNodeList $nodes
225
     * @return string
226
     */
227
    public function extractSkuValue(DOMNodeList $nodes)
228
    {
229
        $coreHelper = $this->coreHelper;
230
        return Mage::helper('ebayenterprise_catalog')->normalizeSku(
231
            $coreHelper->extractNodeVal($nodes),
232
            $coreHelper->getConfigModel()->catalogId
0 ignored issues
show
Documentation introduced by
The property catalogId does not exist on object<EbayEnterprise_Eb..._Model_Config_Registry>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
233
        );
234
    }
235
    /**
236
     * extract the the title value from the DOMNodelist object if value not empty
237
     * simply append the store id and return the vlaue. if the value is empty
238
     * append the a know string string with the sku and the store id and return
239
     * @param DOMNodeList $nodes
240
     * @param Mage_Catalog_Model_Product $product
241
     * @return string
242
     */
243
    public function extractUrlKeyValue(DOMNodeList $nodes, Mage_Catalog_Model_Product $product)
244
    {
245
        $urlKey = $this->coreHelper->extractNodeVal($nodes);
246
        return ($urlKey !== '')?
247
            $urlKey . '-' . $product->getStoreId() :
248
            'Incomplete Product: ' . $product->getSku() . '-' . $product->getStoreId();
249
    }
250
    /**
251
     * given a gift card type return the gift card constant mapped to it
252
     * @param string $type the gift card type in this set (virtual, physical or combined)
253
     * @see Enterprise_GiftCard_Model_Giftcard
254
     * @return int|null
255
     */
256 View Code Duplication
    protected function _getGiftCardType($type)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
257
    {
258
        switch ($type) {
259
            case self::GIFTCARD_PHYSICAL:
260
                return Enterprise_GiftCard_Model_Giftcard::TYPE_PHYSICAL;
261
            case self::GIFTCARD_COMBINED:
262
                return Enterprise_GiftCard_Model_Giftcard::TYPE_COMBINED;
263
            default:
264
                return Enterprise_GiftCard_Model_Giftcard::TYPE_VIRTUAL;
265
        }
266
    }
267
    /**
268
     * extract the giftcard tender code from the DOMNOdeList object get its map value
269
     * from the config and then return the actual constant to the know magento gift card sets
270
     * @param DOMNodeList $nodes
271
     * @return int|null integer value a valid tender type was extracted null tender type is not configure
272
     */
273
    public function extractGiftcardTenderValue(DOMNodeList $nodes)
274
    {
275
        $value = $this->coreHelper->extractNodeVal($nodes);
276
        $cfg = Mage::helper('ebayenterprise_catalog')->getConfigModel();
277
        $mapData = $cfg->getConfigData(EbayEnterprise_Catalog_Helper_Feed::GIFTCARD_TENDER_CONFIG_PATH);
278
        return isset($mapData[$value])? $this->_getGiftCardType($mapData[$value]) : null;
279
    }
280
281
    /**
282
     * given DOMNodeList object containing htscode data extract the htscode data
283
     * into an array of array of keys and return a serialize string of the build array of htscode data
284
     * @param DOMNodeList $nodes
285
     * @return string a serialize string of array of htscodes
286
     */
287
    public function extractHtsCodesValue(DOMNodeList $nodes)
288
    {
289
        $htscodes = array();
290
        foreach ($nodes as $item) {
291
            $htscodes[] = array(
292
                'mfn_duty_rate' => $item->getAttribute('mfn_duty_rate'),
293
                'destination_country' => $item->getAttribute('destination_country'),
294
                'restricted' => $item->getAttribute('restricted'),
295
                'hts_code' => $item->nodeValue
296
            );
297
        }
298
        return serialize($htscodes);
299
    }
300
301
    /**
302
     * extract the attribute set name
303
     *
304
     * @param DOMNodeList $nodes
305
     * @param Mage_Catalog_Model_Product $product
306
     * @return int
307
     */
308
    public function extractAttributeSetValue(DOMNodeList $nodes, Mage_Catalog_Model_Product $product)
309
    {
310
        $attributeSetName = $this->coreHelper->extractNodeVal($nodes);
311
        $attributeSetId = Mage::helper('ebayenterprise_catalog')->getAttributeSetIdByName($attributeSetName);
312
        if (is_null($attributeSetId)) {
313
            // @todo: move to error confirmation feed
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
314
            $logData = ['attribute_set_name' => $attributeSetName];
315
            $logMessage = 'Attribute Set "{attribute_set_name}" has not yet been setup for this Magento instance.';
316
            $this->logger->warning($logMessage, $this->context->getMetaData(__CLASS__, $logData));
317
        }
318
        return $attributeSetId ?: $product->getAttributeSetId();
319
    }
320
    /**
321
     * extract the first element of a dom node list and return a string value
322
     * @param DOMNodeList $nodes
323
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
324
     */
325
    public function extractStringValue(DOMNodeList $nodes)
326
    {
327
        return ($nodes->length)? $nodes->item(0)->nodeValue : null;
328
    }
329
    /**
330
     * extract the first element of a dom node list and return a boolean
331
     * value of the extract string
332
     * @param DOMNodeList $nodes
333
     * @return bool
334
     */
335
    public function extractBoolValue(DOMNodeList $nodes)
336
    {
337
        return $this->coreHelper->parseBool(($nodes->length)? $nodes->item(0)->nodeValue : null);
338
    }
339
    /**
340
     * extract the first element of a dom node list and return the string value cast as integer value
341
     * @param DOMNodeList $nodes
342
     * @return int
343
     */
344
    public function extractIntValue(DOMNodeList $nodes)
345
    {
346
        return ($nodes->length)? (int) $nodes->item(0)->nodeValue : 0;
347
    }
348
    /**
349
     * extract the first element of a dom node list and return the string value cast as float value
350
     * @param DOMNodeList $nodes
351
     * @return int
0 ignored issues
show
Documentation introduced by
Should the return type not be double|integer?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
352
     */
353
    public function extractFloatValue(DOMNodeList $nodes)
354
    {
355
        return ($nodes->length)? (float) $nodes->item(0)->nodeValue : 0;
356
    }
357
    /**
358
     * it return the pass in value parameter
359
     * it's a callback to return static value set in the config
360
     * @param mixed $value
361
     * @return mixed
362
     */
363
    public function passThrough($value)
364
    {
365
        return $value;
366
    }
367
    /**
368
     * Always return false.
369
     * This is useful for clearing a value to have it fallback to a higher scope.
370
     */
371
    public function extractFalse()
372
    {
373
        return false;
374
    }
375
376
    /**
377
     * return a sum of the data for all elements retrieved by the xpath.
378
     * @param DOMNodeList $nodes
379
     * @return float
380
     */
381
    public function extractFloatSum(DOMNodeList $nodes)
382
    {
383
        $sum = 0.0;
384
        foreach ($nodes as $node) {
385
            $sum += (float) $node->nodeValue;
386
        }
387
        return $sum;
388
    }
389
390
    /**
391
     * Return a negative sum of the data for all elements retrieved by the xpath.
392
     * Used to get a negative amount for discount sums.
393
     * @param DOMNodeList $nodes
394
     * @return float
395
     */
396
    public function extractDiscountSum(DOMNodeList $nodes)
397
    {
398
        return -$this->extractFloatSum($nodes);
399
    }
400
401
    /**
402
     * extract all custom attributes and set it to the passed in product object.
403
     *
404
     * @param  DOMNodeList
405
     * @param  Mage_Catalog_Model_Product
406
     * @return null
407
     */
408
    public function extractCustomAttributes(DOMNodeList $nodes, Mage_Catalog_Model_Product $product)
409
    {
410
        /** @var DOMElement $node */
411
        foreach ($nodes as $node) {
412
            /** @var string $attribute */
413
            $attribute = trim($node->getAttribute('name'));
414
            /** @var string $value */
415
            $value = trim($node->nodeValue);
416
            if ($attribute && $value) {
417
                $product->setData($attribute, $value);
418
            }
419
        }
420
    }
421
422
    /**
423
     * If the "ExtendedAttributes/AllowGiftMessage" node exist then we proceed
424
     * to set the product attribute "use_config_gift_message_available" to false
425
     * and return the boolean value of the "ExtendedAttributes/AllowGiftMessage" node.
426
     * Otherwise, if the "ExtendedAttributes/AllowGiftMessage" node doesn't exists
427
     * we simply return null in order to let the default value be set on the attribute.
428
     *
429
     * @param  DOMNodeList
430
     * @param  Mage_Catalog_Model_Product
431
     * @return int | null
0 ignored issues
show
Documentation introduced by
Should the return type not be integer|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
432
     */
433
    public function extractAllowGiftMessage(DOMNodeList $nodes, Mage_Catalog_Model_Product $product)
434
    {
435
        if ($nodes->length) {
436
            $product->setUseConfigGiftMessageAvailable(0);
437
            // Explicitly casting the extracted boolean value as an integer value because
438
            // Magento only work with integer value 0 or 1 representing boolean value in the database.
439
            return (int) $this->coreHelper->parseBool(($nodes->length)? $nodes->item(0)->nodeValue : null);
440
        }
441
        return null;
442
    }
443
444
    /**
445
     * Map an array of website ids the product should be linked to, based upon
446
     * the item's client id, catalog id and/or store id.
447
     *
448
     * @param DOMNodeList
449
     * @param Mage_Catalog_Model_Product
450
     * @return array
451
     */
452
    public function extractWebsiteIds(DOMNodeList $nodes, Mage_Catalog_Model_Product $product)
453
    {
454
        $websiteIds = $product->getWebsiteIds();
455
456
        $itemNode = $nodes->item(0);
457
458
        // If there's no node to get data from, just let website ids remain
459
        // what it is.
460
        if (!$itemNode) {
461
            return $websiteIds;
462
        }
463
464
        $clientId = $itemNode->getAttribute('gsi_client_id');
465
        $catalogId = $itemNode->getAttribute('catalog_id');
466
        $storeId = $itemNode->getAttribute('gsi_store_id');
467
468
        $websites = $this->catalogHelper->loadWebsiteFilters();
469
470
        foreach ($websites as $websiteFilter) {
471
472
            $websiteId = $websiteFilter['mage_website_id'];
473
            // Assume no value in feed is a wildcard.
474
            $matches = !$catalogId || $catalogId === $websiteFilter['catalog_id'];
475
            $matches = $matches && (!$clientId || $clientId === $websiteFilter['client_id']);
476
            $matches = $matches && (!$storeId || $storeId === $websiteFilter['store_id']);
477
478
            // Just add any matched websites to the list, ignoring that this
479
            // might end up with dupes, list will be made unique when returned.
480
            if ($matches) {
481
                $websiteIds[] = $websiteId;
482
            }
483
484
        }
485
486
        return array_unique($websiteIds);
487
    }
488
}
489