CoolCMS API

AdvertPriceColumnTrait

Fills the denormalized column `advert.price` from the `price` parameter.

The price is a dynamic parameter (parameterRels) that cannot be indexed or sorted quickly. The column is filled in beforeSave directly from the object-graph collection $advert->getParameterRels(). At that point (beforeSave runs after hydrateForPersist in Api/Presenters/SaveTrait::internalActionSave) the collection is already fully merged with the submitted values, so the current state is always read, whether this save touched the collection or not, and the price is stored in the same INSERT/UPDATE as the rest of the advert.

NOTE: currencies are not compared; the bare number is stored without conversion.

Tags
requires

AdvertManager expects:

  • $parameterManager->findAll(...) (ParameterManager)

Table of Contents

Methods

applyPriceColumn()  : void
Extracts the price parameter value from `$advert->getParameterRels()` and writes it into the scalar column `advert.price`.
normalizePrice()  : float|null
Normalizes "1 500,50" to 1500.5; empty or non-numeric (negotiable) gives null.
resolvePriceParameterId()  : int|null

Methods

applyPriceColumn()

Extracts the price parameter value from `$advert->getParameterRels()` and writes it into the scalar column `advert.price`.

private applyPriceColumn(Advert $advert) : void
Parameters
$advert : Advert

normalizePrice()

Normalizes "1 500,50" to 1500.5; empty or non-numeric (negotiable) gives null.

private normalizePrice(mixed $raw) : float|null
Parameters
$raw : mixed
Return values
float|null
On this page

Search results