How can you rename & add new columns beside the item attributes when exporting data via ImpEx?
I have the following:
"#% impex.setTargetFile( ""attributes.csv"" , true );"
insert_update ClassificationAttribute; pk[unique=true]; code ; creationtime; classes
But I want to have, besides code & creationTime, the name and the code of the classes and subcategories/supercategories of them. For now I can only get the PK.
And I want the columns to be renamed, for example: the code column to be renamed into attribute_code
Maybe you want to read more at
https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/2005/en-US/8bef9530866910148e6cff59d9afa127.html
and
https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/2005/en-US/1c8f5bebdc6e434782ff0cfdb0ca1847.html
and
https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/2005/en-US/8bd9d5bb86691014ba9d95a88ede75f3.html
You cannot achieve this using impexes, unless you are okay with having two csvs, one corresponding to classificationattribute and another one for classsification class:
"#% impex.setTargetFile( ""ClassificationAttribute.csv"" , true );"
insert_update ClassificationAttribute; pk[unique=true]; code ; creationtime;classes(&Item)
"#% impex.setTargetFile( ""ClassificationClass.csv"" , true );"
insert_update ClassificationClass;&Item;code;name;supercategories(code)
The supercategories is a list and classes is also a list, a list of list scenario is not supported in a single line of impex. Even with this in place you cannot reimport the data with a renamed attribute.
You can however, achieve the same using a customized version of excel export and import, OOTB code is implemented using apache POI. Extend DefaultExcelExportService and override create custom export classification attribute. Write the reverse logic after extending DefaultExcelImportService, if reimport is required:
public class CustomClassificationExportServiceImpl extends DefaultExcelExportService implements CustomExportService{
public class CustomClassificationImportServiceImpl extends DefaultExcelImportService implements CustomImportService{
Create custom method for classification export. This method fetches the classes corresponding to each classificationattribute as a list and converts this into a set of excel cells.
Create a meta excel sheet that stores the mapping of the actual attribute with the alias attribute given (if reimport required).
Implement the custom logic for import in DefaultExcelImportService. This should fetch the actual attribute using metadata, convert the excel columns to a list etc
Related
We use RICS that auto import our product information into Akeneo. Every time there is a new COLOR, I get an error for example: Property "color" expects a valid reference data code. The code "BALTIK/LAKE" of the reference data "color" does not exist under CONNECT/CONNECTION SETTINGS/ERROR MONITORING, so I then manually add each color under REFERENCE DATA/(_T) SIMPLE ASSETS. Is there a way Akeneo can be set up to auto add these new colors in the REFERENCE DATA as there are hundreds of new colors needing to be added frequently?
It depends on which type of attribute do you have.
If you have attribute type Reference entity simple link there is no job to import the records. You can do this by writing a simple script using REST API.
If you have attribute type Simple select there is dedicated import job, and you can prepare CSV or XLSX with all possible values. Then you can import it to PIM. You can do this via API too.
Additionally, there is no possibility to new option/record on the go while importing the product. There are a couple of plugins in marketplace which does that, but it's really bad for catalog hygiene and can cause a lot of problems for system operators.
I have a custom table in SQL Server called AnimalBreed and maintenance page.
I wish to add User Defined Field support via the KvExt approach instead of
traditional practices involving either CSAnswers or a CacheExtension of the
DAC and underlying "Usr" fields.
Is this possible?
Can it be done for line-level (child) DACs, such as
existing INLocation and INLocationKvExt?
Thanks!
UPDATE:
It appears the feature needs at least:
ensure your table has the NoteID column as uniqueidentifier datatype and the DAC has the corresponding field: Guid? NoteID and [PXNote()] attribute.
In the ASPX, if not ListView, add the following to the PXDataSource tag:
EnableAttributes="true"
By making these changes, I can Manage User Defined Fields, choose Attributes to include, and I can store values to the KvExt table.
I am using Version = 19.205.0023
Sales Order page observation: if I add two UDFs on SO Order Entry page, one is combobox and one is checkbox, setting their values saves just fine, but then updating the combobox and save leads to loss of the checkbox (from true to false), unless you uncheck and recheck prior to the save. Is this a bug?
Maybe technically possible but definitely not recommended to use undocumented feature like KvExt.
If you need to deploy User Defined Fields on a page which already contains them. Configure them manually and then add them in a customization package in the user defined fields section for deployment as described here:
https://help-2019r2.acumatica.com/Help?ScreenId=ShowWiki&pageid=e01f29d3-b6b1-40f4-a2d1-45c9d01bdde3
Example:
I know how to write and use Cell Decorator and Translators during impex imports
in hybris, However, I am not sure when the one is preferred over the other?
For example, I have used Cell Decorator to change the value of an attribute slightly like if a customer is from US I will append an '_US' at the end of customer number while inserting in the DB.
Similarly, I have used Translator when I need to find a status of a product Available/Out of stock based on product ID.
However, I am not 100% positive is this the only differentiation.
Any explanation with example will be appreciated.
What is a translator?
(from SAP documatentation):
A translator class is a converter between ImpEx-related CSV files and values of attributes of Hybris Commerce items
The translator is a "converter" it is used when you need to modify your data into some other kind of data.
What is a decorator?
(From Wikipedia)
The decorator pattern is a design pattern that allows behavior to be added to an individual object, dynamically, without affecting the behavior of other objects from the same class
What should be used in hybris
For Impex most of the time you want to use a translator because you want to use simple syntax in the Impex file and convert( ie. translate/modify) it to the target format using code.
When you need to add functionality to an existing feature use a decorator. It can be used in Impex too if you want to add data.
For example you can read the Wikipedia article for decorator, in hybris you can look at ChineseLogisticCellDecorator. For translators, you have the list in hybris documentation (mentioned above)
I have a classification system attribute in a classification class that classifies all categories in my catalog.
This attribute is called Vanprijs. I can add values to this attribute for different products/variants on the hMC. Like on the picture below, but how can I add these values via impex files?
I did try this, but the importer doesn't recognize Vanprijs as a known attribute:
INSERT_UPDATE ModelVariantProduct;$baseProduct;code[unique=true];name[lang=$lang];Vanprijs;$catalogVersion;$approved
;B300047;M300047;Toiletverhoger (met deksel en stabiele armleuningen);10
This is how it's done (note the 2 variables $clAttrModifiers and $vanprijsFeature):
$lang=nl
$productCatalog=myProductCatalog
$catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged]
$approved=approvalstatus(code)[default='check']
$baseProduct=baseProduct(code,$catalogVersion)
$clAttrModifiers=system='MySystemClassifications',version='General',translator=de.hybris.platform.catalog.jalo.classification.impex.ClassificationAttributeTranslator,lang=nl
$vanprijsFeature=#Vanprijs[$clAttrModifiers];
INSERT_UPDATE Product;code[unique=true];$vanprijsFeature;$catalogVersion
;M300047;200.59;
I'm starting to do some test on SubSonic 3 and I'm missing some stuff.
1st: Where's the Table names constants? The place where we could ask for the same of a certain table using intelisense...
2nd: Same as the above but for the table columns... where are they?
This is very useful mostly when you need to pass those names as string... it you need to refactor your DB we don't need to look through all the code to find where was I using that column!! Once you re-generate the code the compiler tells you!
3rd: Now how can I perform an ExecuteReader on a certain table like I'm used to on 2.x through the Query object? I used this a lot for list where I really don't need the business objects (BO) overhead... When I needed a BO (for showing a grid row details) I create it from the row itself...
I'm using ActiveRecord btw...
Thanks guys!
Alex
1st: Where's the Table names constants? The place where we could ask for the same of a certain table using intelisense...
In Structs.tt find the following line of code at line 47:
<# foreach(var col in tbl.Columns){#>
Add the following code above it:
public static string TableName { get { return "<#=tbl.Name#>"; } }
Now you'll have a property that returns the name of the table.
2nd: Same as the above but for the table columns... where are they?
In the generated Structs.cs file, this is included in the 3.0.0.3 version
3rd: Now how can I perform an ExecuteReader on a certain table like I'm used to on 2.x through the Query object? I used this a lot for list where I really don't need the business objects (BO) overhead... When I needed a BO (for showing a grid row details) I create it from the row itself...
If you're using SqlQuery object you can call ExecuteReader on it. Alternatively you can use Linq syntax to generate return custom shaped objects and they'll get mapped automatically.
1st and 2nd: It's not implemented in the default tt-files.
A similiar question:
SubSonic 3 Simple Query Tool
Problem is that's not a correct implementation if you want the 2.x way - the XColumn properties used to be column objects and not string constants, those were found under the Columns struct. So I hope that check-in will not be accepted and that someone will 2.x-ify it correctly.
Anyway as you can see it seems pretty easy to fix it on your own.