Download the PHP package decss/item-parser without Composer
On this page you can find all versions of the php package decss/item-parser. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download decss/item-parser
More information about decss/item-parser
Files in decss/item-parser
Package item-parser
Short Description Parse Items/Products with parameters or options from CSV. Display result as HTML table
License MIT
Informations about the package item-parser
ItemParser
ItemParser is a simple PHP class for parsing Products and other records with their parameters or options (like colors, sizes etc) from CSV, present results as array or display it as html table
Take a look at live demo
See the examples
folder for usage examples
Features
Parser features:
- Parse data from csv to array
- Display parse results in table view
- Parse parameters like
size
,color
,material
,category
, etc from cells likeS; M; L; XL
to array of[id => 1, value => "S"]
items - Detect missing parameters and give an ability to replace or ignore it
- Configure each column type and order or skip it
- Search parameters by value or aliases
- Skip specified rows or columns
Drawer features:
- Select, change or skip each column manually
- Display parameters as tags
- Mark tags as
ignored
,replaced
ornot found
- Mark cell as
valid
orinvalid
- Shorten links and image urls
- Shorten long text
- Hide valid, invalid or custom rows
Requirements
As noted in composer.json
production requirements:
- php >= 5.5
- php mbstring extension
- php json extension
- php iconv extension
- parsecsv/php-parsecsv
Installation
Using Composer run the following on the command line:
Include Composer's autoloader file in your PHP script:
Without composer
Not recommended. To use ItemParser, you have to add a require 'itemparser.lib.php';
line.
Note that you will need to require all ItemParser dependencies like ParseCsv
.
Parser result
Paeser result is an array of rows (lines). Each row matches the corresponding line in the CSV and generally looks as follows:
Skipped rows can be both valid ("valid" => true
) or invalid ("valid" => false
) and vice versa.
As mentioned above, "fields"
is an array of Field items. Each Field can be different depending on its type, config and content.
All row fields will be presented in result, even if Field was not parsed or was skipped or invalid - there is no matter.
Empty field
This is an example of skipped or not configured Field:
Text field
So there is 2 Field types: text
and param
. Here is example of configured text
Field:
"value"
- is what you should to use instead of "text"
Param field and values
Next is "param" Field:
So you can see that "value"
of param
Field is an array. Here is example of both found [0,2]
and not found [1]
colors.
If there is 2 or more identical colors (ie "Black; Red; Black"
) all fo them will be valid but duplicates will be skipped.
Usage
Parser usage
Drawer usage
Detailed usage
Create Parser and set content
You can access to Csv()
instance of ParseCsv
library and configure it directly:
Configure columns
See examples to get how arguments like $colors
and $colorsMissing
work
Configure parser options
Parsing and results
Use Drawer
Credits
- ItemParser is based on ParseCsv class.
All versions of item-parser with dependencies
ext-mbstring Version *
ext-json Version *
ext-iconv Version *
parsecsv/php-parsecsv Version ^1.2