PluginProbe
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments / 4.4.1
SureCart – Ecommerce Made Easy For Selling Physical Products, Digital Downloads, Subscriptions, Donations, & Payments v4.4.1
4.7.2 4.7.1 4.7.0 4.6.6 4.6.5 4.6.4 4.6.3 4.6.2 4.6.1 4.6.0 4.5.1 4.5.0 4.4.2 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.3 4.2.2 4.2.1 1.0.3 1.0.4 1.0.5 All 281 releases
surecart / app / src / Models / ProductCollectionImport.php
ProductCollectionImport.php
37 lines 863 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SureCart\Models;
4
5 use SureCart\Models\Concerns\ImportModel;
6
7 /**
8 * Product import model
9 */
10 class ProductCollectionImport extends ImportModel {
11 /**
12 * Rest API endpoint.
13 *
14 * @var string
15 */
16 protected $endpoint = 'imports/product_collections';
17
18 /**
19 * Set the data attribute as an array of Product models.
20 * Accepts an iterable of attribute arrays/Products or a single Product instance.
21 *
22 * @param mixed $value Iterable of product attributes or Product instance.
23 *
24 * @return void
25 */
26 public function setDataAttribute( $value ) {
27 $models = [];
28 if ( ! empty( $value ) && is_array( $value ) ) {
29 foreach ( $value as $attributes ) {
30 $models[] = is_a( $attributes, ProductCollection::class ) ? $attributes : new ProductCollection( $attributes );
31 }
32 $value = $models;
33 }
34 $this->attributes['data'] = $value;
35 }
36 }
37