Magento Collection load for sales order with custom fields - magento-1.4

I am new to magento. I have added two text fileds(custom options) for products in magento admin panel.
When the customer purchasing products these two text fields are required. I need to load the collection for sales order to get this two fields.
Customer fields namely like:
1) domain name 2) activation code
Can any one give me guidance? How to get this text fields from magento sales order?
thanks

Below collection will get your products custom fields from sales order
I have tried my self and got the final result.
Note : These products custom fields values entered by the customer in the product details page.
$order = Mage::getModel('sales/order');
$orderItems = $order->getItemsCollection();
$orderItems->addFieldToFilter('product_options',array('like'=>'%'.$domain_name.'%'));
$data = $orderItems->getData();

Related

Checkbox reveal which items are selected on page

on my page a user can select multiple items.
I use a checkbox and iterate over all the items of a user.
Now I want to show the user the total price of all the items he selected on that page.
So to say the total price of the shopping cart.
How can I access the ids of my items on the same page that the user clicks on them? I know that in the controller I can access them by
Item.find(params[:items])
Thanks a lot in advance :)
You'll need to do this via Javascript.
One way is to store the id in the data tags of your html element (checkbox in this case)
Then you can get this value in your Javascript callback as
element.getAttribute('data-type');
or if you are using jQuery
$(this).data("id")
Now you will need to access the value of the item (individual price for the item with the selected id) as well in Javascript. You can do this by either storing the mapping of id to price in a js variable
let prices = <%= #items.select(:id, :price).to_json %>;
or alternatively, you can just store the price in a data-attribute of each checkbox, and use this value to update the total selected price.

How to store different sets of user information using ASP.NET MVC Simple Memberships

How do I store different sets of user information using Simple Memberships? For eg. I have two roles (doctors and patients) respectively. The extended user information to be stored for both the roles is somewhat different. Simple Membership creates a UserProfile table by default which I'd like to split into two tables to accomodate the user information for both the roles respectively.
Please suggest if and how this can be achieved.
Thanks.
You have Roles defined in your 'Roles' Table. Then, for a particular User, UserId and RoleId both are associated with each other in another Table named '_UserInRoles'. Now, Create another table maybe Named as 'UserAdditionalInfo' and
make table structure as below
Id(PK)
UserId(FK)
RoleId(FK)
Column1
Column2
Now, you can save user additional data according to its RoleId and UserId in another table and when you need to display User Profile on front end, then may be you can use JOIN in these tables and return information.

QBFC- entity reference keys between recievePaymentsToDeposits and Invoices and Customers

I am developing a accounting third party C# form application for my company which bulk load the payments from external source, for prototype, I using an excel file for actual payment data.
Now that I have IRecievePaymenttoDeposit, I get all unpaid invoices with customer refs and by IInvoiceQuery I can get customers, but what is the reference keys for these two queries?
I will be getting a customer name, customer id and invoice no, how can I add the amount to the selected payment.
In order to apply a payment to an invoice, you need the TxnID of the invoice, which is different than the invoice number. You can use the invoice number, however to query for the invoice to get the TxnID.
IInvoiceQuery invQuery = MsgRequest.AppendInvoiceQueryRq();
invQuery.ORInvoiceQuery.InvoiceFilter.ORRefNumberFilter.RefNumberFilter.RefNumber.SetValue(invoiceNumber);
// Use either the full name of the customer or the ListID
invQuery.ORInvoiceQuery.InvoiceFilter.EntityFilter.OREntityFilter.FullNameList.Add(customerName);
invQuery.ORInvoiceQuery.InvoiceFilter.EntityFilter.OREntityFilter.ListIDList.Add(customerid);
Once you have the invoice, you get can get the TxnID. Then, when you create your ReceivePaymentAdd you specify the TxnID to apply the payment to:
// Create the payment add request
IReceivePaymentAdd pmtAdd = MsgRequest.AppendReceivePaymentAddRq();
// Create the AppliedToTxn request for the payment.
IAppliedToTxnAdd appAdd = pmtAdd.ORApplyPayment.AppliedToTxnAddList.Append();
// Set the invoice TxnID and amount of the payment to apply
appAdd.TxnID.SetValue(invoiceTxnID);
appAdd.PaymentAmount.SetValue(amountToApply);

How to update the same attributes in several tables with Postgresql and Rails

In order to minimize the number of joins that I have to execute in my application I decided to copy in my database the same field in several tables for example :
I have a User, Product and a Wishlist Table.
My Product pages shows the user who created the product, as the wishlists pages which also shows the user who created them.
So I added in my products and wishlists table all the users field needed to show the required informations.
How can I update the users related fields in my Products and Wishlists Table as soon as the user change his information ?
Here is a part of my model :
User Table
Full Name
UserName
Avatar URL
Product Table
Product Name
Product Price
User ID
User Full Name
Username
User Avatar URL
Wishlist Table
Wishlist Name
User ID
User Full Name
Username
User Avatar URL
Thanks in advance for your answers !
Firstly, by denormalizing the data in the way that you are, you are working against what relational databases are meant to do. They thrive on joins, and having each piece of data appear as few times as possible. So you really want to make sure that this is the schema that you want.
That being said, you can use the basic update_attibute syntax to update any field in any table. So, if a user edited his or her username, you would do:
User.update_attribute(:username, username)
Product.update_attribute(:username, username)
Wishlist.update_attribute(:username, username)

Ruby on Rails HABTM Multiple Dropdowns with AJAX

I have a typical HABTM relationship between members (actual members of our organization, not all have online accounts) and users (online accounts). I have an edit users page for site administrators where multiple members can be assigned to users.
There are too many members to reasonably use checkboxes or a multi-select dropdown. I have decided to use dropdowns that are added by clicking an "Add Member" button that uses an AJAX function to add a dropdown.
Here's what I have working:
I can add dropdowns and pick any member. On save, the relationships are established.
I can edit that user and add more members, remove members, and change members in the dropdown.
The final piece I am struggling with is having my remove link (next to each member drop down) remove a drop down for a new user. The reason being that the action behind the remove link relies on the id of the div that contains the dropdown. When editing a user, this id is generated based on the selected member. For a new user, I do not know the selected member in the dropdown, so I can't assign it an id that I can know about when the remove link is clicked.
Are dropdowns the way to go? Are there any good tutorials or examples of what I am describing out there? Should I perhaps update the div ID in an onchange event in the dropdown?
I have found that the best way to do this is to use the object_id of member to create a unique div id. My Javascript function is then able to use this to remove the div.

Resources