Friday

BBC World Cup 2010 dynamic semantic publishing

The World Cup 2010 website is a significant step change in the way that content is published. From first using the site, the most striking changes are the horizontal navigation and the larger, format high-quality video. As you navigate through the site it becomes apparent that this is a far deeper and richer use of content than can be achieved through traditional CMS-driven publishing solutions.

The site features 700-plus team, group and player pages, which are powered by a high-performance dynamic semantic publishing framework. This framework facilitates the publication of automated metadata-driven web pages that are light-touch, requiring minimal journalistic management, as they automatically aggregate and render links to relevant stories.

eng_595.jpg

Dynamic aggregation examples include:

The underlying publishing framework does not author content directly; rather it publishes data about the content - metadata. The published metadata describes the world cup content at a fairly low-level of granularity, providing rich content relationships and semantic navigation. By querying this published metadata we are able to create dynamic page aggregations for teams, groups and players.

The foundation of these dynamic aggregations is a rich ontological domain model. The ontology describes entity existence, groups and relationships between the things/concepts that describe the World Cup. For example, "Frank Lampard" is part of the "England Squad" and the "England Squad" competes in "Group C" of the "FIFA World Cup 2010".

The ontology also describes journalist-authored assets (stories, blogs, profiles, images, video and statistics) and enables them to be associated to concepts within the domain model. Thus a story with an "England Squad" concept relationship provides the basis for a dynamic query aggregation for the England Squad page "All stories tagged with England Squad".

This diagram gives a high-level overview of the main architectural components of this domain-driven, dynamic rendering framework.

diagram_595.png

The journalists use a web tool, called 'Graffiti', for the selective association - or tagging - of concepts to content. For example, a journalist may associate the concept "Frank Lampard" with the story "Goal re-ignites technology row".

In addition to the manual selective tagging process, journalist-authored content is automatically analysed against the World Cup ontology. A natural language and ontological determiner process automatically extracts World Cup concepts embedded within a textual representation of a story. The concepts are moderated and, again, selectively applied before publication. Moderated, automated concept analysis improves the depth, breadth and quality of metadata publishing.

Journalist-published metadata is captured and made persistent for querying using the resource description framework (RDF) metadata representation and triple store technology. A RDF triplestore and SPARQL approach was chosen over and above traditional relational database technologies due to the requirements for interpretation of metadata with respect to an ontological domain model. The high level goal is that the domain ontology allows for intelligent mapping of journalist assets to concepts and queries. The chosen triplestore provides reasoning following the forward-chaining model and thus implied inferred statements are automatically derived from the explicitly applied journalist metadata concepts. For example, if a journalist selects and applies the single concept "Frank Lampard", then the framework infers and applies concepts such as "England Squad", "Group C" and "FIFA World Cup 2010" (as generated triples within the triple store).

This inference capability makes both the journalist tagging and the triple store powered SPARQL queries simpler and indeed quicker than a traditional SQL approach. Dynamic aggregations based on inferred statements increase the quality and breadth of content across the site. The RDF triple approach also facilitates agile modeling, whereas traditional relational schema modeling is less flexible and also increases query complexity.


Our triple store is deployed multi-data center in a resilient, clustered, performant and horizontally scalable fashion, allowing future expansion for additional ontologies and indeed linked open data (LOD) sets.

The triple store is abstracted via a JAVA/Spring/CXF JSR 311 compliant REST service. The REST API is accessible via HTTPs with an appropriate certificate. The API is designed as a generic façade onto the triplestore allowing RDF data to be re-purposed and re-used pan BBC. This service orchestrates SPARQL queries and ensures that results are dynamically cached with a low 'time-to-live' (TTL) (1 minute) expiry cross data center using memcached.

All RDF metadata transactions sent to the API for CRUD operations are validated against associated ontologies before any persistence operations are invoked. This validation process ensures that RDF conforms to underlying ontologies and ensures data consistency. The validation libraries used include Jena Eyeball. The API also performs content transformations between the various flavors of RDF such as N3 or XML RDF. Example RDF views on the data include:

Automated XML sports stats feeds from various sources are delivered and processed by the BBC. These feeds are now also transformed into an RDF representation. The transformation process maps feed supplier ids onto corresponding ontology concepts and thus aligns external provider data with the RDF ontology representation with the triple store. Sports stats for matches, teams and players are aggregated inline and served dynamically from the persistent triple store.

The following "Frank Lampard" player page includes dynamic sports stats data served via SPARQL queries from the persistent triple store:

frank_595.jpg


The dynamic aggregation and publishing page-rendering layer is built using a Zend PHP and memcached stack. The PHP layer requests an RDF representation of a particular concept or concepts from the REST service layer based on the audience's URL request. If an "England Squad" page request is received by the PHP code several RDF queries will be invoked over HTTPs to the REST service layer below.

The render layer will then dynamically aggregate several asset types (stories, blogs, feeds, images, profiles and statistics) for a particular concept such as "England Squad". The resultant view and RDF is cached with a low TTL (1 minute) at the render layer for subsequent requests from the audience. The PHP layer dynamically renders views based on HTTP headers providing content negotiated HTML and/or RDF for each and every page.

To make use of the significant number of existing static news kit and architecture (apache servers, HTTP load balancers and gateway architecture) all HTTP responses are annotated with appropriate low (1 minute) cache expires headers. This HTTP caching increases the scalability of the platform and also allows content delivery network caching (CDN) if demand requires.

This dynamic semantic publishing architecture has been serving millions of page requests a day throughout the World Cup with continually changing OWL reasoned semantic RDF data. The platform currently serves an average of a million SPARQL queries a day with a peak RDF transaction rate of 100s of player statistics per minute. Cache expiry at all layers within the framework is 1 minute proving a dynamic, rapidly changing domain and statistic-driven user experience.

