I'm running into a problem with importing product attribute values that has custom source model (so no visible options in attribute edit page).
Simply it's not working with option ID value or option label neither.
When I was trying to export product with this attribute, there has been an error
Invalid option ID specified for ceneo_category_id (2278), skipping the record. (Line 1, SKU: ...)
Can someone help me with this?
I think I've just experienced the same problem:
created a custom multiselect attribute with a custom source model
for a product.
the label was 'human readable' and the value was an alphanumeric
code.
used the alphanumeric code in a csv product import file.
tried to use the Magento import to load a product with this
attribute.
Got the error: Invalid value for 'test_attr' in rows: 1
After some debugging this seems to be because:
- Mage_ImportExport_Model_Import_Entity_Abstract#isAttributeValid(..) reports the attribute value is invalid (the case 'multiselect' line).
- this is because it is checking the value from the csv file (alphanumeric code) and finding it wasn't in the list of valid options for this attribute. This is because its list of valid options contained the label.
- The reason the list of options contains the label and not the value/code is because in Mage_ImportExport_Model_Import_Entity_Abstract#getAttributeOptions(..) it decides to use the label because the attribute isn't in an array of attributes that values should be used for. This array is declared in Mage_ImportExport_Model_Import_Entity_Abstract:
protected $_indexValueAttributes = array(
'status',
'tax_class_id',
'visibility',
'enable_googlecheckout',
'gift_message_available',
'custom_design'
);
So, the answer is to use in the csv file the label for the attribute. Or to overwrite Mage_ImportExport_Model_Import_Entity_Abstract to get your attribute into the array of attributes for which the value and not the label is expected during product imports.
Related
I am trying to add an expression in header section, which would display parameter value chosen by users (if everything selected, display "ALL" instead). I am having trouble with "Property" parameter.
Report structure:
Report is a matrix report that shows data by year and grouped by refBuildingID. Parameter "Property" is based on RefBuildingID. I want to show these parameter values in header when users run this report.
Expression:
=IIF(Countrows("BuildingID")=(Parameters!refBuildingID.Count),"All",Join(Parameters!refBuildingID.Value,", "))
Error:
The Value expression for the text box ‘Textbox31’ has a scope parameter that is not valid for an aggregate function. The scope parameter must be set to a string constant that is equal to either the name of a containing group, the name of a containing data region, or the name of a dataset.
Is there a way to get around this error?
Try this method:
=IIF(Count("BuildingID")=Count(Parameters!refBuildingID.Value),"All",Join(Parameters!refBuildingID.Value,", "))
i think CountRows will work
=IIF(COUNTROWS("BuildingID").Equals(Parameters!refBuildingID.Count),"ALL",Join(Parameters!refBuildingID.Value,", "))
I have a grid where the user can select records via checkbox in front of every record. Now I have a requirement to sort the records based on their selection, so that all selected records should be placed top, followed by the not selected ones.
Is there any standard function to achieve this? As an alternative I thought of saving the selection state as an attribute on every record and sort based on the attribute.
The code for the column is:
gridRealmDt.setSelectionType(SelectionStyle.SIMPLE);
gridRealmDt.setSelectionAppearance(SelectionAppearance.CHECKBOX);
I try to describe the code I use as the affected code is deeply nested in our own framework classes.
gridRealmDt is a subclass of smartgwt ListGrid. In my Dialog a create an instance of the grid which creates an instance of a database bound datasource. When the dialog is loaded the records are fetched from the database and after that a registered an dataArrivedHandler where I select the records which match records from another table.
I tried to place the selection attribute in an extra field and use that for sortig before my other sort criteria, but this does not work. Here is the code for the field I am using.
ListGridField txtSelected = new ListGridField(SELECTED, "");
txtSelected.setHidden(true);
txtSelected.setSortByDisplayField(true);
txtSelected.setCanSortClientOnly(true);
When I do not set the canSortClientOnly property the order by is sent to my database resulting in an error, as the table does not contain that field, so I set the property. Now I get following error
Removing field from the sort Specifier array because it specifies canSort Client Only: true and all data is not yet client-side.
I also tried to use a sortNormilizer on the Name field which is my main sort criteria, but the normalizer is called before the selection value is set to the record.
record.setAttribute(CARealmDS.SELECTED,selected ? "a" : "b");
I also cannnot find a way to call the normalizer when selection changes.
Currently we are using Smart GWT Version 6.0p.
I don't think there is any standard function. Just use grid store update. Place checked items first.
There are different ways to retrieve attribute values in Magento,
$options=$_product->getAttributeText('some_attribute')
$options=$_product->getResource()->getAttribute('some_attribute')->getFrontend()->getValue($_product)
$options=$_product->getSomeAttribute()
How different are the above methods and which is the proper way to retrieve attribute value?
echo $_product->getSomeAttribute()
would get the value with attribute as a text value or textarea value, etc..
echo $_product->getAttributeText('some_attribute')
would get an array of all options in a Drop Down or Multiple Select attribute type.
$attributes = $_product->getAttributes();
$someAttr = $attributes['some_attribute']->getFrontend()->getValue($_product);
would get you the value of any type of attribute, even the value from Drop Down or Multiple Select attribute types.
With getAttributetext you'll get the attribute directly on array of attributes.
When you are using get methods, you'll geting the product by the "right" way, becouse get and set can gage the date respecting the magento rules.
And using the getFrontend you'll geting this directly from database.
There is no right way to do this, but there is low cost solution, i think using get method and getAttributeText is the best way.
1.In my application there is a requirement to display certain value (among the 3 different values) in each row of the table column,the value to be displayed in each row can be decided by checking the values of two different model key paths.
This i tried to implement using bindings,where i used "Display pattern Value1 with one key path and custom value transformer class" and "Display pattern Value2 with other key path and same value transformer".But i am not getting desired output value from the transformer class.Can anyone please help me in resolving this issue.
2.In the other application there is a table view with 3 columns,where the first column displays the complete word,second column displays the prefix of that word and the third column displays the suffix of that word.
I implemented this requirement using bindings and two custom value transformer classes.One for getting the prefix of the word(prefixExtractor) and the other for getting the suffix of the word(suffixExtractor).Can anyone suggest me how can i implement this requirement using only one custom value transformer class so that it optimizes my code.
Thanks in advance.
I have a report that uses a Multi Value parameter. I have added this to the report and can specify the parameter values in code.
Now I want to filter the data on the report by the multiple value parameter. Eg, I pass in a list of account no's and I want to filter the data on the report so only records with the passed in account no's are shown.
In the tablix properties there is a filters option which looks like the place I need to set up the filters.
I have added a new one, selected the Account Number column on the report. The operator that seems relevant to me is the 'in' operator. So show records that a 'in' this list. However, If i select the 'in' filter the expression text box is disabled. Is this what im meant to use?
Found it:
You should filter on The name of the parameter rather than an expression.
eg:
[#CostCentres]
rather than:
=Parameters!CostCentres.Value