Error Source model “customer_entity/address_attribute_source_country” not found for attribute “country_id”

If you happen to encounter this error in magento 1.6 there is a chance that was caused by an upgrade from a previous version of magento.  Check eav_atribute table and change rows containing

customer_entity/address_attribute_source_country
customer_entity/address_attribute_source_region

to

customer/entity_address_attribute_source_country
customer/entity_address_attribute_source_region

Also if you check your error log for this error you might notice the cause:

Varien_Autoload::include(Mage/Customer/Entity/Model/Address/Attribute/Source/Country.php) [<a href='function.Varien-Autoload-include'>function.Varien-Autoload-include</a>]: failed to open stream: No such file or directory …

Posted in Errors | 4 Comments

How to get the newest products of magento current category

If you ever need listing the newest products of magento current category (or even of a category given by it’s Id, see the code comments)

<?php
$totalPerPage = ($this->show_total) ? $this->show_total : 9;
$visibility = array(
                      Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
                      Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
                  );
 
// If you want to use a specific category load it by using this
// $cur_category=Mage::getModel('catalog/category')->load($category_id);
// Get current category
$cur_category = Mage::registry('current_category');
$storeId = Mage::app()->getStore()->getId();
$_productCollection = 
Mage::getResourceModel('catalog/product_collection')->setStoreId($storeId)
                              ->addAttributeToSelect('*')
			      ->addStoreFilter($storeId)
                              ->addCategoryFilter($cur_category)
                              ->addAttributeToFilter('visibility', $visibility)
                              ->setOrder('created_at', 'desc')
			      ->setPageSize($totalPerPage);
 
?>
Posted in Categories, Products | Tagged , , | 2 Comments

Get magento page current url

echo Mage::help('core/url')->getCurrentUrl();
Posted in Uncategorized | Tagged , | Leave a comment

Magento new products

New products is one of the useful feature required for a magento site. Below is a short example how to have this. You can call this in a cms page.

$totalPerPage = ($this->show_total) ? $this->show_total : 9;
$visibility = array(
                      Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
                      Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
                  );
 
$storeId = Mage::app()->getStore()->getId();
 
$_productCollection = 
Mage::getResourceModel('catalog/product_collection')->setStoreId($storeId)
                              ->addAttributeToSelect('*')
			      ->addStoreFilter($storeId)
                              ->addAttributeToFilter('visibility', $visibility)
                              ->setOrder('created_at', 'desc')
			      ->setPageSize($totalPerPage);
Posted in Products | Tagged , | Leave a comment

Magento query filter by category and attribute

We know how to show up the products of a category in a cms page. But what if we wanna filter them by an attribute? Here is an example where $category_id is a given category ID, $currentPage the number of page you want to fetch the results from and $limit is for the number of results per page:

$visibility = array(
                      Mage_Catalog_Model_Product_Visibility::VISIBILITY_BOTH,
                      Mage_Catalog_Model_Product_Visibility::VISIBILITY_IN_CATALOG
                  );
$cur_category=Mage::getModel('catalog/category')->load($category_id);
$_productCollection= Mage::getModel('catalog/product')->setStoreId(Mage::app()->getStore()->getId())->getCollection()
                                                                        ->addAttributeToSelect('*')
                                                                        ->addAttributeToFilter('visibility', $visibility);
$_productCollection->addAttributeToFilter('color', $this->getRequest()->getParam('color'));
 $_productCollection->addCategoryFilter($cur_category);
 $_productCollection->setPage($currentPage,$limit);
Posted in Categories, Queries | Tagged , , , , | 3 Comments

Add featured category products to cms home page

If you have a category with products( like the featured products) you can  include them in a cms page calling the template block  the following way:

{{block type=”catalog/product_list” template=”catalog/product/list.phtml” category_id=”5″ column_count=”4″ }}

You have to change category_id 5 for your categeory ID.  Blocks are very useful for the home page and you can edit list.phtml to get rid of paging if itdoes not suit you.  With column_count you can set the number of columns used for listing. For a working example you can go check out http://www.mage-contacts.com/magento-1.4.2-sample/category-products-cms-page

 

 

 

 

