I duplicated the product from the client side and updated the new product. The site have different store views.
I want to make sure that when saving/updating "Use Default Value" checkbox should be checked for Visibility, price, special price etc.
But when using save() function it is always getting unchecked.. How to save "Use Default Value" for these magento attributes.
Best deal would be backup your data first.
Then create a script for which product you want to set the default value in such a way that it deletes the related row from that entity attribute table.
Thanks
Related
I have to create and remove attributes based on an api response in Objective C.
For example, Now my api response contains fields "facebook", "whatsapp" and "viber". But in future the reponse can add "youtube". Based on this response, I have to remove all the attributes and values of an entity "Social", and create Four attributes now and set values.
How to do that programmatically? Because the default *.xcdatamodeld file cant help me here, right?
Note: My project is in objective C.
The data model is mutable when the app starts-- you can completely build the model in code, and not use the model editor, for example. But as soon as you load a persistent store file, you must treat the model as fixed. Any changes after loading a persistent store will cause crashes. That means any changes would have to happen before calling either loadPersistentStores(completionHandler:) or addPersistentStore(with:completionHandler:).
Alexander's suggestion of optional attributes is a good one. If you need the model to be more dynamic, you would need to create a new related entity which would store the service name plus whatever information you need to save about the service. If you did this, your Social entity would have a to-many relationship to a new entity called something like Service. Service would have a string property called name that would have values like twitter, facebook, youtube, etc. It would also have whatever other attributes you need to save about the service.
You can create all 4 fields in advance and just make them optional and fill them depending on the server response. But you cannot add new attributes in runtime. Your *.xcdatamodeld file compiles into *.momd and it contains all the data to create tables in the DB since Core Data by default works with SQLite under the hood and it's a relational database management system.
To make attributes optional you should check that.
And then newly created objects contain nil as default values of object properties. So, in your case your "youtube" property of Social object will be just nil.
In my iOS app's core data model, I had an Entity called Fish with a string attribute called mainText. I renamed this attribute to questionText. The CRUD operations works fine for the new data. However, I cannot read the old data, the one written when the attribute was called mainText. Here is what I have tried:
Renaming it back to mainText, it does not work.
Adding a new attribute called like the old one, mainText, it does not work.
How would you proceed to retrieve the old data's values (the one wrote when the attribute was still called mainText) ?
If you want to rename an attribute and keep the old data, there are two things you need to do:
Create a new version of the data model. You probably already did this, or your app would not have been able to load the old data at all. If not though, make sure you keep your changes in a different version of the model file. The old model version needs to be available or migration won't work.
On this property, set the "renaming identifier" field to contain the old name of the attribute. This will tell Core Data that it should migrate values to the new attribute name. Without that it can't tell if you want to rename the attribute or if you want to delete the old one and add a new, different attribute. In the model editor, you'll find this on the right when you select the new attribute:
You may find Apple's guide to lightweight migration to be useful too.
I have a requirement from a client to give them the option to add custom fields to a program i am going to write for them. The custom fields will be on a per/poco basis. What is the best way of handling custom properties like this. I am going to use SQL Server and ASP.NET MVC4.
Just need a starting point..
thanks in advance.
The way we handle this where I work is storing the information in a database table. We store the field name, the value, and some identifier for which object it belongs to. Sometimes we have an additional table stores the specific list of available values.
When it's pulled out of the db, we place it in a dictionary list. If you set up some conventions then it's not too bad building validation for the fields. I.E. any field name with "phone" in the name gets validated as a phone number.
We want to extend the bug work item template with a new field called Found In Iteration. This field, what a surprise, should contains the iteration the bug was found in. But when I created the new field of type TreePath, I got an error when importing the process template into the Team Project Collection (TPC) stating that TreePath is only a valid field type for IterationPath and AreaPath fields.
Looking at that I'm wondering if there is at least any way to add a field to a work item template that uses the iteration path as data source and stores the selected value in another field (e.g. FoundInIteration).
This is not possible. There can neither be custom fields of type TreePath nor fields refering to System.IterationPath.
I have a simple table/model in rails, vat_rates. Administrators need to be able to select one, and only one of these as the default rate that will be selected on the HTML form when creating new related items items that have a vat_rate_id. I have added a boolean default column to the vat_rates table.
What is the most straight forward, and rails-like way to ensure that only one vat_rate can be the default one at any time?
I'm not really bothered if there are no defaults, just that there are no more than one.
You could add a custom validation method like this and return an error if another vat_rate is selected as default already. Alternatively you can add a before_update or after_update callback like this to set all other default values to false on update.