how to reorder programmatically drupal 7 ubercart 3 attributes - sorting

how can i programmatically arrange or set ordering of attribute
in ubercart3 in drupal7 i tried doing the following:
$node = node_load($product_id);
$node->attributes[1]->ordering = -25;
$node->attributes[12]->ordering = -24;
node_save($node);
nothing is changed when i saved it.
Can someone help out whats the workaround for this please..
i tried node_presave() hook samething happend, it didnt re-order the products attributes.

Related

CarouselView.FormsPlugin get index of specific page

I'm using Carousel View by alexrainman for creating custom wizard.
I need to get index of specific page by its type (I don't know exactly which index would that page have).
Something like this:
var indexAdvanced = MyCarouselView.GetIndex<ContentView>(typeof(AdditionalDefectParametersContentView));
but of course, this code doesn't work. While creating this question, I've got an idea with using CarouselView's ItemsSource. How to do it properly? TIA.
By the way, I've already found an answer. >_<
The resulting code is:
// My CarouselView consists of ContentViews
_indexAdvanced = MyCarouselView.ItemsSource.Cast<ContentView>().
IndexOf(view => view is AdditionalDefectParametersContentView);
So it works!
Don't know what should I do: delete this question or leave? Maybe It would be useful for somebody, so I'll leave it for now.

adding row manualy into DataGrid using VB6

i want to display the data into DataGrid manually in VB6, source of data is not from database or other source. I have created the column, like this:
For i = 2 To 4
DataGrid1.Columns.Add i
Next i
DataGrid1.Columns(0).Caption = "No"
DataGrid1.Columns(1).Caption = "Subdataset"
DataGrid1.Columns(2).Caption = "Dimension"
DataGrid1.Columns(3).Caption = "Check"
DataGrid1.Columns(3).Caption = "Detail"
but i can't add row and add value into it, i have tried like this:
Me.DataGrid1.AllowUserToAddRows = True
DataGrid1.Row = DataGrid1.Row + 1
then i got error
Please tell me if anybody can help me, thank you
Not only is DataGrid designed to be a bound control, it doesn't support unbound use. Says so right in the doc. So, the short answer is that you can't do what you are trying to do, because it's designed to display values from a database.
Instead, you'll want to use the MSFlexGrid control (Not the MSHFlexGrid control, although some of the doc confuses them), which you can read about here. Suppose you play around with that (the AddItem method is the fundamental piece you need to work with) and post back with specifics if you have problems.
Once you have added the table (DataGrid) right click select edit then you can insert columns:

Magento Can't mass update attributes for Required Field Error

I’m hoping someone can shed some light on this:
I’m using the search facility in Magento to find products with a certain attribute, and then selecting those products and using the “update attributes” feature to add data to (update) a different attribute field.
In some cases, this works fine, the new attribute data is recorded and all is well. On other selections when I try and save the new attribute data it comes up with the red warning “this is a required field”. Sure enough, the field it specifies IS a required field, but as I’m not updating that particular field I’ve not ticked the check box underneath it and this field should be ignored.
If I turn off the “required field” option for the highlighted fields then the new attribute data gets saved BUT: It wipes the data in loads of the other attributes, meaning I lose valuable data from my product attributes. It seems as if it works the first couple of times I use it in a day then it spits its dummy out and comes up with the required field issue.
I’ve tried this with both Google Chrome and Firefox. As I’ve said though, sometimes it will work , sometimes it won’t . I’m selecting 20-100 products at a time. I’ve even tried selecting just one product, and can still get the same error on that one product.
I’m on Magento 1.7.0.2
I did have a similar problem with attribute data getting wiped last year when we were on 1.6 but I seem to remember it was a Magento bug which was fixed when we upgraded to a newer version.
Can anyone shed any light on why this might be happening? There’s nothing coming up in the search engines for it and its really slowing me down!
The problem is that the attributes are NOT getting disabled by default in the update attributes page, hence require a value.
Why?
Most likely due to a faulty attribute failing somewhere above your attribute.
Option 1. As I don't know what attribute or the attribute problem, hack js/mage/adminhtml/product.js and change this function to ignore the faulty attribute.
function disableFieldEditMode(fieldContainer) {
try {
$(fieldContainer).disabled = true;
if ($(fieldContainer + '_hidden')) {
$(fieldContainer + '_hidden').disabled = true;
}
}
catch(exception) {
}
}
Option 2. Remove the faulty attribute from the product (You might need to remove restrictions ).
update eav_attribute set is_user_defined = 1 where attribute_code like 'foo_bar';
Option 3. Fix the faulty attribute. In my case the offending module was AW_Onsale.
it attempted to render a nonexistent frontend model: onsale/system_entity_form_element_position
select attribute_code, frontend_model from eav_attribute where attribute_code like '%aw_os_%';
aw_os_product_position | onsale/entity_attribute_frontend_position
update eav_attribute set frontend_model = null where attribute_code like '%aw_os_product_position%';
update eav_attribute set frontend_model = null where attribute_code like '%aw_os_category_position%';

Magento Javascript issue with image resizing

I'm using a Magento 1.4.1.1 install that I'm having issues with the javascript on a custom themed store.
For example, going to any product page (e.g. http://www.papakuraeducation.co.nz/index.php/teachers/magic-caterpillar-handwriting-casey-caterpillar-small-book.html) loads a Javascript file, which contains code which is supposed to scale down the .jpg file to fit the 'product-image' container it sits inside.
The relevent code seems to be around line #10279, which is causing a exception that $(imageEl).parentNode = null
Product.Zoom.prototype = {
initialize: function(imageEl, trackEl, handleEl, zoomInEl, zoomOutEl, hintEl){
this.containerEl = $(imageEl).parentNode;
this.imageEl = $(imageEl);
this.handleEl = $(handleEl);
this.trackEl = $(trackEl);
this.hintEl = $(hintEl);
(snipped...)
I've tried debugging it in Chrome and adding breakpoints, but tbh I'm not actually sure how to use this information to find the solution.
Any help in pointing me in the right direction would be greatly appreciated.
You have to add an ID to the <IMG> in question. This ID should than be fed into the following code-space:
product_zoom = new Product.Zoom('IMAGE_ID', 'track', 'handle', 'zoom_in', 'zoom_out', 'track_hint');

Flex 4: Add Items to a dropdownlist progmatically

I would like to add items to a dropdownlist progmatically.
I have an empty drop downlist and depending on a number of factors I then populate it with various action choices.
the Drop Down list is called dlFirstChoice and I would like to add some values to it, can some one give me the basic code to do so, I have tired ILists and Arrays as the Dataprovider but clearly Im doing something wrong.
Please and thank you in advance for any help.
var dropListDb:ArrayList=new ArrayList();
dropListDb.addItem({label: "Equals (List)"});
dropListDb.addItem({label: "Is Between"});
dlFirstChoice.visible = true;
dlFirstChoice.dataProvider=dropListDb;
dlFirstChoice.selectedIndex=0;

Resources