# scandipwa/performance

> N/A

`composer require scandipwa/performance`

Canonical URL: https://packagento.com/scandipwa/performance

## At a glance

- **Vendor**: scandipwa (https://packagento.com/scandipwa.md)
- **Latest version**: 1.5.7 — released 2022-11-23
- **Pricing**: Free
- **Package type**: Magento 2 module
- **Status**: active, accepting new buyers

## Installation

Packagento is licence-gated, so even free packages need a licence on a project before Composer can resolve them.

1. **Sign in or create an account** at https://packagento.com/customer/account/.

2. **Add the package to your account.** Open https://packagento.com/scandipwa/performance and complete the free checkout. A licence is minted automatically.

3. **Create or pick a project, then activate the licence on it.**
   - Projects represent the Magento installs you deploy to. Manage them at https://packagento.com/projects/.
   - Activate the new licence on the project you'll deploy this package to. Activation is what generates the Composer credentials scoped to that project.

4. **Add the project credentials to your Magento codebase.**

   Grab the project's public + private key from https://packagento.com/projects/ (open the project, then its Credentials tab), and add them to `auth.json`:

   ```json
   {
     "http-basic": {
       "packagento.com": {
         "username": "ppk_live_...",
         "password": "psk_live_..."
       }
     }
   }
   ```

   Add the Packagento Composer repository to `composer.json`:

   ```json
   {
     "repositories": [
       { "type": "composer", "url": "https://packagento.com" }
     ]
   }
   ```

5. **Install and apply.**

   ```bash
   composer require scandipwa/performance:*
   bin/magento setup:upgrade
   bin/magento setup:di:compile
   bin/magento cache:flush
   ```

## What it does

N/A

## README

Enhanced performance of product loading.

#### How to use

When adding a new resolved field to product interface, make sure to:
1. Understand when you are able to load it? If you can load it on collection, 
create a processor and register it in `CompositeCollectionProcessor` using DI.
2. If data is needed to be formatted, or you can not request data with collection,
use `DataPostProcessor`. Register a processor there, and return a product (as key => value array)
processing function (see example in implementations).
3. If data is impossible to request before collection load, but it is possible to append
the loaded data afterwards (using the collection itself) - use `CollectionPostProcessor`, register 
the processor there in the same way as for `DataPostProcessor`.

#### Related modules:

- [quote-graphql](https://github.com/scandipwa/quote-graphql)
- [wishlist-graphql](https://github.com/scandipwa/wishlist-graphql)
- [catalog-graphql](https://github.com/scandipwa/catalog-graphql)
- [reviews-graphql](https://github.com/scandipwa/reviews-graphql)

#### Initial motivation:

> CASE ONE: The data can not be requested along with product collection
> (**only post-load is possible**)

1. After collection load, checked for requested fields in schema (using $info) for each additional info category
2. If additional info was requested, the helper requested & returned the info for all products at once
3. The loop through all loaded products applying data from helpers to each specific product

> CASE TWO: The data can be requested before load
>(**field can be resolved with collection load**)

**This one is covered by M2 (by default) - we will just ignore this.**

1. The collection processor goes through collection, it adds requested fields to a collection
2. If field requires additional work, it is formatted after collection load
3. If field needs no formatting it is automatically out-putted in resulting data array

> CASE THREE: The data can be requested after collection load,
> but is based on the collection data, not product array.

#### Potential Issues 

a. The code duplicates in each of 5 places were the collection was loaded [REQUIRES ABSTRACTION]
b. The data structures are common to be different from place to place, a check if field was requested or no is hard:
1. ConfigurableVariant: `variants/product`
2. Default: `products/items`
3. Cart, Wish-list: `items/product`
4. Orders: `order_products`

### What was implemented

#### GraphQL schema reading trait _[new]_

**Class name**: `ScandiPWA\Performance\Model\Resolver\ResolveInfoFieldsTrait`

**Motivation**: allows for GraphQL info parsing, can extract fields from path.
By default returns array of product fields, the product field parsing can be 
changed by overriding `getFieldContent` method.

**Used in**:

1. `ScandiPWA\Performance\Model\Resolver\Products\DataPostProcessor\Images`
2. `ScandiPWA\Performance\Model\Resolver\Products\DataPostProcessor\Stocks`
3. `ScandiPWA\Performance\Model\Resolver\Products\DataPostProcessor\Attributes`
4. `ScandiPWA\CatalogGraphQl\Model\Resolver\ConfigurableVariant`
5. `ScandiPWA\CatalogGraphQl\Model\Resolver\Products\Query\Filter`
6. `ScandiPWA\WishlistGraphQl\Model\Resolver\WishlistItemsResolver`
7. `ScandiPWA\QuoteGraphQl\Model\Resolver\ProductsResolver`

#### Collection post processor _[new]_

**Class name**: `ScandiPWA\Performance\Model\Resolver\Products\CollectionPostProcessor`

**Motivation**: allows to post-process collection, for situations, where data is
applied on-top of loaded collection - media gallery data, product options data, etc.

**Used in**: 

1. `ScandiPWA\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product`
2. `ScandiPWA\CatalogGraphQl\Model\Variant\Collection`

#### Data post processor _[new]_

**Class name**: `ScandiPWA\Performance\Model\Resolver\Products\DataPostProcessor`

**Motivation**: allows for loaded product collection data post-processing. Accepts
array of products, resolve info and can efficiently process the product data.
Is made to prevent child fields of products to request the data in the loop.
Attribute, image, stock info is moved to this resolver out of product.

**Used in**:

1. `ScandiPWA\WishlistGraphQl\Model\Resolver\WishlistItemsResolver`
2. `ScandiPWA\QuoteGraphQl\Model\Resolver\GetCartForCustomer`
3. `ScandiPWA\CatalogGraphQl\Model\Resolver\Products\Query\Filter`
4. `ScandiPWA\QuoteGraphQl\Model\Resolver\ProductsResolver`
5. `ScandiPWA\CatalogGraphQl\Model\Resolver\ConfigurableVariant`

#### Product data provider _[modified]_

**Class name**: `ScandiPWA\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product`

**Motivation**: previously the collection post processor was implemented here (hard-coded).
Since it was moved into separate class, the logic had to be removed from origin.

**Used in**:

1. `ScandiPWA\QuoteGraphQl\Model\Resolver\ProductsResolver`
2. `ScandiPWA\CatalogGraphQl\Model\Resolver\Products\Query\Filter`

#### Products Collection processor _[modified]_

**Class name**: `Magento\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\CompositeCollectionProcessor`

**Motivation**: The M2 implementation was OK, just added additional processors to it:
1. `ScandiPWA\CatalogGraphQl\Model\Resolver\Products\DataProvider\Product\CollectionProcessor\ImagesProcessor`

## Recent Versions

| Version | Released |
|---|---|
| 1.5.7 | 2022-11-23 |
| 1.5.6 | 2022-06-09 |
| 1.5.5 | 2021-12-30 |
| 1.5.4 | 2021-12-29 |
| 1.5.3 | 2021-12-09 |
| 1.5.2 | 2021-10-26 |
| 1.5.1 | 2021-09-28 |
| 1.5.0 | 2021-09-21 |
| 1.4.6 | 2021-07-01 |
| 1.4.5 | 2021-06-28 |

Showing 10 of 23 versions. Full release history on https://packagento.com/scandipwa/performance.

## Dependencies

### Require

| Package | Constraint |
|---|---|
| magento/framework | * |
| magento/module-catalog | * |
| magento/module-catalog-graph-ql | ^100.3 |
| magento/module-catalog-inventory | * |
| magento/module-eav | * |
| magento/module-inventory-api | * |
| magento/module-inventory-catalog | * |
| magento/module-store | * |
| magento/module-swatches | * |

## Quality

Latest release (1.5.7) fails the Packagento QA pipeline. Verdicts below are per-cell (Magento line × PHP version) for the matrixed tools, and run-once for the static / security tiers.


### Compatibility

Each Magento line is installed on its supported PHP versions, then the module is built (DI compile + static-content deploy). Cells show passed / failed / untested; staircase gaps render as `–`.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | Pass | Pass | – | – |
| 2.4.8 | – | Pass | 1 | – |
| 2.4.9 | – | – | 1 | 1 |


### Code Quality

Advisory checks against the module's source. Never affect the Compatibility verdict — a phpcs finding can't make a module incompatible.

#### Static Analysis

Coding standards (phpcs), mess detection (phpmd), copy-pasted code (cpd), PHP cross-version compatibility, composer.json validity. Each runs once for the whole module.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| PHPCS | Warning | 20 | 20 warnings (ruleset: Magento2) — 7 auto-fixable with phpcbf |
| PHPMD | Warning | 12 | 12 rule violations (CyclomaticComplexity:3, NPathComplexity:3, ExcessiveMethodLength:3, UnusedLocalVariable:2, ExcessiveClassComplexity:1) |
| Cpd | Pass | 0 |  |
| Composer validate | Info | 8 | valid; 8 advisory notes (composer validate --strict) |

#### PHPStan

Type-checks the module against a real Magento install. Re-runs per Magento + PHP version because resolvable symbols differ between releases.

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | 10 | 10 | – | – |
| 2.4.8 | – | 10 | 12 | – |
| 2.4.9 | – | – | 12 | 12 |


### Tests

Unit and integration suites run per Magento + PHP cell. Test failures speak to the module's behaviour, not its compatibility with a line, so they're reported here separately.

#### Unit Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |

#### Integration Tests

| Magento | PHP 8.2 | PHP 8.3 | PHP 8.4 | PHP 8.5 |
|---|---|---|---|---|
| 2.4.7 | N/A | N/A | – | – |
| 2.4.8 | – | N/A | N/A | – |
| 2.4.9 | – | – | N/A | N/A |


### Security

Dependency-advisory audit (composer audit) plus a source malware scan. A malware detection fails the version outright.

| Tool | Status | Findings | Summary |
|---|---|---|---|
| Composer audit | Pass | 0 |  |
| Malware scan | Pass | 0 |  |

## Licence and pricing

Free. A licence is still minted on checkout and bound to your project for Composer access — no payment step.

Refundable within 14 days of first purchase via https://packagento.com/account/refunds/.

## Install via Claude Code or any MCP client

The Packagento MCP server can run the licence + project + Composer steps above in one tool call:

```
purchase_and_install_packages(
  composer_names=["scandipwa/performance"],
  project_id="proj_xxx"
)
```

This handles cart, checkout, licence minting, project activation, and writes auth.json credentials. Connect a client with `claude mcp add packagento https://mcp.packagento.com`. Full setup at https://packagento.com/docs/mcp-setup.

## Vendor

scandipwa is a Magento 2 vendor on Packagento. See https://packagento.com/scandipwa.md for their full catalogue.