The development of this new high-performance dynamic semantic publishing stack is a great innovation for the BBC as we are the first to use this technology on such a high-profile site. It also puts us at the cutting edge of development for the next phase of the Internet, Web 3.0.

So what's next for the platform after the World Cup? There are many engaging expansion possibilities: such as extending the World Cup approach throughout the sport site; making BBC assets geographically 'aware' is another possibility; as is aligning news stories to BBC programs. This is all still to be decided, but one thing we are certain of is that this technological approach will play a key role in the creation, navigation and management of over 12,000 athletes and index pages for the London 2012 Olympics.


Jem Rayfield is Senior Technical Architect, BBC News and Knowledge. Read the previous post on the Internet blog that covers the BBC World Cup website, The World Cup and a call to action around Linked Data.


Metadata is data about data - it describes other data. In this instance, it provides information about the content of a digital asset. For example, a World Cup story may include metadata that describes which football players are mentioned within the text of a story. The metadata may also describe the associated team, group or organization associated to the story.

IBM LanguageWare Language and ontological linguistic platform.

RDF is based upon the idea of making statements about concepts/resources in the form of subject-predicate-object expressions. These expressions are known as triples in RDF terminology. The subject denotes the resource; and the predicate denotes traits or aspects of the resource and expresses a relationship between the subject and the object. For example, to represent the notion "Frank Lampard plays for England" in RDF is as a triple, the subject is "Frank Lampard"; the predicate is "plays for" and the object is "England Squad".

SPARQL (pronounced "sparkle") is an RDF query language its name is a recursive acronym (i.e. an acronym that refers to itself) that stands for SPARQL Protocol and RDF Query Language.

BigOWLIM A high performance, scalable, resilient triplestore with robust OWL reasoning support

LOD The term Linked Open Data is used to describe a method of exposing, sharing, and connecting data via dereferenceable URIs on the Web.

JAVA Object-orientated programming language developed by Sun Microsystems.

Spring Rich JAVA framework for managing POJOs providing facilities such as inversion of control (ioc) and aspect orientated programming

Apache CXF JAVA Web services framework for JAX-WS and JAR-RS

JSR 311 Java standard specification API for RESTful web services.

Memcached Distributed memory caching system (deployed multi datacenter)

Jena Eyeball JAVA RDF validation library for checking ontological issues with RDF

N3 Shorthand textual representation of RDF designed with human readability in mind.

XML RDF XML representation of an RDF graph.

XML (Extensible Markup Language) is a set of rules for encoding documents and data in machine-readable form

Zend Open source scripting virtual machine for PHP, facilitating common programming patterns such as model view controller.

PHP Hypertext Preprocessor general-purpose dynamic web scripting language, use to create dynamic web pages.

CDN A content delivery network or content distribution network (CDN) is a collection of computers usually hosted within Internet Service Provider hosting facilities. The CDN servers cache local copies of content to maximize bandwidth and reduce requests to origin servers.

OWL Web Ontology Language (OWL) is a family of knowledge representation languages for authoring ontologies.

courtsy: BBC Jem Rayfield

Wednesday

Cake PHP vs Zend Framework

The Zend Framework, developed by Zend Technologies is an open-source, object oriented web-application framework implemented in PHP 5. It is widely known as ZF and is developed with the purpose of making things easier for PHP developers and supporting best practices at the same time. CakePHP too, is an open-source web application framework used for creating web applications written in PHP. It is developed by Cake Software Foundation, Inc. It is written in PHP and is based on the model of Ruby on Rails.

Zend Framework has easy methods of licensing with the new BSD license and a swift and well-tested code base that your business can rely upon. It makes use of commonly available APIs from well known vendors like Google, Amazon, Yahoo!, Flickr and API providers and catalogers such as StrikeIron and Programmable Web.

ZF offers a simple component library to provide 80 percent of the functionality mostly needed by developers. The rest of the 20 percent can be altered as per your requirements of the business. This can be done since it has a flexible architecture and you do not need any configuration file to get started with. Due to this, training costs are lessened and the product reaches the market sooner. Moreover, Zend Framework also offers:

  • AJAX support through JSON, which offers ease-of-use of the framework.
  • The PHP version of the Lucene Search engine.
  • Simple access to data formats needed in Web 2.0 applications.
  • The ideal destination to utilize and publish web services.
  • Top quality, object-oriented PHP 5 class library.

CakePHP is a rapid development framework for PHP that offers a flexible architecture for development, maintenance and deployment of applications. It uses the usual design patterns like MVC and ORM within the convention over configuration paradigm that helps lower development expenses and does not need the developers to write a lot of code. CakePHP boasts of clients like Mozilla Addons, Scratch by MIT, Yale Daily News, Onion Store and MapMe to name a few.

Just like ZF, CakePHP does not require configuration. It is very simple to use. The company has a user friendly community called #cakephp on IRC that helps new users to begin. It is distributed under the MIT License and promises Best Practices like security, authentication and session handling. It has an object-oriented approach to keep you at ease.

Overall, both these frameworks are good to use as per your requirements. CakePHP is suitable for developers new to MVC and those who require stricter conventions. ZF is a choice for those who need better control over the application design and built-in support for renowned Web services. Both the frameworks are developing fast and the choice is entirely yours.

curtsy: Douglas Brown

The Zend Framework, developed by Zend Technologies is an open-source, object oriented web-application framework implemented in PHP 5. It is widely known as ZF and is developed with the purpose of making things easier for PHP developers and supporting best practices at the same time. CakePHP too, is an open-source web application framework used for creating web applications written in PHP. It is developed by Cake Software Foundation, Inc. It is written in PHP and is based on the model of Ruby on Rails.

Zend Framework has easy methods of licensing with the new BSD license and a swift and well-tested code base that your business can rely upon. It makes use of commonly available APIs from well known vendors like Google, Amazon, Yahoo!, Flickr and API providers and catalogers such as StrikeIron and Programmable Web.

