Article
extends Basic
in package
Uses
Images, MainFolder
Implement article master object
This class provides general interfaces to handle the shop article content.
Tags
Table of Contents
- $ : bool
- $amount : int
- $folder : FolderTree|null
- Buffer for linked main folder
- $ignore_hash_fields : array<string|int, mixed>
- $relation_id : string|null
- $_alternatives : array<string|int, mixed>|null
- List of alternatives, is cached
- $_brands : array<string|int, mixed>|null
- Buffer of brand articles
- $_bundle_articles : array<string|int, mixed>|null
- Storage for bundle article resolver
- $active_vouchers : array<string|int, mixed>
- Apply some active vouchers based on basket context
- $brand : string|null
- Buffer active brand
- $bundle_config : array<string|int, mixed>
- $periods_table : array<string|int, mixed>|null
- $price_table : array<string|int, mixed>|null
- $resource : null|false|BookableResource
- $trail_duration : int
- __construct() : mixed
- Article constructor.
- ActiveBrand() : string|null
- In context of a purchase the brand can be activated
- ActiveBrandArticle() : Article|null
- ActiveBundleConfig() : array<string|int, mixed>
- ActiveVouchers() : array<string|int, Voucher>
- Get / set active vouchers
- ActiveVouchersAffiliate() : Company|null
- Alternatives() : array<string|int, mixed>
- Get alternative article ids of this article
- AssignedSubscription() : bool
- AssignImage() : Result
- Assign an image from instance
- Author() : User|null
- Get the original author of the task
- Brands() : array<string|int, Article>
- Get the brands the article has as article internal alternatives
- BundleArticle() : array<string|int, mixed>|null
- BundleArticles() : array<string|int, mixed>
- Get bundle articles
- Category() : array<string|int, mixed>|null
- Copy() : Result|null
- CreateExtra() : Result
- Create a new extra
- DeleteExtra() : Result
- Delete the extra
- FetchExtras() : Result
- Fetch extra list
- Frames() : array<string|int, mixed>|null
- Get the plain frames list if it is not empty
- GeneralSearchFields() : array<string|int, mixed>
- The general search fields
- GetAmountOptions() : array<string|int, mixed>|null
- List of possible selectable options for this article
- GetExtra() : Result
- Fetch single extra
- GetPrice() : array<string|int, mixed>
- Get price by amount and/or date
- GetPriceFormatted() : string
- Get formatted price of instance
- GetPrimaryPicture() : Asset|null
- Get the primary picture
- GetTrailPriceFormatted() : string
- Get formatted trail price of instance
- HasAlternatives() : bool
- Has alternative articles?
- Hash() : string
- Generate hash of current contents
- Images() : array<string|int, mixed>|array<string|int, Asset>
- List images
- Interval() : null|array<string|int, mixed>
- Get interval
- IsBundle() : bool
- Is a bundle
- IsInterval() : bool
- Return boolean status of interval
- MainFolder() : Folder|null
- Resolve the main project of this article
- MainFolderRelation() : string|null
- MainImage() : Asset|null
- Get main image
- MasterEvent() : BookableResource|bool|null
- Name() : string|null
- Number() : string|null
- Get the article number
- PeriodTable() : array<string|int, mixed>|null
- Persons() : int
- Count the persons that are part of this bundled article
- PriceTable() : array<string|int, mixed>|null
- Get price list
- RequestedFrameSize() : int
- Get the requested room size
- RequestedMainFrame() : string
- Get fitting target room article id
- RequiredPurchases() : array<string|int, mixed>|null
- List of required purchases the article needs beforehand
- Save() : Result
- Save changes and clear caches
- SearchFields() : mixed
- SpecificTrail() : int
- Calculate specific trail duration based on relative start
- StockCount() : float
- Get physical available count in stock
- TaxLevel() : float
- Get the tax for certain time frame
- ToLocalDataJson() : string
- Convert to json
- ToPlainObject() : stdClass
- Convert to plain data set
- TrailDuration() : int
- Get the trail duration for this article
- TrailInterval() : array<string|int, mixed>|null
- Get tail interval
- UpdateExtra() : Result
- Update the extra
- VoucherTemplate() : Voucher|null
- Get the linked voucher template for this article it can generate user individual vouchers on demand
- _interval() : array<string|int, mixed>|null
- Get interval of type
- extrasPath() : string
- Helper to get the extras path
- writeExtra() : Result
- Store extras
Properties
$
public
bool
$
individual_checkout Has individual checkout requirement
$amount
public
int
$amount
= 1
The amount
$folder
Buffer for linked main folder
protected
FolderTree|null
$folder
= null
$ignore_hash_fields
protected
array<string|int, mixed>
$ignore_hash_fields
= ['last_changed_by', 'last_changed_at']
$relation_id
protected
string|null
$relation_id
= null
$_alternatives
List of alternatives, is cached
private
array<string|int, mixed>|null
$_alternatives
= null
$_brands
Buffer of brand articles
private
array<string|int, mixed>|null
$_brands
= null
$_bundle_articles
Storage for bundle article resolver
private
array<string|int, mixed>|null
$_bundle_articles
= null
$active_vouchers
Apply some active vouchers based on basket context
private
array<string|int, mixed>
$active_vouchers
= []
$brand
Buffer active brand
private
string|null
$brand
= null
$bundle_config
private
array<string|int, mixed>
$bundle_config
= []
$periods_table
private
array<string|int, mixed>|null
$periods_table
= null
$price_table
private
array<string|int, mixed>|null
$price_table
= null
$resource
private
null|false|BookableResource
$resource
= null
$trail_duration
private
int
$trail_duration
= 0
Methods
__construct()
Article constructor.
public
__construct([string|null $id = null ][, string|null $language = null ][, string $type = 'article' ]) : mixed
Parameters
- $id : string|null = null
-
The article id or null
- $language : string|null = null
-
The object language or null
- $type : string = 'article'
-
The child type when needed
Return values
mixed —ActiveBrand()
In context of a purchase the brand can be activated
public
ActiveBrand([string|null $brand = null ]) : string|null
Parameters
- $brand : string|null = null
-
The brand article id
Return values
string|null —The active brand
ActiveBrandArticle()
public
ActiveBrandArticle() : Article|null
Return values
Article|null —ActiveBundleConfig()
public
ActiveBundleConfig([array<string|int, mixed>|null $bundle_config = null ]) : array<string|int, mixed>
Parameters
- $bundle_config : array<string|int, mixed>|null = null
Return values
array<string|int, mixed> —ActiveVouchers()
Get / set active vouchers
public
ActiveVouchers([array<string|int, mixed>|null $voucher = null ]) : array<string|int, Voucher>
Parameters
- $voucher : array<string|int, mixed>|null = null
Return values
array<string|int, Voucher> —ActiveVouchersAffiliate()
public
ActiveVouchersAffiliate() : Company|null
Return values
Company|null —Alternatives()
Get alternative article ids of this article
public
Alternatives() : array<string|int, mixed>
Return values
array<string|int, mixed> —The id list
AssignedSubscription()
public
AssignedSubscription() : bool
Return values
bool —AssignImage()
Assign an image from instance
public
AssignImage(Asset $asset) : Result
Parameters
- $asset : Asset
-
An asset instance
Return values
Result —The result object
Author()
Get the original author of the task
public
Author() : User|null
Return values
User|null —Brands()
Get the brands the article has as article internal alternatives
public
Brands() : array<string|int, Article>
Return values
array<string|int, Article> —BundleArticle()
public
BundleArticle(string $id) : array<string|int, mixed>|null
Parameters
- $id : string
Return values
array<string|int, mixed>|null —BundleArticles()
Get bundle articles
public
BundleArticles([bool $resolve = false ][, string|null $plain_language = null ]) : array<string|int, mixed>
Fetch the bundle articles as raw list or, resolved. This method is cached until save
Parameters
- $resolve : bool = false
-
When true, resolve sub content
- $plain_language : string|null = null
-
When given, translate it
Return values
array<string|int, mixed> —The list of children when it is a bundle
Category()
public
Category() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —Copy()
public
Copy([null $target = null ]) : Result|null
Parameters
- $target : null = null
Return values
Result|null —CreateExtra()
Create a new extra
public
CreateExtra(string $type, array<string|int, mixed> $data[, bool $individual = true ]) : Result
Parameters
- $type : string
- $data : array<string|int, mixed>
- $individual : bool = true
Return values
Result —DeleteExtra()
Delete the extra
public
DeleteExtra(string $type[, string|null $id = null ][, bool $individual = true ]) : Result
Parameters
- $type : string
-
The extras type
- $id : string|null = null
-
The id or null to drop all of certain kind
- $individual : bool = true
-
Is individual file or, in all full list?
Return values
Result —FetchExtras()
Fetch extra list
public
FetchExtras(string $type[, bool $individual = true ]) : Result
Parameters
- $type : string
- $individual : bool = true
Return values
Result —Frames()
Get the plain frames list if it is not empty
public
Frames([bool $with_override = false ]) : array<string|int, mixed>|null
Parameters
- $with_override : bool = false
Return values
array<string|int, mixed>|null —GeneralSearchFields()
The general search fields
public
GeneralSearchFields() : array<string|int, mixed>
Return values
array<string|int, mixed> —GetAmountOptions()
List of possible selectable options for this article
public
GetAmountOptions() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —GetExtra()
Fetch single extra
public
GetExtra(string $type, string $id) : Result
Parameters
- $type : string
- $id : string
Return values
Result —GetPrice()
Get price by amount and/or date
public
GetPrice([float|int $count = 1 ][, null|string $date = null ][, bool|string $trail = false ]) : array<string|int, mixed>
Parameters
- $count : float|int = 1
-
Get price for specific amount
- $date : null|string = null
-
Get price for specific date, defaults to now
- $trail : bool|string = false
-
Get trial period price, can be set to 'restore' for certain restore context
Return values
array<string|int, mixed> —The price for 1 item and the tax level
GetPriceFormatted()
Get formatted price of instance
public
GetPriceFormatted([float|int $count = 1 ][, bool $tax = false ][, string $dec = ',' ][, string $tho = '.' ][, null|string $date = null ]) : string
Parameters
- $count : float|int = 1
-
The multiplier
- $tax : bool = false
-
Include taxes?
- $dec : string = ','
-
The decimal separator
- $tho : string = '.'
-
The thousands separator
- $date : null|string = null
-
Get price for specific date
Return values
string —The formatted price
GetPrimaryPicture()
Get the primary picture
public
GetPrimaryPicture() : Asset|null
Return values
Asset|null —GetTrailPriceFormatted()
Get formatted trail price of instance
public
GetTrailPriceFormatted([int $count = 1 ][, bool $tax = false ][, string $dec = ',' ][, string $tho = '.' ][, null|string $date = null ]) : string
Parameters
- $count : int = 1
-
The multiplier
- $tax : bool = false
-
Include taxes?
- $dec : string = ','
-
The decimal separator
- $tho : string = '.'
-
The thousands separator
- $date : null|string = null
-
Get price for specific date
Return values
string —The formatted price
HasAlternatives()
Has alternative articles?
public
HasAlternatives() : bool
Return values
bool —Hash()
Generate hash of current contents
public
Hash() : string
Return values
string —Images()
List images
public
Images([bool $resolved = false ]) : array<string|int, mixed>|array<string|int, Asset>
Get the content of the images attribute relation Will generate and return an empty array hen attribute is not filled
Parameters
- $resolved : bool = false
Return values
array<string|int, mixed>|array<string|int, Asset> —Interval()
Get interval
public
Interval([string|null $date = null ]) : null|array<string|int, mixed>
If the article has an interval, read it from sub content and return it as string. Will return null when nothing is set.
Parameters
- $date : string|null = null
Return values
null|array<string|int, mixed> —IsBundle()
Is a bundle
public
IsBundle() : bool
When this article is composed of bundle articles return true
Return values
bool —The status
IsInterval()
Return boolean status of interval
public
IsInterval() : bool
Return values
bool —MainFolder()
Resolve the main project of this article
public
MainFolder([string|null $root = null ]) : Folder|null
Parameters
- $root : string|null = null
Return values
Folder|null —MainFolderRelation()
public
MainFolderRelation([string|null $root = null ]) : string|null
Parameters
- $root : string|null = null
Return values
string|null —MainImage()
Get main image
public
MainImage() : Asset|null
Return values
Asset|null —MasterEvent()
public
MasterEvent() : BookableResource|bool|null
Return values
BookableResource|bool|null —Name()
public
Name(string $language) : string|null
Parameters
- $language : string
Return values
string|null —Number()
Get the article number
public
Number() : string|null
Return values
string|null —PeriodTable()
public
PeriodTable() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —Persons()
Count the persons that are part of this bundled article
public
Persons() : int
Return values
int —PriceTable()
Get price list
public
PriceTable() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —RequestedFrameSize()
Get the requested room size
public
RequestedFrameSize() : int
Return values
int —RequestedMainFrame()
Get fitting target room article id
public
RequestedMainFrame() : string
Return values
string —RequiredPurchases()
List of required purchases the article needs beforehand
public
RequiredPurchases() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null —Save()
Save changes and clear caches
public
Save([false $force_new_id = false ]) : Result
Parameters
- $force_new_id : false = false
Return values
Result —SearchFields()
public
SearchFields() : mixed
Tags
Return values
mixed —SpecificTrail()
Calculate specific trail duration based on relative start
public
SpecificTrail([string|null $duration = null ][, MyDateTime|null $relative = null ]) : int
Parameters
- $duration : string|null = null
-
The alternative duration in format 12M or 1Y without unit it counts as days
- $relative : MyDateTime|null = null
-
Relative time defaults to now
Return values
int —StockCount()
Get physical available count in stock
public
StockCount() : float
Will calculate automatically the amount of assemblable items
Return values
float —The sum of assembled and splitted available items
TaxLevel()
Get the tax for certain time frame
public
TaxLevel([string|null $date = null ]) : float
Parameters
- $date : string|null = null
-
Date for date table or null
Return values
float —ToLocalDataJson()
Convert to json
public
ToLocalDataJson(Request $request[, array<string|int, mixed>|null $org = null ]) : string
Generate a json ld entry of the given element
Parameters
- $request : Request
-
A system request
- $org : array<string|int, mixed>|null = null
-
Additional information about the organisation
Return values
string —The json-ld content
ToPlainObject()
Convert to plain data set
public
ToPlainObject([string|null $language = null ][, bool $with_parent = true ][, bool $recurse = true ]) : stdClass
Translate and expose the current data attribute as plain resolved object
Parameters
- $language : string|null = null
-
A system language code or empty for raw setup
- $with_parent : bool = true
-
When set to true the attributes will be resolved witch parent attributes included
- $recurse : bool = true
-
When true, resolve child contents as well
Return values
stdClass —A simple attribute based php object
TrailDuration()
Get the trail duration for this article
public
TrailDuration([string|null $date = null ]) : int
In context of assignment a date should be given representing the subscription start date
Parameters
- $date : string|null = null
Tags
Return values
int —TrailInterval()
Get tail interval
public
TrailInterval([string|null $date = null ]) : array<string|int, mixed>|null
If the article has an interval, read it from sub content and return it as string. Will return null when nothing is set.
This method uses the active vouchers to determine the actual period
Parameters
- $date : string|null = null
Return values
array<string|int, mixed>|null —The actual duration with unit and length
UpdateExtra()
Update the extra
public
UpdateExtra(string $type, string $id, array<string|int, mixed> $data[, bool $individual = true ]) : Result
Parameters
- $type : string
-
The extras type
- $id : string
-
The item primary key
- $data : array<string|int, mixed>
-
The new data
- $individual : bool = true
-
Is individual file or in all full list?
Return values
Result —VoucherTemplate()
Get the linked voucher template for this article it can generate user individual vouchers on demand
public
VoucherTemplate() : Voucher|null
Return values
Voucher|null —_interval()
Get interval of type
private
_interval(string $type[, string|null $date = null ]) : array<string|int, mixed>|null
Parameters
- $type : string
- $date : string|null = null
Return values
array<string|int, mixed>|null —extrasPath()
Helper to get the extras path
private
extrasPath(string $type) : string
Parameters
- $type : string
Return values
string —writeExtra()
Store extras
private
writeExtra(string $file, array<string|int, mixed> $data[, bool $individual = true ]) : Result
Parameters
- $file : string
-
The target file
- $data : array<string|int, mixed>
-
The new row
- $individual : bool = true
-
Save in individual file?