unable to insert values to the classAttributeAssignment in impex - sap-commerce-cloud

$classificationSystem=hpeClassification
$classificationCatalogVersion=catalogversion(catalog(id[default=$classificationSystem]),version[default='1.0'])[unique=true,default=$classificationSystem:1.0]
$classificationSystemVersion=systemVersion(catalog(id[default=$classificationSystem]),version[default='1.0'])[unique=true,default=$classificationSystem:1.0]
$code=/facet/Category
$class=classificationClass($code,$classificationCatalogVersion)[unique=true]
$attribute=classificationAttribute(code,$classificationSystemVersion)[unique=true]
$unit=unit(code,$classificationSystemVersion)
INSERT_UPDATE ClassAttributeAssignment;$class;$attribute;multiValued[default=false];range[default=false];attributeType(code[default=string]);localized[default=true];$unit;attributeValues(code,$classificationSystemVersion);

The problem is the use of macro for code(i.e $code).I modified the impex and bellow version should work(However it will not insert nothing in DB):
$classificationSystem=hpeClassification
$classificationCatalogVersion=catalogversion(catalog(id[default=$classificationSystem]),version[default='1.0'])[unique=true,default=$classificationSystem:1.0]
$classificationSystemVersion=systemVersion(catalog(id[default=$classificationSystem]),version[default='1.0'])[unique=true,default=$classificationSystem:1.0]
$class=classificationClass(code,$classificationCatalogVersion)[unique=true]
$attribute=classificationAttribute(code,$classificationSystemVersion)[unique=true]
$unit=unit(code,$classificationSystemVersion)
INSERT_UPDATE ClassAttributeAssignment;$class;$attribute;multiValued[default=false];range[default=false];attributeType(code[default=string]);localized[default=true];$unit;attributeValues(code,$classificationSystemVersion);
An example of inserting an instance in DB would be:
$classificationSystem=hpeClassification
$classificationCatalogVersion=catalogversion(catalog(id[default=$classificationSystem]),version[default='1.0'])[unique=true,default=$classificationSystem:1.0]
$classificationSystemVersion=systemVersion(catalog(id[default=$classificationSystem]),version[default='1.0'])[unique=true,default=$classificationSystem:1.0]
$class=classificationClass(code,$classificationCatalogVersion)[unique=true]
$attribute=classificationAttribute(code,$classificationSystemVersion)[unique=true]
$unit=unit(code,$classificationSystemVersion)
INSERT_UPDATE ClassAttributeAssignment;$class;$attribute;multiValued[default=false];range[default=false];attributeType(code[default=string]);localized[default=true];$unit;attributeValues(code,$classificationSystemVersion);
;accessoryclassification;bands
Where "accessoryclassification" is the code of an already existing(in DB) Classification Class and "bands" is the code of already existing classification attribute

Related

CatalogVersion with catalogId 'xxxProductCatalog' and version 'Staged' not found

i follow that tutorial
https://wiki.hybris.com/pages/viewpage.action?pageId=294094418&showComments=true
first i changed impex names to mystore name.
Then i went to hac console and updated only my extension, mystoreinitialdata.
But it gives those errors:
Creating project data for mystoreinitialdata ...
Begin importing common data for [mystoremystoreinitialdata]
Begin importing product catalog data for [xxx]
Begin importing content catalog data for [xx]
Begin synchronizing Product Catalog [xxx]
Error creating sample data for mystoreainitialdata. See console output.
ERROR [hybrisHTTP39] [Initialization]
de.hybris.platform.servicelayer.exceptions.UnknownIdentifierException:
CatalogVersion with catalogId 'xxxProductCatalog' and version 'Staged'
not found!
i searched and there is no xxxProductCatalog in my code.
What can i do?
Make sure the ImportData created in your InitialDataSystemSetup has valid names for ProductCatalog and Content Catalog attributes. Like this:
final List<ImportData> importData = new ArrayList<ImportData>();
final ImportData sampleImportData = new ImportData();
sampleImportData.setProductCatalogName("mystore");
sampleImportData.setContentCatalogNames(Arrays.asList("mystore"));
sampleImportData.setStoreNames(Arrays.asList("mystore"));
importData.add(sampleImportData);
getCoreDataImportService().execute(this, context, importData);
getEventService().publishEvent(new CoreDataImportedEvent(context, importData));
getSampleDataImportService().execute(this, context, importData);
getEventService().publishEvent(new SampleDataImportedEvent(context, importData));
Also make sure, that catalogs with the names "mystoreContentCatalog" and "mystoreProductCatalog" are created in the impex files in the following files:
/mystoreinitialdata/resources/mystoreinitialdata/import/coredata/contentCatalogs/mystoreContentCatalog/catalog.impex
$contentCatalog=mystoreContentCatalog
$languages=ja,en,de,zh
INSERT_UPDATE ContentCatalog;id[unique=true]
;$contentCatalog
INSERT_UPDATE CatalogVersion;catalog(id)[unique=true];version[unique=true];active;languages(isoCode)
;$contentCatalog;Staged;false;$languages
;$contentCatalog;Online;true;$languages
/mystoreinitialdata/resources/mystoreinitialdata/import/coredata/productCatalogs/mystoreProductCatalog/catalog.impex
$productCatalog=mystoreProductCatalog
$catalogVersion=catalogversion(catalog(id[default=$productCatalog]),version[default='Staged'])[unique=true,default=$productCatalog:Staged]
$languages=ja,en,de,zh
INSERT_UPDATE Catalog;id[unique=true]
;$productCatalog
INSERT_UPDATE CatalogVersion;catalog(id)[unique=true];version[unique=true];active;languages(isoCode);readPrincipals(uid)
;$productCatalog;Staged;false;$languages;employeegroup
;$productCatalog;Online;true;$languages;employeegroup

