FaceBook: How to clear Facebook Share’s Cache?
Facebook share is good, simple, lets us share almost everything on web in seconds. But Facebook caches already shared urls/pages for better performance. This causes issues at time when we update the title, picture being shared or the description of the page because Facebook still shows the older version of the page.
For modifying which image, title and description FB chooses, read this
I will discuss three simple ways to force facebook to go and fetch the latest stuff from the page being shared.
CakePHP: Merge Add and Edit actions into a single HTML form
This CakePHP example will show you how to merge your Add and Edit forms into a Single Form action.
This may be of benefit if you have a form with complex controller logic that you don’t want to duplicate.
Incrementing a field in CakePHP like Hits & Votes
Let’s say you have an application, where users can place votes for their favorite products and you’d like to increment the current number of votes by one or count number of hits(Number of page views)
It’s very easy by using updateAll:
You may want to restrict Product model by using unbindModel, containable, etc.
Also, you don’t have to pass in the second argument to updateAll, if you wish to update all records in your table.
Magento Invalid Method Mage Catalog Model Product IsDuplicable
New version theme is not working in old version.
After upgrading magento or when I design theme in magento 18.104.22.168 and use that theme in magento 1.4.2 that time my product page shows error like
Invalid method Mage_Catalog_Model_Product::isDuplicable
I find the solutin and its work for me.
Copy your product.php file from this path: app\code\core\Mage\Catalog\Model\product.php and replace in your maegnto folder.
Magento AddAttributeToFilter SQL Conditionals
If you want to customize query or product collection data you can easily to do that with addAttributeToFilter funcation in magento. In short you can easily customize product collection select query based on your requirement in magento development.
<?php $collection = Mage::getModel('catalog/product')->getCollection(); ?>
If you want get all fields then use below condition select (more…)
Magento: ERROR: unable to unpack
The following error (or similar) is shown in Magento Connect Manager on installation/upgrade:
ERROR: unable to unpack downloader/pearlib/download/AW_Blog-1.0.21.tgz
There is a bug in current stable PEAR/Archive_Tar implementation resulting in impossibility to unpack archives made by certain software versions.
How to retrieve data from another model into view templates or anyplace
To retrieve data from another model into view templates or anyplace
$this->Model2 = ClassRegistry::init('Model2 ');
Or if the models are associated, just daisy chain the finds:
$results = $this->Model1->Model2->find();
PHP: How to create unique short string IDs with PHP & MySQL
IDs are often numbers. Unfortunately there are only 10 digits to work with, so if you have a lot of records, IDs tend to get very lengthy. For computers that’s OK. But human beings like their IDs as short as possible. So how can we make IDs shorter? Well, we could borrow characters from the alphabet as have them pose as additional numbers…. Alphabet to the rescue!
I created this function a long time ago. Time to be nice and share.
More is Less – the ‘math’
The alphabet has 26 characters. That’s a lot more than 10 digits. If we also distinguish upper- and lowercase, and add digits to the bunch or the heck of it, we already have (26 x 2 + 10) 62 options we can use per position in the ID.
Now of course we can also add additional funny characters to ‘the bunch’ like – / * & # but those may cause problems in URLs and that’s our target audience for now.
OK so because there are roughly 6x more characters we will use per position, IDs will get muchshorter. We can just fit a lot more data in each position.
This is basically what url shortening services do like tinyurl, is.gd, or bit.ly. But similar IDs can also be found at youtube: http://www.youtube.com/watch?v=yzNjIBEdyww
Magento Compiler feature should be disabled on any changes in loaded Magento classes, in other words, you need to disable Magento Compilation every time before installing new extension or initiating upgrade/downgrade/installation or removal of any Magento module.
To disable Magento Compiler you can use one of the following methods:
- navigate to System > Tools > Compilation page and click on Disable button:
How do I disable Magento Compiler?
Fixing Magento Category Order Problems
Recently, one of our clients could not get their product categories to appear in the order set in the Magento Catalog > Manage Categories screen. No matter how they dragged and dropped the categories, the ones near the top would not display as intended on the front end.
How Magento Orders Categories
Categories are displayed in navigation menus based on a field titled “position” in thecatalog_category_entity data table. By default, the order is displayed in ascending order. There are other ways of adding code to display categories alphabetically, but by default, the order shown is determined by the position value.
So, why would changing the order under Manage Categories not work?
What I Observed
When working in the Manage Categories menu, the client and I were focused on manipulating the top 2-3 categories, as those were the ones most important to him at the time. We could change their order, but even after re-indexing the Flat Catalog, the front end would still not display the correct order.