ZF offers a simple component library to provide 80 percent of the functionality mostly needed by developers. The rest of the 20 percent can be altered as per your requirements of the business. This can be done since it has a flexible architecture and you do not need any configuration file to get started with. Due to this, training costs are lessened and the product reaches the market sooner. Moreover, Zend Framework also offers:

  • AJAX support through JSON, which offers ease-of-use of the framework.
  • The PHP version of the Lucene Search engine.
  • Simple access to data formats needed in Web 2.0 applications.
  • The ideal destination to utilize and publish web services.
  • Top quality, object-oriented PHP 5 class library.

CakePHP is a rapid development framework for PHP that offers a flexible architecture for development, maintenance and deployment of applications. It uses the usual design patterns like MVC and ORM within the convention over configuration paradigm that helps lower development expenses and does not need the developers to write a lot of code. CakePHP boasts of clients like Mozilla Addons, Scratch by MIT, Yale Daily News, Onion Store and MapMe to name a few.

Just like ZF, CakePHP does not require configuration. It is very simple to use. The company has a user friendly community called #cakephp on IRC that helps new users to begin. It is distributed under the MIT License and promises Best Practices like security, authentication and session handling. It has an object-oriented approach to keep you at ease.

Overall, both these frameworks are good to use as per your requirements. CakePHP is suitable for developers new to MVC and those who require stricter conventions. ZF is a choice for those who need better control over the application design and built-in support for renowned Web services. Both the frameworks are developing fast and the choice is entirely yours.

curtsy: Douglas Brown

Thursday

Indian becoming Cloud service leader

India has potential to emerge as the global competency centre for cloud services, says Microsoft.

India, with its powerful ecosystem of over 1300 independent software vendors (ISVs), 1.4 million developers and more than 11000 system integrators (SIs and custom software development organizations), is ideal to tap this growing opportunity.

As a result, an additional 300,000 jobs related to cloud services are estimated to be created in India over the next 5 years. A study by global consultants, Zinnov estimates the global cloud computing market to be over $70 billion by 2015.

Steve Ballmer, CEO, Microsoft Corporation said, "India will not only see a surge in consumption of cloud services, driving growth in domestic IT usage, but companies all over the world will look to India to support their transition to cloud computing."

Microsoft's cloud infrastructure supports over one billion customers and 20 million businesses globally. Leaders from the industry and academia also support Microsoft cloud services.

NIIT will train over 100,000 students on Windows Azure over the next three years

Rajendra Pawar, Chairman, NIIT said, "We foresee the power of the cloud and the following gap in the skill set. Through our exclusive program, our attempt is to offset this gap by churning out first-day first-hour trained professionals on Windows Azure".

Academic institutions such as the IITs and IIITs are also building large India-relevant projects leveraging Microsoft's Azure platform.

Cognizant has announced the creation of a vertically aligned set of industry frameworks and pre-built solution accelerators to enable implementation, migration and management of cloud-enabled application portfolios built on Azure for clients both in India and globally.

"Windows Azure helps customers unlock the value that can be derived from cloud-enabled services, and helps them build strong and agile businesses," said Chandrasekaran, president and MD (global delivery), Cognizant.

CDC Software has announced the global roll out of its flagship product 'CDC Respond' (a complaint and feedback management application for banking and government sectors) on Windows Azure.

The Indian Institute of Science, Bangalore, is building a large-scale application on Windows Azure to study the basic resource allocation constructs and strategies required for addressing enterprise needs on cloud computing.

These announcements are in addition to the over 4000 applications that have already been built on the Windows Azure platform by India.

ISVs and SIs including Wipro , Infosys, TCS, HCL Technologies and Mahindra Satyam are building applications and solutions across verticals ranging from healthcare to banking to manufacturing for both local and global markets.

courtsy: rediff.com

Wednesday

IP addresses and its future

It has emerged that the IP addresses used in helping to distinguish one computer from another are expected to run out in approximately 500 days.

The unique numbers, which are known as Internet protocol addresses, help identify the world's networked devices.

An IP address uses four numbers from 0 to 255 to distinguish one computer from another. As an example, computers around the world can recognise the IP address 203.26.51.71 as a server for fairfax.com.au, which publishes this newspaper online.

There are more than four billion combinations. But the proliferation of networked devices means soon that will no longer be enough.

In a way, IP addresses are like phone numbers, which need to be entered correctly if a right connection is to be made. So the ability to uniquely identify everything in the computer world is essential.

IP addresses are like phone numbers in another way, too.

Just as Australia [ Images ] had to move from seven-digit phone numbers to eight digits in the early 1990s, massive change will now be required globally to resolve the problem.

However, there's a complication.

"Unlike the telephone system, it's not easy to just add more digits," the Sydney [ Images ] Morning Herald quoted chief scientist at the Asia Pacific Network Information Centre, Geoff Huston, as saying.

Although every telephone number in Australia was successfully altered, the phones themselves didn't change. Humans simply dialled an extra number and were connected to the person.

But every web server, every iPhone, every router and everything else - possibly billions of devices - will need to be reconfigured or upgraded.

"The idea that every last one has to go back into the doctor for a new transplant does sound a bit frightening. It's almost like having to teach every device a new language," Huston said.

Fortunately, a new language exists.

Computers now use IP version 4 and have since the 1980s. Its replacement is version 6, known as IPv6. For humans, little will change.

The traditional way we visit a website, by typing google.com or facebook.com, won't be any different and personal computers will automatically use IPv4 or IPv6 as required.

The impending shortage has been apparent for more than a decade as the volume of networked devices has escalated but inertia has stymied efforts to prepare for IPv6, Huston revealed.

While personal computers have been capable of understanding IPv6 since Windows XP and Apple OS X, Huston says only about 5 percent of devices are configured to do so. Among web servers, the figure is less than 1 per cent.