Importing collection type using ImpEX Import

I have a data structure as follows defined in my items.xml file:
An itemtype of Country type having a attribute(name as collection type of another itemtype Region,which has an attribute(name=locality)of another itemtype say Locality. What would be the right option for ImpEx import to insert some Localities and Countries?We were trying a script like :
INSERT_UPDATE Country;code;regions(locality(code))
;abc;1,2
Separate Country from Region from locality you would write something like :
INSERT_UPDATE Locality;code
;locality_1
;locality_2
;locality_3
INSERT_UPDATE Region;code;locality(code)
;1;locality_1
;2;locality_2
;3;locality_3
INSERT_UPDATE Country;code;regions(code)
;c_1;1,2,3

how to assign categories to classifying categories in hybris through impex

I don't know whether the below impex is correct for my requirement.please correct me if i am wrong.i want to assign categories to classification class.
$classificationSystem=hpeClassification
$classificationCatalogVersion=catalogversion(catalog(id[default=$classificationSystem]),version[default='1.0'])[unique=true,default=$classificationSystem:1.0]
$classificationClasses=Classificationclass(code[unique=true],name[lang=en],supercategories(code,$classificationCatalogVersion),$classificationCatalogVersion);
INSERT_UPDATE Product;code[unique=true];$classificationClasses;$catalogVersion;
;5476;/facets/care;
I think your missing some elements
First you need to define a classification catalog version macro:
$systemName=TelcoClassification;
$systemVersion=1.0;
INSERT_UPDATE ClassificationSystem; id[unique=true]; name[lang=en];
;$systemName;Telco ClassificationSystem;
$classCatalogVersion=catalogversion(catalog(id[default=$systemName]),version[default=$systemVersion])
Then you define the Classification class macro
$class=classificationClass(ClassificationClass.code,$classCatalogVersion)[unique=true]
You create the DB object :
INSERT_UPDATE ClassificationSystemversion; catalog(id)[unique=true] ; version[unique=true] ; active ; writeprincipals(uid); languages(isocode); inclPacking[virtual=true,default=true]; inclDuty[virtual=true,default=true]; inclFreight[virtual=true,default=true]; inclAssurance[virtual=true,default=true]
;$systemName ;$systemVersion ;true ;employeegroup;en;
INSERT_UPDATE ClassificationClass;$classCatalogVersion[unique=true];code[unique=true];allowedPrincipals(uid)[default='customergroup']
;;compatibilityclassification
You define the attribute for classification :
INSERT_UPDATE ClassificationAttribute;$classSystemVersion;code[unique=true]
;;featurecompatibility
$class=classificationClass(ClassificationClass.code,$classCatalogVersion)[unique=true]
$attribute=classificationAttribute(code,$classSystemVersion)[unique=true]
INSERT_UPDATE ClassificationAttributeValue;code[unique=true];$classSystemVersion
;feature_bt10
INSERT_UPDATE ClassAttributeAssignment;$class;$attribute;position;$unit;attributeType(code[default=string]);multiValued[default=false];range[default=false];localized[default=false];attributeValues(code,$classSystemVersion)
;compatibilityclassification;featurecompatibility;0;;enum;true;;;feature_bt10
And you link it to a product
$clAttrModifiers=system='TelcoClassification',version='1.0',translator=de.hybris.platform.catalog.jalo.classification.impex.ClassificationAttributeTranslator,lang=en
$feature1=#featurecompatibility[$clAttrModifiers];
UPDATE Product;code[unique=true];$feature1;$catalogversion
;109058;feature_bt10;
For category:
INSERT_UPDATE Category;code[unique=true];allowedPrincipals(uid)[default='customergroup'];$catalogversion
;devices
UPDATE Category; $catalogversion; code[unique=true]; supercategories(code,$classCatalogVersion)[mode=append]
;;devices;compatibilityclassification;
Old question, but here is the answer, for the product instead of assigning the attribute assign the category.
UPDATE Product;code[unique=true];supercategories(code)[mode = append];
; 5476; <code of your classification class>;

Yii Lazy Loading From Object Instance ($this) with Criteria (Is it possible?)

I'm new to Yii and used to Kohana. I have two models:
1. sampleRequests -> (this has many SampleShares)
2. sampleShares
In my case I have already instantiated an object (sampleRequest) and I am trying to get a particular sampleShares based on added criteria.
In Kohana I could do:
$myShare = $this->sampleShares->where('user_id','=',$my_user_id)->find();
It Yii I have tried something similar:
$myShare = $this->sampleShares->find(array(
'condition'=>'user_id:user_id',
'params'=>array(':user_id'=>$my_user_id)));
The previous does not work for me however, the following will work:
$myShare = SampleShare::model()->find(array(
'condition'=>'sample_id=:id AND user_id=:user_id',
'params'=>array(':id'=>$this->id, ':user_id'=>Yii::app()->user->id)));
So my question is, can you grab related models with appended select criteria to the relationships established in Yii (particular with the instance or $this)? (Similar to my Koahana example?) If so how do you do that?
$myShare = SampleShare::model()->findAll(array('condition'=>'sample_id='.$id.' AND user_id='.$user_id));
and relation query example
$myShare = SampleShare::model()->with('sampleRequests')->findAll(array('condition'=>'sample_id='.$id.' AND user_id='.$user_id));
you can find the realtion name in your model file...
And then you can get the related table records using $myShare->sampleRequests
you can set relationship between the tables in your model file, like this:
public function relations()
{
return array(
'category' => array(self::BELONGS_TO, 'CategoryCategory', 'category_id'),
);
}
how to use:
$model=Blog::model()->with('category')->findAll(); //object
Nevermind I figured it out. I just had to replace:
$this->sampleShares->find(
with
$this->with('sampleShares')->find(

SubSonic Change DropDown Value for Load Drops SUB

I used the subsonic generator to create some aspx pages, It works fine.
On some of the pages it automaticaly generated the dropdown boxes for foreign key values.
How Can change that value in the load drops code? Or where I need to change it.
For instance I have a workers table and a workersweek table.
The workers table has a workerid,firstname and lastname field and the workersweek has a workerID field.
The generator automatically set it up to show the firstname in the dropdown. I want to change the value to be both firstname and lastname.
I am sure I will have to add code that does something like firstname + " " + Lastname.
I am just not sure where to do it withing the code that was generated. I see the load drops sub, but it does not seem like that is the one I need to modify.
If it loads from a foreign key then it loads from a database table.
If you need to concat fields in the query, try making a view with the fields concatenated. e.g. select fName + ' ' + lName as FullName from table
Then in the code behind for the aspx page, select that from the view to load the combobox.
Alternatively try using the 'partial' class functionality to create a new bind-able property. This works for me a treat and has the added bonus of consistent presentation of data through out my apps (With the added bonus of not having to change anything in the database - helpful if you have DBA's from hell that demand 18 levels of change control to get anything done.)
So if your tables class file is "workers.cs" and contains a class called "workers.cs", simply create another class file called "workers_custom.cs" (use your own conventions for working with partial classes) that contains the rest of the partial class, in this case something like:
using System;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Xml;
using System.Xml.Serialization;
using SubSonic;
using SubSonic.Utilities;
namespace YOURCOMPANY.YOURSYSTEM.YOURDAL {
public partial class Workers {
[Bindable(true)]
public string displayWorkersName {
get {
try {
return this.fName + ", " + this.lName;
} catch {
//Your own error handling here
return IsNew ? "##New##" : "##Undefined##";
}
}
}
}
}
(Note you will need to change the bound property member of your control to your new property - in this case: "displayWorksName")

Resources