Is it upgrade safe to add custom address attributes - magento

currently i am developing a Magento extension, that needs to add several custom attributes to customer address.
I've found several tutorials on the topic that describe precisely what i need to build
http://www.unexpectedit.com/magento/add-new-customer-attribute-onepage-magento-checkout
http://www.excellencemagentoblog.com/magento-adding-custom-field-to-customer-address
They all use ALTER TABLE to add columns to several db tables.My question is :
Is it upgrade safe to do this?
Thanks in advance

They're using the magento framework method addAttribute() not pure SQL queries. They're using it in an upgrade script and it's its purpose : to upgrade safely a database..
Note that the EAV mechanims of the customer entity is built in order to not alter the table definition but add data in it. So in the background customer::addAttribute doesn't do a single ALTER TABLE. On the contrary, the now flated-tables sales_flat_order/quote addAttribute method does alter the tables cause it's no more an EAV entity.
They're doing it right.
I don't really understand your question.

Related

Postgres ActiveRecord limit table size to one row

I am creating a custom CMS using Sinatra and Postgres with sinatra-activerecord enabled. I am creating a model called SiteInfo which will store information such as the about_description, about_photo, tagline, etc. Is there a way within the migration to create that SiteInfo table to specify that there can only be one row? There's no way through the interface for the admin or user to create an additional one, I'm just wondering.
To answer your question: No, you can't, and there is no need for.
You'll want to do something like SiteInfo.first to load your information anyway.

Model with multiple tables

We run two websites, A and B. Each website has its own table, _a_ and _b_ which have exactly the same structure. Yes, I know it's silly, we'll be rewriting them over the course of this year and next.
Using Laravel I need to create a model that will hold both tables content. I don't need any kind of UPDATE or INSERT functionality, I just need to SELECT and use with to access other model information.
Is this possible with Laravel 4.1? I can individually model each table, but that would make it difficult in the future.
I was able to fix this by making using the Repository pattern and merging the results of each model into the get and all functions.

mutual exclusion in joomla

I created an extension for joomla using:
$id=$database->insertid();
I just covered that if two users are logged on to the site will fit together perform two records in the database and then this statement will return in both cases the same value.
in php you can solve this problem with the transactions.
In joomla how do I solve this problem?
If you have a table you are working with that extends JTable then make sure that you included the check out functionality that is optionally a part of that. THis must means adding a couple of fields like what is in the content table. This will prevent two people from editing the same row at the same time which creates a race condition in which one of the other will lose their data.
Please note that both php and joomla functions to return the last insert id rely on the mysql implementation, and mysql returns the last id inserted on the currently open connection so concurrency is not an issue
#iacoposk8 Your are right it might possible that in very rear case. Such time try to add current logged in user id in your sql query or any where so that it doesn't make any confict. I hope you get it what i want to say. Thanks

Magento coupon entities in database

I'm trying to develop a Magento plugin which involves using coupons. Apparently after looking around I found a source that mentions use of a 'salesrule' table for coupons. However when I looked at my database i couldn't find it. However I did find 3 tables that had mention 'coupon' called 'coupon_aggregated', 'coupon_aggregated_order', and 'coupon_aggregated_updated'.
I just wanted to know what is the difference between the 3 tables so I can start using them? I am on the latest version of Magento.
The table you're looking for is indeed named
salesrule
There's also a table named salesrule_coupon, which contains specific coupon codes linked back to the main salesrule definition.
If your database is missing this table, something bad has happened to your system. Go to
Promotions -> Shopping Cart Price Rules
and create a new coupon code with a distinct title. Then dump your database content and search for the text of your distinct title. That will let you know which table your system is storing salesrules in.
The tables you mentioned above are aggregate data tables used for reporting only.

Magento: Custom Module: How to Manage with Multiple tables

I am working on magento custom module [created by module creator].
There is a requirement to create a Child table which maintains the relation to the default/parent table by means of primary/foreign key references.
There is a one-to-many relation from parent-to-child table.
I need to have the Grid interface and Edit interface to update/save all relevant data.
Please, provide me the way to manage this module.
I have just tried the join clause on default data collection as below:
===============================
In protected function _prepareCollection() At "\app\code\local\Klimaire\WarrantyRegProd\Block\Adminhtml\WarrantyRegProd\"
$collection->getSelect()->joinLeft('warrantyregprod_child','main_table.warrantyregprod_id = warrantyregprod_child.warrantyregprodID', 'warrantyregprod_child.prodcode');
===============================
What you are asking for is a very advanced aspect of Magento (custom Admin code and functionality). I would suggest you go through online or in-person training as this is far to complex to describe in a stackoverflow answer (I went through training, and this is honestly a 10-step process that takes about an hour just to copy/paste demo code -- custom work will probably be anywhere from 4-6 hours to complete). Your question is also somewhat incomplete -- need more info if you are having sql-specific problems. You also never want to call select statements from a Block - these should be managed by Models, and you should also call your collections from your Models.

Resources