Internode is one of the few Internet service providers that offers an IPv6 service. Telstra is among the many that do not. Tens of millions of mobile phones are on an IPv4 network only.

Technically, it's not all that difficult to enable IPv6. Logistically, it's a horrendous challenge, and the conversion can involve substantial costs, with little in return.

"It doesn't make your Internet any shinier or any brighter, so customers won't pay more," he said.

Consequently, Huston predicts we will get to a point where large numbers of people will no longer be able to see everything on the Internet.

So far, the dwindling storehouse of IP addresses has been managed with trickery that translates one IP address to another.

But by about late September next year, the key body that distributes IP addresses will run out of them. Three months after that, every drop in the pipeline will dry up and the only way to get an IPv4 address will be to buy one from someone else.

Lacking that, consumers whose computers are not configured to use IPv6 won't see new websites. Likewise, iPhones, which don't understand IPv6, will be limited to the "old" Internet.

For businesses that are not prepared, this could spell trouble. Unless web servers and mobile phone services are configured to send information via IPv4 as well as IPv6, companies could be left with a fraction of their current customers.

The good news is that once IPv6 is in place, it should satisfy demand as far as a computer can calculate.

"If every single address was one grain of sand, in IPv6 you could build 300 million planets the size of Earth," he added.
Source: ANI

Magento - how to add new attributes

To add customiged fields for shop customer..

First We can make a module to extend the functionality of the customer module already in magento. First adding the module xml file to the app/etc/modules/ directory. You need to decide on a module name. In this example we will use the Sarvottom scope, and call the module 'NewCustomer'. Therefore we need to create a file named Sarvottom_NewCustomer.xml and add the following content:
<code>
<config>
<modules>
<Sarvottom_NewCustomer>
<active>true</active>
<codePool>local</codePool>
</Sarvottom_NewCustomer>
</modules>
</config>
</code>

Second to add the above file means that Magento is now aware of a new custom module been added as local module. Now, we need to create the module itself, which must be located in the app/code/local/Sarvottom/NewCustomer directory. Inside this directory, create an etc directory and copying the following file inside:

app/code/core/Mage/NewCustomer/etc/config.xml

Edit the file and change :
<code>
<modules>
<Mage_NewCustomer>
<version>x.x.x</version>
</Mage_NewCustomer>
</modules>

to:

<modules>
<Sarvottom_NewCustomer>
<version>1.0.0</version>
</Sarvottom_NewCustomer>
</modules>
</code>
Third this file default contains two different <fieldsets> - one in <config><admin> and one in <config><global>. At the end of the second one, in the <config><global><fieldsets><customer_account> scope, add:
<code>
<account_no><create>1</create><update>1</update></account_no>
</code>
In this example account_no is the chosen attribute code. The attribute code that you choose here will be important in all the following steps.
Next we need to add the attribute to the NewCustomer Entity Setup Model. To do this, copy the getDefaultEntities method from app/code/core/Mage/Customer/Model/Entity/Setup.php file to a new file, Model/Entity/Setup.php in our module. Put the method inside the following class:

class Sarvottom_NewCustomer_Model_Entity_Setup extends Mage_Customer_Model_Entity_Setup

Then add the following code at the end of the attributes array inside the customer arrray:

'account_no' => array(
'label' => 'Account No',
'visible' => true,
'required' => true,
),

In this case the new attribute is set as compulsory by adding 'required' => true, to the end of that array. If you want the attribute to be optional, remove the required lines.
Next new attribute needs to be added to the Magento database. The best way to do this is to tell Magento to insert it for you. You can either create your own script that uses the Magento code or you can just drop the following code into one of your template files:

$setup = new Mage_Eav_Model_Entity_Setup('core_setup');
$setup->addAttribute('customer', 'account_no', array(
'label' => 'Account No',
'type' => 'varchar',
'input' => 'text',
'visible' => true,
'required' => true,
'position' => 1,
));

A brilliant way to add the above code is the <theme>/template/customer/form/register.phtml file since it needs to be edited to add a custom field for the new attribute. Make sure the above code is enclosed with
<code>
<?php
...
?>
</code>
To add the attribute (ie. run this code) view the register new customer page. Once you have viewed the page this code can be removed.

In this example the attribute type is set to varchar and the input is set to text. This needs to be modified to match the requirements of each specific attribute.
Next point, the attribute is installed and it will show up in the backend. We need to modify the frontend, so that the customers can enter values for the custom attribute. There are two fairly similar phtml files:
<code>
<theme>/template/customer/widget/name.phtml
</code>
Now you need to add a new text box in the name.phtml file, since that is what customers see on the register page. Make sure that the ID and name of the new input text box match the attribute code chosen in step 3. In this case it is 'account_no'. The following shows the sample code that adds a new text box with a label:
<code>
<div class="input-box">
<label for="account_no"><?php echo $this->__('Account No') ?><span class="required">*</span></label><br />
<input type="text" name="account_no" id="account_no" value="<?php echo $this->htmlEscape($this->getFormData()->getAccount_No()) ?>" title="<?php echo $this->__('Account No') ?>" class="required-entry input-text" />
</div>
</code>

Friday

Bypass Magento Payment and Shipping

Magento has always been flying forward with code optimization and adding new features. Recently I’ve been tasked with upgrading one of our websites from 1.2 to 1.3.2
Seems like alot has changed since that time, no core changes are now required, you can overwrite code functionality with your own controllers, and etc.. Awesome! So lets move forward.

How would you disable shipping and payment steps for you Magento installation and apply changes in such manner that you wont have to worry about this when doing the next Magento upgrade?
Below is a step by step tutorial “copy paste” pretty much.

Now I don’t expect this that this solution will always work with next version of Magento, but unless they deprecate some existing functionality I’m sure you wont need to change anything.
NOTE: When doing copy paste make sure you wont end up with weird characters, such as single and double quotes.

STEP 1

