Practical Web Applications for Daily Living…
Object Oriented Programming
Displaying Product Images of Associated Products with Configurable Products in Magento
Aug 21st
$assoc_product = Mage::getModel(‘catalog/product’)->load($child->getId());
echo $assoc_product->getName();
foreach($assoc_product->getMediaGalleryImages() as $assoc_product_img){ ?>
<div>
<img src=’<?php echo $this->helper(‘catalog/image’)->init($assoc_product, ‘thumbnail’, $assoc_product_img->getFile())->resize(70, 70); ?>‘ />
</div>
<?php } ?>
The complete snippet is here
$product = Mage::getModel(‘catalog/product’);
$parent = $product->load($_product->getId());
$children = Mage::getModel(‘catalog/product_type_configurable’)->getUsedProductCollection($parent);
$xxx = $parent->getResource()->getAttribute(‘Color’)->getFrontend()->getValue($parent);
foreach($children as $child){
$child = $product->load($child->getId()); ?>
<div>
<a href="<?php echo $this->helper(‘catalog/image’)->init($child, ‘image’); ?>" id="<?php echo "link".$child->getResource()->getAttribute(‘Color’)->getFrontend()->getValue($child); ?>">
<img src="<?php echo $this->helper(‘catalog/image’)->init($child, ‘image’); ?>" id="<?php echo "img".$child->getResource()->getAttribute(‘Color’)->getFrontend()->getValue($child); ?>" />
</a>
<?php
$assoc_product = Mage::getModel(‘catalog/product’)->load($child->getId());
echo $assoc_product->getName();
foreach($assoc_product->getMediaGalleryImages() as $assoc_product_img){ ?>
<div>
<img src=’<?php echo $this->helper(‘catalog/image’)->init($assoc_product, ‘thumbnail’, $assoc_product_img->getFile())->resize(70, 70); ?>‘ />
</div>
<?php } ?>
</div>
<?php } ?>
Display more Attribute in Table Grid of Group Product Details in Magento
Aug 21st
Go to frontend/base/default/template/catalog/product/view/type/grouped.html
Add this code to the head of the table
<th class="a-right"><?php echo $this->__(‘Height’) ?></th>
insert this code in the table body:
where ’sign_width’ and ’sign_height’ are attribute names.
<td><?php echo $this->htmlEscape($_item->getData(’sign_height’)); ?></td>
enjoy!!!
How do you use configurable products versus group products in magento?
Zend framework on Saturday
Aug 18th
Currently I am uploading another batch of magento files to be deployed live, and I am so sleepy right now… well… anyway… This friday we don’t to have work because we are going to a company relaxation day, because our skins are turning green already due to work radiation… so after friday, the whole saturday.. I will try to implement a zend application so I can have a taste of it before deploying a heavy weight web app, and also to compare my experience in asp.net mvc development.
I was wondering if there are any tools that can help unit test zend framework apps, of can I even use castle project for them, I don’t know yet. Are zend frameworks applications a test driven design one… opssss… files are almost done uploading in 3, 2, 1, byeeee…..
Payroll system Singapore
Aug 12th
We are currently arming for a payroll system which is going to be deployed in Linux servers, my first choice is asp.net mvc but I am not sure if it is supported on the engine that can run asp.net apps to Linux (forgot the name of the engine). So the second choice is PHP, since it is the closest language I am fluent in using next to c#. But building payroll system from scratch is a total pain how much more if I code everything from zero. I have to pick a reliable framework for this. I have a little experience in cakephp and code igniter but I think this frameworks are still babys frameworks, I need a framework that has proven record and is used in enterprise level of applications. Enter Zend framework, used by varien to build there magento ecommerce platform, hmmmm…. so I made my choice, zend.
I downloaded the manual documentation and yep, it is in mvc pattern. So this thing is pretty easier for me.
Now the business analysis part, I am not an accounting Guy, I need to research on how payrolls flow, I really don’t care about this stuffs before.
I will be posting here the codes and scenarios as I move along with this project. Stay tune.
Coding in Asp.net MVC
Jul 3rd
Its been more than 6 months now, I haven’t touch anything about C# MVC, I’ve been following asp.net mvc for 5 months, and I had created some web apps in my local drive, I have digested the concept of model-view-controller and transitioning to Zend Framework which is one of my current weapons right now is fast. Right now I have an Idea of a web application system that can give solution to project workflows and I want to deploy it in the cloud. I’ve done some UI design already and we are using it right now, although not automated since I just to the thing first in MS exel, but I want to deploy this system to the cloud because I find out that we have generated a very effective project management system here for project collaboration, even better than basecamp.
Well…. I still have a lot of projects to finish, I am targeting to finish my android game before the year ends, And still I haven’t find any resource that can be my reference on how to optimize java codes to run super fast in the Android Platfrom. The codes that I am using is super basic, and it cannot handle my game requirements, especially for animations.
I am very hungry already… have to go back home ASAP…. !!!!
Android Game Development
Jul 3rd
I downloaded the source code of replica island, an open source project by one of Google’s advocate for android game development,
The codes are scattered everywhere and I don’t know where to start. I tried reading his diary building the game and it doesn’t help anything.
I stop my development right now because of a very tight deadline I have in office, so I want to open source my code to the github but… sad to say… I am having some problem creating a
repository, I already installed the github client and create a key, but somehow I still can’t connect, and because time is running out I just leave the task unfinished, And finish it nextweek. Still I am not confident on how I code the game, I want to structure everything clean and apply the notion of encapsulation so that when the game scales, the codes will still be manageable on my part.
Handling Paging in Gridview in codebehind
Nov 24th
OrderGrid.PageIndex = e.NewPageIndex
OrderGrid.DataBind()
End Sub
Sample Code for an Email Manager Class in Asp.net / C#
Nov 18th
{
private bool _issent;
public EmailManager()
{
}
public void Send(EmailContents emailcontents)
{
SmtpClient client = new SmtpClient(SMTPServerName);
client.UseDefaultCredentials = true;
MailAddress from = new MailAddress(emailcontents.FromEmailAddress, emailcontents.FromName);
MailAddress to = new MailAddress(ToAddress);
MailMessage message = new MailMessage(from, to);
message.Subject = emailcontents.Subject;
message.Body = Utilities.FormatText(emailcontents.Body, true);
message.IsBodyHtml = true;
try
{
client.Send(message);
IsSent = true;
}
catch (Exception ex)
{
throw ex;
}
}
public bool IsSent
{
get { return _issent; }
set { _issent = value; }
}
private string SMTPServerName
{
get { return ConfigurationManager.AppSettings["SMTPServerName"]; }
}
private string ToAddress
{
get { return ConfigurationManager.AppSettings["ToAddress"]; }
}
}
public struct EmailContents
{
public string FromName;
public string FromEmailAddress;
public string Subject;
public string Body;
}
public class NewsletterManager
{
private DataSet _userdata;
private string _messagebody;
public NewsletterManager()
{
}
public void SendNewsletter()
{
string unsubscr = string.Empty;
string msgbody = string.Empty;
EmailManager mailmanager = new EmailManager();
EmailContents mailcontents = new EmailContents();
using (StreamReader sr = new StreamReader(HttpContext.Current.Server.MapPath("~/Admin/EmailTemplates/CustomerNewsletter.htm")))
{
string stringBody = sr.ReadToEnd();
foreach (DataRow dr in UserData.Tables[0].Rows)
{
msgbody = stringBody;
unsubscr = "<a href=\"http://www.juliusbacosa.com/Admin/Unsubscribe.aspx?EndUserID=" +
dr["EndUserID"].ToString() + "?FullName=" +
dr["FirstName"].ToString() +
" " + dr["LastName"].ToString() +
"\"Target=\"_blank\"\">Click here</a>";
msgbody = msgbody.Replace("`+Name+", dr["FirstName"].ToString() +
" " + dr["LastName"].ToString());
msgbody = msgbody.Replace("`+MessageBody+", MessageBody);
msgbody = msgbody.Replace("`+Clickhere+", unsubscr);
mailcontents.To = dr["Email"].ToString();
mailcontents.FromName = "Julius Bacosa Chronicles";
mailcontents.FromEmailAddress = "juliusbacosa@gmail.com";
mailcontents.Subject = "Newsletter";
mailcontents.Body = msgbody;
mailmanager.Send(mailcontents);
}
}
}
public string MessageBody
{
get { return _messagebody; }
set { _messagebody = value; }
}
public DataSet UserData
{
get { return _userdata; }
set { _userdata = value; }
}
}
What makes Asp.net MVC beautiful!
Nov 17th
I’ve been a graphic designer and web designer for 2 years before I dive into world of serious web development at the backstage, my first impression of asp.net and how it renders its html is wtf! Yes, asp.net webforms has help a lot in creating reports. ( blahhh, blahh , )
