Sunnysideup\EcommerceProductVariation\Tasks\EcommerceTaskCSVToVariations
allows the creation of variations from a CSV CSV will have the following fields: ProductTitle, Size, Colour, Price If you like to add more fields, then it is recommended that you extend this BuildTask to your own BuildTask.
Synopsis
class EcommerceTaskCSVToVariations
extends BuildTask
{
- // members
- protected boolean $forreal = false;
- protected string $title = 'Create variations from a Spreadsheets (comma separated file CSV)';
- protected string $description = ' Does not delete any record, it only updates and adds. The minimum recommend columns are: ProductTitle (or ProductInternalItemID), Size, Colour, Price, InternalItemID. You can add ?forreal=1 to the URL to run the task for real.';
- protected string $csvSeparator = ',';
- protected boolean $debug = true;
- protected array $csv = ;
- protected array $data = ;
- protected array $soleProduct = ;
- protected integer $defaultProductParentID = 0;
- private static string $file_location = '';
- private static string $no_price_available = 'POA';
- private static array $attribute_type_field_names = ;
- // methods
- public void getDescription()
- public void run()
- protected void addMoreProduct()
- protected void addMoreProductForProductWithoutVariations()
- protected void addMoreAttributeType()
- protected void addMoreToAttributeValue()
- protected void addMoreToVariation()
- protected void reset()
- protected void readFile()
- protected void createProducts()
- protected void findVariations()
- protected void showData()
- protected void createVariations()
- protected void getExtraDataForVariations()
- protected void addFieldToObject()
- protected void alterationMessage()
Hierarchy
Extends
- SilverStripe\Dev\BuildTask
Members
private
- $attribute_type_field_names — array
- $file_location
—
string
excluding base folder - $no_price_available
—
string
Cell entry for a price that is not available
protected
- $csv
—
array
the original data from the CVS -
$csvSeparator
Is the CSV separated by , or ; or [tab]? - $data
—
array
Structure will be as follows: - $debug — boolean
- $defaultProductParentID
—
int
The default page of where the products are added. - $description
- $forreal
-
$soleProduct
list of products without variations - $title
Methods
protected
- addFieldToObject() — adds a field to the variation
- addMoreAttributeType() — do more with Product Variation
- addMoreProduct() — do more with Product
- addMoreProductForProductWithoutVariations() — do more with Product that does have any variations
- addMoreToAttributeValue() — do more with Product Variation
- addMoreToVariation() — do more with Product Variation
- alterationMessage()
- createProducts()
- createVariations()
- findVariations()
- getExtraDataForVariations()
- readFile()
- reset()
- showData()