First step would be to get a Magento extension called “LKC_ModularRouters” (ext. key: “magento-community/LKC_ModularRouters” to be used in MagentoConnect from admin tool)
After installation you can proceed to step 2, if you are using Magento v.1.3 if you are on a newer version you would need to make some tweaks to that module, since it has not been updated for the newer versions yet.
See how to do it…

STEP 2

Next, you would want to do is to create a project folder under /app/code/local
Lets say we name it “XYZ”

STEP 3

First, lets create a Bock that will overwrite existing Magento core block for onepage checkout /app/code/local/XYZ/Checkout/Block/Onepage.php

  1. class XYZ_Checkout_Block_Onepage extends Mage_Checkout_Block_Onepage {
  2. public function getSteps() {
  3. $steps = array();
  4. if (!$this->isCustomerLoggedIn()) {
  5. $steps['login'] = $this->getCheckout()->getStepData('login');
  6. }
  7. $stepCodes = array('billing', 'shipping', 'review');
  8. foreach ($stepCodes as $step) {
  9. $steps[$step] = $this->getCheckout()->getStepData($step);
  10. }
  11. return $steps;
  12. }
  13. }

Basically, this class will extend the core class. If you compare getSteps() function to the core file its pretty much identical, we just removed payment and shipping option steps.

STEP 4

Now this is the most intense part, We would have to tweak the default controllers for that page and make sure we assign a shipping method automatically and automatically select free shipping.

Create the following file /app/code/local/XYZ/Checkout/Controller/Onepage.php

  1. require_once 'Mage/Checkout/controllers/OnepageController.php';
  2. class XYZ_Checkout_Controller_Onepage extends Mage_Checkout_OnepageController
  3. {
  4. /**
  5. * Checkout page
  6. */
  7. public function indexAction()
  8. {
  9. if (!Mage::helper('checkout')->canOnepageCheckout()) {
  10. Mage::getSingleton('checkout/session')->addError($this->__('Sorry, Onepage Checkout is disabled.'));
  11. $this->_redirect('checkout/cart');
  12. return;
  13. }
  14. $quote = $this->getOnepage()->getQuote();
  15. if (!$quote->hasItems() || $quote->getHasError()) {
  16. $this->_redirect('checkout/cart');
  17. return;
  18. }
  19. if (!$quote->validateMinimumAmount()) {
  20. $error = Mage::getStoreConfig('sales/minimum_order/error_message');
  21. Mage::getSingleton('checkout/session')->addError($error);
  22. $this->_redirect('checkout/cart');
  23. return;
  24. }
  25. Mage::getSingleton('checkout/session')->setCartWasUpdated(false);
  26. Mage::getSingleton('customer/session')->setBeforeAuthUrl($this->getRequest()->getRequestUri());
  27. $this->getOnepage()->initCheckout();
  28. $this->loadLayout();
  29. $this->_initLayoutMessages('customer/session');
  30. $this->getLayout()->getBlock('head')->setTitle($this->__('Request a Quote'));
  31. $this->renderLayout();
  32. }
  33. public function saveBillingAction()
  34. {
  35. $this->_expireAjax();
  36. if ($this->getRequest()->isPost()) {
  37. $data = $this->getRequest()->getPost('billing', array());
  38. $customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
  39. $result = $this->getOnepage()->saveBilling($data, $customerAddressId);
  40. if (!isset($result['error'])) {
  41. if ($this->getOnepage()->getQuote()->isVirtual()) {
  42. $this->loadLayout('checkout_onepage_review');
  43. $result['goto_section'] = 'review';
  44. $result['update_section'] = array(
  45. 'name' => 'review',
  46. 'html' => $this->getLayout()->getBlock('root')->toHtml()
  47. );
  48. }
  49. elseif (isset($data['use_for_shipping']) && $data['use_for_shipping'] == 1) {
  50. $this->saveShippingMethodAction();
  51. $this->loadLayout('checkout_onepage_review');
  52. $result['goto_section'] = 'review';
  53. $result['update_section'] = array(
  54. 'name' => 'review',
  55. 'html' => $this->_getReviewHtml()
  56. );
  57. $result['allow_sections'] = array('shipping','review');
  58. $result['duplicateBillingInfo'] = 'true';
  59. }
  60. else {
  61. $result['goto_section'] = 'shipping';
  62. }
  63. }
  64. $this->getResponse()->setBody(Zend_Json::encode($result));
  65. }
  66. }
  67. public function saveShippingAction()
  68. {
  69. $this->_expireAjax();
  70. if ($this->getRequest()->isPost()) {
  71. $data = $this->getRequest()->getPost('shipping', array());
  72. $customerAddressId = $this->getRequest()->getPost('shipping_address_id', false);
  73. $result = $this->getOnepage()->saveShipping($data, $customerAddressId);
  74. if (!isset($result['error'])) {
  75. $this->saveShippingMethodAction();
  76. $this->loadLayout('checkout_onepage_review');
  77. $result['goto_section'] = 'review';
  78. $result['update_section'] = array(
  79. 'name' => 'review',
  80. 'html' => $this->_getReviewHtml()
  81. );
  82. }
  83. $this->getResponse()->setBody(Zend_Json::encode($result));
  84. }
  85. }
  86. public function saveShippingMethodAction()
  87. {
  88. $this->_expireAjax();
  89. if ($this->getRequest()->isPost()) {
  90. $this->savePaymentAction();
  91. $data = $this->getRequest()->getPost('shipping_method', 'freeshipping_freeshipping');
  92. $result = $this->getOnepage()->saveShippingMethod($data);
  93. $this->getResponse()->setBody(Zend_Json::encode($result));
  94. }
  95. }
  96. public function savePaymentAction()
  97. {
  98. $this->_expireAjax();
  99. if ($this->getRequest()->isPost()) {
  100. $data = $this->getRequest()->getPost('payment', array('method'=>'checkmo'));
  101. try {
  102. $result = $this->getOnepage()->savePayment($data);
  103. }
  104. catch (Mage_Payment_Exception $e) {
  105. if ($e->getFields()) {
  106. $result['fields'] = $e->getFields();
  107. }
  108. $result['error'] = $e->getMessage();
  109. }
  110. catch (Exception $e) {
  111. $result['error'] = $e->getMessage();
  112. }
  113. $redirectUrl = $this->getOnePage()->getQuote()->getPayment()->getCheckoutRedirectUrl();
  114. if ($redirectUrl) {
  115. $result['redirect'] = $redirectUrl;
  116. }
  117. $this->getResponse()->setBody(Zend_Json::encode($result));
  118. }
  119. }
  120. }

