How to build many to many product database into pimcore? - many-to-many

I have to build a product repository in pimcore. I have clear design of database but I do not know how make it in pimcore in recommended/optimize way.
Category :
id
name
Attribute :
id
cat_id
name
Product
id
cat_id
name
ProdAttributes
id
prod_id
attr_id
attr_value
I can build Object classes for all and set relation within them, But if that is recommended way ?
Also I need to build REST API for inserting & fetch data. I assuming I need to do some ZF1 DB code instead of using pimcore Object API ?

I'd highly recommend using pimcore's GUI. That's the best way.
Ad REST: there's allready an RESTful API in pimcore. You can find the documentation here.
If you need more you'll have to build your own. I've put mine on GitHub. It fetches data from an object and returns them via JSON or XML - maybe it helps.

Related

In testrail API how do I get project_id from case data?

I am trying to add a run with the add_run endpoint, but in my automation code I only have the test cases ids but not the project id (which according the the docs is mandatory).
Right now I am doing:
get all projects with /get_projects
get all cases /get_cases/{project_id}
Then I loop over the cases I get and add the project_id to the case so I could create an add_run with the proper project_id.
This seems like the wrong way to do it.
Anybody has a better solution?
Also is there a way to create a run without a project_id? for example if I have a sanity run that includes cases from many projects.
Any help is appreciated.
You can do the following to get the parent project ID:
get the case by ID and capture value of the suite_id field
get the parent suite by the value of the suite_id field and capture value of the project_id field <--- here you have your project ID and can use it for creating runs.

Delete from json without the use of a 'real' id

In Angular:
I'm trying to delete items from a local json server using a http request.
The problem is that the items don't have 'real' id's. Their id's are strings which json doesn't recognises as id's (so far I know).
So when I try to search for an id (either to get it or delete it) I have to use for example:
"http://localhost:3000/watchlist?imdbID=tt5745872"
which gives an array with 1 item.
When using this in a delete request, it will result in a 404.
I was wondering if there is some kind of a workaround for doing this or do I really have to implement 'real' id's?
Context: I'm getting movies from an API and I then store those in an json server. As the API uses string id's, it would be a pain in the ass to try and implement a second id for the same object.

What is the URL when I DELETE an object

I'm running a local server playing around with an API using Django. I have a model called 'Users' populated with a few objects, and am using DefaultRouter.
I want to know what the URL would be if I were to DELETE a specific object from this model. For example, if I wanted to GET a user with an ID of 1 in this model, the URL would be: "localhost:8000/Users/1/". What would the equivalent be to DELETE this user?
I found an explanation of this on the REST API website (below), however, I don't understand what any of the syntaxes means.
What is {prefix}, {url_path}, {lookup} and [.format]? If anyone could provide an example of what this might be using a localhost that would be really helpful.
Thanks
Let us take an example of an API (URL) to update book data with id (pk) being 10. It would look something like this:
URL: http://www.example.com/api/v1/book/10/
Method: PUT/PATCH
With some data associated.
If you want to delete you just need to change method to DELETE instead of put or patch.
Regarding your second question lets compare the url with the parameters.
prefix: http://www.example.com/api/v1/book
lookup: 10
format: It specifies what type of data do you expect when you hit the API. Generally it is considered to be json.
url_path: In general, every thing after look up except query string is considered to be url_path.

How to include SR related work log long description when using maximo oslc rest api?

I am doing an HTTP GET request to /maximo/oslc/os/mxsr and using the oslc.select query string parameter to choose:
*,doclinks{*},worklog{*},rel.commlog{*},rel.woactivity{*,rel.woactivity{*}}
This lets me get related data, including related worklogs, but the worklog does not include the 'description_longdescription' field.
The only way I seem to be able to get that field is if I do a separate HTTP GET to query a worklog id directly through /maxrest/rest/mbo/worklog . Then it provides the description_longdescription field.
I understand this field is stored separately through the linked longdescription table, but I was hoping to get the data through the "next gen" oslc api with one http get request.
I've tried putting in 'worklog{*,description_longdescription}', as I read somewhere that longdescription is a "non-persistent" field and must be explicitly named for inclusion, but it had no effect.
I figured out that for the /maximo/oslc/os/mxsr object in the API, I needed to reference the related MODIFYWORKLOG object through the rel.modifyworklog syntax in the oslc.select query string:
oslc.select=*,doclinks{*},rel.modifyworklog{*,description_longdescription},rel.commlog{*},rel.woactivity{*,rel.woactivity{*}}
I also had to explicitly name the non-persistent field description_longdescription for it to be included.
Ref. for the "rel." syntax: https://developer.ibm.com/static/site-id/155/maximodev/restguide/Maximo_Nextgen_REST_API.html#_querying_maximo_asset_management_by_using_the_rest_api

Can I insert deserialized JSON SObjects from another Salesforce org into my org?

We have the need to clone a complex data structure from one org to another. This contains a series of custom SObjects, including parents and children.
The flow would be the following. On origin org, we just JSON.serialize the list of SObjects we want to send. Then, on target org, we can JSON.deserialize that list of objects. So far so good.
The problem is that we cannot insert those SObjects directly, since they contain the origin org's IDs and Salesforce won't let us insert objects that already have Ids.
The solution we found is to manually insert the object hierarchy, maintaining a map of originId > targetId and fixing the relationships manually. However, we wonder if Salesforce provides an easier way to do such a thing, or someone knows a better way to do it.
Is there an embedded way in Salesforce to do this? Or are we stuck into a tedious manual process?
List.deepClone() call with preserveIds = false might deal with one problem, then:
Consider using upsert operation to build the relationships for you.
Upsert not only can prevent duplicates but also maintain hierarchies.
You'll need an external Id field on the parent, not on the children though.
/* Prerequisites to run this example succesfully:
- having a field Account_Number__c that will be marked as ext. id (you can't mark the standard one sadly)
- having an account in the DB with such value (but the point of the example is to NOT query for it's Id)
*/
Account parent = new Account(Account_Number__c = 'A364325');
Contact c = new Contact(LastName = 'Test', Account = parent);
upsert c;
System.debug(c);
System.debug([SELECT AccountId, Account.Account_Number__c FROM Contact WHERE Id = :c.Id]);
If you're not sure whether it will work for you - play with Data Loader's upsert function, might help to understand.
If you have more than 2 level hierarchy on the same sObject type I think you'd still have to upsert them in correct order though (or use Database.upsert version and keep on rerunning it for failed ones).