Posted in Categories, Cms | Tagged , , | Leave a comment

Magento get category subcategories

One thing we will meet for sure in magento is the category. One of the task we will need to do is the listing of child categories, the subcategories. In the following example will be listed the subcategories of a category given by it’s ID.

    <ol>
    <?php
    $parent_category = Mage::getModel('catalog/category')->load(15);
    $subcategories = $parent_category->getChildrenCategories();
    foreach ($subcategories as $child)
    {
     echo "<li><a href=\"".$child->getUrl()."\">" . $child->getName();
     echo   "</a>(".$child->getProductCount().")";
     echo "</li>";
    }
 
    ?>
    </ol>

You can check out the following working example for category subcategories.

 

Posted in Categories | Tagged , , , | Leave a comment

eBay Agrees to Acquire Magento

Some interesting news regarding Magento received two weeks ago by Magento newsletter.

The past several years have been an amazing journey for Magento, as we’ve grown from a new open source platform into an eCommerce leader. Along the way, we’ve built not only a platform, but a company and a worldwide community. Together, we’ve identified opportunities, taken risks, innovated, struggled, succeeded, and changed the face of eCommerce. Today marks a milestone on this journey as we announce the most exciting news in our company’s history.

Magento has reached an agreement to be acquired by eBay Inc. We believe this move will open incredible opportunities for the entire Magento ecosystem.

The Big Picture

Why is this acquisition so exciting for all of us? eBay is evolving to become a strategic commerce partner focused on delivering new ways for merchants of all sizes to drive innovation. As a centerpiece of this strategy, they are building a global, open commerce platform that leverages the worldwide developer community. And Magento will be at the core of this new, open commerce platform, called “X.Commerce.”

Magento & eBay

As many of you know, Magento has had a relationship with eBay for some time. In March 2010, eBay became our first outside investor. Over the past year, eBay has gotten to know our platform, our culture, and our community. They have experienced the passion of the Magento ecosystem, and they are eager to harness the power of this ecosystem to create the next generation of eCommerce innovation.

Magento Forward: The Details

How will this acquisition impact our organization, customers and partners? It’s too soon to know all the details, but there are a few things we know. Magento will continue to operate out of LA, with Yoav Kutner and me as its leaders following the closing. We’ll continue building our team and our enhancing our product line, including the Magento Community, Enterprise, and Mobile Editions, as well as Magento Go and the Magento Go Platform. And we’ll continue strengthening our training, education, packaged consulting services and support efforts around the world.

Through it all, we’ll be collaborating with our colleagues at eBay on developing the X.Commerce platform and defining the next generation of eCommerce innovation.

Yoav and I recorded a short video message for the community – you can find it on our blog, along with FAQs about the pending acquisition.

Creating The Future Together

To all the members the Magento family: we thank you for all the passion, expertise and hard work that you’ve invested in Magento. Thanks to you, Magento finds itself exactly where we’ve always aimed to be: at the core of eCommerce. We are thrilled to become part of a larger organization that recognizes – as we always have – that the future of eCommerce is global, innovative and open. We look forward to creating that future with all of you.

Warm Regards,

Roy Rubin
Co-Founder and CEO, Magento
roy@magento.com

Posted in News | Tagged , | Leave a comment

Magento disable block cache

As  an example if you want to disable caching for the footer block you have to make a copy of app/code/coreMage/Page/Block/Html in app/code/local/Mage/Page/Block/Html. If you have copied the file open it from local and in the _construct function comment out

$this->addData(array(
‘cache_lifetime’=> false,
‘cache_tags’    => array(Mage_Core_Model_Store::CACHE_TAG, Mage_Cms_Model_Block::CACHE_TAG)
));

 

You can read further on it at http://www.magentocommerce.com/wiki/5_-_modules_and_development/block_cache_and_html_ouput

 

Posted in Cache | Tagged , , | 5 Comments