STEP 5

Now that the code is in place we need to rewrite the core calls to custom classes we’ve created. To do so you create the file /app/code/local/XYZ/Checkout/etc/config.xml

  1. xml version="1.0"?>
  2. <config>
  3. <modules>
  4. <XYZ_Checkout>
  5. <version>0.1.0version>
  6. XYZ_Checkout>
  7. modules>
  8. <global>
  9. <controllers>
  10. <Mage_Checkout>
  11. <rewrite>
  12. <onepage>XYZ_Checkout_Controller_Onepageonepage>
  13. rewrite>
  14. Mage_Checkout>
  15. controllers>
  16. <blocks>
  17. <checkout>
  18. <rewrite>
  19. <onepage>XYZ_Checkout_Block_Onepageonepage>
  20. rewrite>
  21. checkout>
  22. blocks>
  23. global>
  24. config>

STEP 6

Now we would have to add a new XML config file for you XYZ module. This config file will tell Magento about your module and here you will enable all the code you wrote. /app/etc/modules/XYZ_All.xml

  1. xml version="1.0"?>
  2. <config>
  3. <modules>
  4. <XYZ_Checkout>
  5. <active>trueactive>
  6. <codePool>localcodePool>
  7. <<b style="color: white; background-color: rgb(136, 0, 0);">dependsb>>
  8. <Mage_Core />
  9. <Mage_Checkout />
  10. <LKC_ModularRouters />
  11. <b style="color: white; background-color: rgb(136, 0, 0);">dependsb>>
  12. XYZ_Checkout>
  13. modules>
  14. config>

STEP 7

Now that the tough part is done, we will just need to do some little tweaks to the AJAX JS file and tweak Magento configuration in the admin tool.
Now locate and open /skin/frontend/default/YOURSKIN/js/opcheckout.js where YOURSKIN is the skin you are using for your site. In most cases its ‘default’ but if you are using a separate skin that you might have created then it will be in a folder you’ve created.

Approximately on the line 721 you should find “var Review = Class.create();” which defines the Review class. Now if you skip to ’save’ function for that class you will find this line of code “var params = Form.serialize(payment.form);” We will have to tweak this because we are skipping payment. This variable wont be defined if we place the order. So I have changed that line to :

  1. //var params = Form.serialize(payment.form);
  2. var params = "color: black; background-color: rgb(255, 153, 153);">payment%5Bmethod%5D=checkmo";
  3. if (this.agreementsForm) {
  4. params += '&'+Form.serialize(this.agreementsForm);
  5. }
  6. params.save = true;

As you see we commented out the serialize call and hardcoding the parameter to reflect the free payment method

STEP 8

Now the last part: tweaking Magento configuration

  1. Go to the admin tool and go to System->Configuration->Shipping Methods and make sure “Free Shipping” is Enabled.
  2. Go to the admin tool and go to System->Configuration->Payment Methods and make sure “Check / Money order” payment option is Enabled.
  3. IMPORTANT! – When copying XML data make sure you don’t have any white-spaces before the first tag, which should be

That is it! Your comments and suggestions are welcome!

courtsy:Blog of Igor Krasnykh

Tuesday

Wholesale Customer Solution with Magento Commerce

The client want to have a shop where regular customers to be able to see products with their retail price, while Wholesale partners to see the prices with ? discount. The extra condition: retail and wholesale prices hasn’t mathematical dependency. So, a product could be $100 for retail and $50 for whole sale and another one could be $60 retail and $50 wholesale. And of course retail users should not be able to see wholesale prices at all.

Basically, I will explain what I did step-by-step, but in order to understand what I mean, you should be familiar with the basics of Magento.

1. Creating two magento websites, stores and views
(Magento meaning of website of course) It’s done from from System->Manage Stores. The result is:
Website | Store | View
————————————————
Retail->Retail->Default
Wholesale->Wholesale->Default

Both sites using the same category/product tree

2. Setting the price scope
in System->Configuration->Catalog->Catalog->Price set drop-down to Website. Now you could enter prices per store/website and they could be totally different.

3. Get some plugins
Get following plugins from Magento Connect and install them from admin: System->Magento Connect->Magento Connect Manager:
Netzarbeiter_LoginCatalog – User need to login in order to see the store (it will be used for Wholesale site)
Netzarbeiter_CustomerActivation – User need to be approved from site admins in order to be able to login to the site. (again it will be used for wholesale site)

Both plugins need to be activated for wholesale only. Because they are activated when they are installed, you need to disable them for Default/Retail website and to leave enabled to Wholesale. You should know that distinction between sites in System->Configuration is done from top left corner of the config window.

First plugin is enabled/disabled from: System > Configuration > Catalog > Login only catalog
Second one: System > Configuration > Customer > Customer Activation.

4. Setting separate url for Wholesale
Now wholesales need to have separate urls, so regular users will access http://domain.com/, while wholesale will access http://domain.com/wholesale/. I found this solution in the Magento Forum: Thread.

So, following the instructions I created directory wholesale/ and copied .htaccess and index.php files from the root directory. Modifications in the index.php are the same as in the Forum:
Mage::run(); become Mage::run(’wholesale’);
and
$mageFilename = ‘app/Mage.php’; become $mageFilename = ‘../app/Mage.php’;

5. Change the wholesale paths from the admin
From System->Configuration (select Wholesale website)->General->Web and change the paths by adding wholesale/ (it’s also mentioned in the forum thread).

6. Adding products to both websites
When adding products, you should mark them visible for both sites. This is done from Product page->Websites tab.

That’s it! Now on http://domain.com/ users will see full catalog, they can login without Admin approval and prices will be retail, while on http://domain.com/wholesale only users registered as wholesale and activated from admin will be able to see catalog with wholesale prices.

courtsy: http://nik.chankov.ne

Friday

Writing a custom module in Magento

Time to move on to some more serious stuff concerning Magento. My last few posts were about understanding a way to use Magento functions. Functions like getModel, getData, getSingleton and so on. Most important it was a way of showing you how to find the available functions ascreend how to extract the data from objects. Not sure if I fully seceded in that but hopefully I helped a bit.

Before I start with the explanation on how to actually write a module let’s take a deeper look at the module philosophy. You can look at the module as your application (that’s the way I look at it) within the main application (Magento). Just for the consistency let’s stick to the module terminology. Each module is comprised of various parts working together for the common goal. If your module is named, let’s say, SomeCoolPaymentServiceModule then the common goal of the module parts is to achieve full integration (inner workings) of Magento system with the SomeCoolPaymentService service.

So what are the parts that make the module? In MVC architecture even the bare bone application is (mostly) written across three separate files. Model, View and Controller. Ideal case is the one where Model manages all of the database connections and queries, then passes the information to controller. Controller then reorders, maps, filters, does some logic on the data and passes it to the View. View is the thing we see. View is the file served to our browsers. In Magento case View is called Block. The same block whose name we see when we turn on System > Current Configuration Scope > Developer > Add Block Names to Hints to Enabled.

Magento is built on top of Zend framework. Since Zend is pure MVC framework so is Magento’s architecture MVC based. Open you Magento installation directory and drill down into the app/code/core/Mage/Catalog/ folder. Notice the word Catalog in this path? Well, the Catalog is one of the modules inside the Magento. And the app/code/core/Mage/ path is the path to all the Magento modules, the building blocks of Magento. Now that we know where to find modules, let’s look at the content of a module. This is the content of the Catalog module:

Block /
controller/
etc /
Helper /
Model /
sql /
Exception.php

As you might notice, there are more than three type of files here. By types I think of Model, View (Block), Controller. Magento’s structure is therefore more divided. We can see the Helper and sql folders as well. Although not every Model contains the same sub folder structure like this one you need to understand that this is somewhat of a blueprint of how Magento modules are built.

So how does one write a custom module? Presumption is that you already know how to create a custom theme. Across this walktrough I will be using paths showing mycustom as the name of my theme folder. Remember this so you don’t get confused. My module will be called ActiveCodeline (wonder why :) ).

Folder /app/code/core/Mage/ is used to store default Magento modules NOT the custom created ones. User (custom) modules are to be stored inside the app/code/local/ folder. The thing with PHP is that it lacks the support for namespaces. However, this did not stop Magento guys and girls for creating them. In the default Magento module folder /app/code/core/Mage/ word (folder) Mage is actually a namespace. Why is this important? Well, as I sad I’ll create a module named ActiveCodeline. Creating a directory app/code/local/ActiveCodeline/ simply means I created a new namespace named ActiveCodeline inside the user module folder. Therefore you should look at the ActiveCodeline folder as the namespace name not the module name for now.

Under the /app/code/local/ActiveCodeline/ folder (or shall I say under the namespace ActiveCodeline) create a folder (module) named Example like

app/code/local/ActiveCodeline/Example/

Now if we were to look at the newly created folder we should look at it the same way we look at the app/code/core/Mage/Catalog/ folder. Example (in our case) and Catalog (in Magento default case) are both modules. Now we can say Example is our custom module. This however is a bit contradictory since we are most likely to say that ActiveCodeline is the name of our module. What’s important is that you know the difference and avoid getting confused by the naming.

Now, let’s go into the /app/code/local/ActiveCodeline/Example/ folder (module) and create two subfolders there, Block and etc. Our folder structure should now look like

/app/code/local/ActiveCodeline/Example/
Block/
etc/

So far, we haven’t done anything that would make Magento see our new module. In order to get our module seen by Magento we need to register it. How do we register our module in Magento? drill down into the newly created

/app/code/local/ActiveCodeline/Example/etc/

folder and create config.xml file.

What do we write into this file? If you open up the app/code/core/Mage/Catalog/etc/config.xml file and have a look inside, you’ll see the stuff it contains. For our bare bone module we need to write the following into the config.xml file:



0.1.0




ActiveCodeline_Example_Block


After we save our config.xml file we can go to Magento admin, go to System > Configuration > Advanced. There you should see the ActiveCodeline_Example on the list among other modules.

Now we need to add some logic to our module. To keep things simple, I’ll make my module simply echo some stuff to the browser. Now lets create second file that we need to make our module work. Open up the app/code/local/ActiveCodeline/Example/Block/ folder and create a View.phtml file.

Place the following content into it:

class ActiveCodeline_Example_Block_View extends Mage_Core_Block_Template {

public function doSomeAction(){
$message = ‘

Hello from ActiveCodeline sample module…

’;
return $message;
}
}

Finaly, we go to our theme folder. As I told you at the beginning of this article, my theme folder is called mycustom. Therefore, inside the app/design/frontend/default/mycustom/template/ folder you need to create the example folder like

app/design/frontend/default/mycustom/template/example/

Now you create a file called view.phtml with the following content

/*
$this is now instance of ActiveCodeline_Example_Block_View
*/
?>

This is the output of the activecodeline example:

echo ‘Class name: ’. get_class($this) .’’;
echo $this->doSomeAction();
?>

Basically these three files conclude the creation of your bare bone module. To test if the module is working, go to Magento admin > CMS > Manage Pages > Home page then write the following somewhere on the page

Sample activecodeline message…


{{block type=”ActiveCodeline_Example/view” template=”example/view.phtml”}}

Notice the type=”ActiveCodeline_Example/view”. If you were to write it like type=”activecodeline_example/view” it wont work. Watch for the capital letters.

Now if you refresh the home page of Magento shop, you would see the result message of the new module.

As I said at the beginning, this is a bare bone module, dummy module or whatever you like to call it. My intention was show you how simple it is to create a basis for module. I haven’t mentioned sql folder here or helpers folder. I leave some things for you to do. Most of the tutorials out there on creating a custom module jump right into the fire going over trough stuff I intentionally left out but they leave the basis unmentioned. Then you end up with the tutorial on how to create something cool but you are missing few steps and you go crazy trying to figure out what’s missing.

If you truly understood this walktrough and my previous articles on Magento then you are ready to connect the dots and start making more serious modules.

courtsy: http://activecodeline.com

Tuesday

How to Import Products into Magento

There’s a little confusion among some on how to import products into a Magento ecommerce store. I spent some time today researching and trying to find the best method on doing this. The reason for my research is because there was no simple documentation anywhere that I could find on how to import products. Magento actually has built a pretty robust import/export mechanism into the ecommerce cms that has a ton of flexibility to do many things. I’m not going to cover all of those. This is just for those of you who simply just want to import products into their Magento cart.

Step 1 – Add a new product manually
add a new product manually to the catalog, assign it to a category, and fill out all fields that will be necessary to your store. The obvious ones are price, description, quantity etc. It’s important that you fill out all fields that you know you are going to need for all the products you import.

Step 2 – Export Your Products
Now we want to export your product to a .csv file so that we can view the fields that are required to import. Go to System >> Import/Export >> Profiles. Now click on Export All Products then Run Profile. Click on the “Run Profile in Popup” button. Once the export is completed, go to your var/export directory on your Magento install and you will find the .csv file there for you to download.

Step 3 – Analyze The .CSV File
Now if you look at your .csv export file you will see the field names that you need to match up. Now just start filling yours in and creating your csv file ready for import. This step is extremely important. Otherwise Magento cannot match what you are trying to import and the importing will fail. At a most basic level, here are the fields that I imported:

  • store
  • attribute_set
  • type
  • sku
  • category_ids
  • status
  • visibility
  • tax_class_id
  • weight
  • price
  • name
  • description

Step 4 – Import Your New .CSV File
Now go to System >> Import/Export >> Profiles. Now click on Import All Products. Change “Type” under Data Format to CSV/Tab Seperated. Now click on Upload File, and browse for your .csv file and click “Save and Continue Editing”. Now go to “Run Profile” and select your file from the dropdown menu. Click the button underneath to run the import. And whalllah. All your products should now be imported.

That was the easiest most simple approach that I could find for Importing Products into a Magento Open Source Ecommerce Store. Like I said I tried this myself and it worked well for me. After that, I went in and manually updated all of my Images and
Quantity numbers. You could even import those if you want to. But for
my purpose I didn’t need to.

courtsy: http://chasesagum.com

Monday

Web addresses to speak all languages

The Internet Corporation for Assigned Names and Numbers, or Icann, has set the ball rolling for web addresses in scripts other than Latin. This will allow uniform resource locators, as web addresses are called in virtual parlance, in languages other than English, including Hindi, Tamil or Bhojpuri.

About half of the world's 1.6 billion Internet users use languages based on scripts other than Latin and may cheer the move. India, which has 50 million Internet users, speaks hundreds of languages.

Icann, the non-profit group that oversees domain names, is meeting representatives from all over the world this week in Seoul to decide on this change, which will be one of the biggest in the 40 years of Internet. If it is cleared, Icann will begin accepting applications for non-Latin domain names and the first entries into the system are expected in the middle of next year.

Icann is also to decide whether it can give users freedom on global top-level domain names.

"If this happens, it will definitely increase the number of internet users. Why should users type in English if they could time in Tamil or Hindi," says Kiruba Shankar, founder chief executive officer of Business Blogging.

At present, web addresses are limited to 21 suffixes, such as, .com (80 per cent), .net and .info, and country-specific ones like .in for India. With this change, companies and individuals can have unlimited choices such as .indian, .delhi, .paris, .gabbarsingh or .whateveryouwant.

Corporate houses like the Tatas, Birlas or Reliance [ Get Quote ] could apply for .tata, .birla or .reliance and could, in turn, give each employee a .tata, .birla or .reliance email identity.

Like all good things, these will come at a price: Rs 40 lakh (Rs 4 million) to Rs 2 crore (Rs 20 million).

Jasjit Sawhney, managing director and chief executive officer of Net4India, an Internet service provider that offers domain registration services, says the move to open up web addresses is good "but will take time to trickle down in India because of technicalities".

Currently, names on the Internet can be typed in local scripts. For instance, you can type dukaan (shop) in Devnagari, the script for Hindi, but not .com.

Icann is in talks with information technology departments of countries to get the exact meaning of .com in local languages, say, Hindi or Tamil. "What do you call .com in Hindi? One has to decide on such issues," says Sawhney.

Naresh Ajwani, president-government affairs, Sify Technologies, who is attending the Icann meeting in Seoul, points out that the Department of Information Technology in India already has fonts for 22 local languages. "This, and the fact that GLTDs may be opened up to more domains, will witness a sea change in the way the Internet is structured," says Ajwani.

Leslie D Monte in New Delhi
Source:

ML self-service pipeline that abstracts Kubernetes complexity

  To successfully bridge the gap between machine learning engineering and cluster operations, you need to build a self-service pipeline that...