$_product = \Magento\Framework\App\ObjectManager::getInstance() ->get(\Magento\Framework\Registry::class)->registry('product');
Wednesday, February 15, 2023
Sunday, May 24, 2020
Wordpress annotation plugin
http://php-you.blogspot.com/search/label/pdf%20annotation%20wordpress
With the plugin
Plugin for annotation
Viewer page template for viewing all pages of pdf document with scroll
Manage annotation page for edit the text used for annotation and for deleting the annotation
With the plugin
Plugin for annotation
Viewer page template for viewing all pages of pdf document with scroll
Manage annotation page for edit the text used for annotation and for deleting the annotation
Thursday, January 10, 2013
Magento Tips: 404 Not Found error after Magento module installation
Sometimes after Magento modules installation, you can see 404 page not found error in your Magento administration zone.

To fix this error, try to re-save permission role of your administrator user, using Magento admin zone -> System -> Permissions -> ‘Roles’ page -> Administrators -> Click on ‘Save Role’ button.
Don’t forget to clear Magento cache after this.
Wednesday, September 5, 2012
Sql query for getting Category id and name from magento database table
SELECT `entity_id`,`value` FROM `catalog_category_entity_varchar` WHERE `attribute_id` = 3 and
`entity_id` IN(SELECT distinct(`entity_id`) FROM `catalog_category_entity` WHERE `path` LIKE
'%1/xxx%')
For more than one store
Take the root category id of store from admin and put it in place of 1/xxx as 1/categoryid
Also you have to search in table `catalog_category_entity_varchar' for attribute_id by giving the name of you store root category in place of value field.
SELECT `attribute_id` FROM `catalog_category_entity_varchar` WHERE `value` = "your category name";
Monday, April 23, 2012
How to Create different store view with different sub-domain in magento
How to create store view
1. Go to admin then select tab System->manage stores
2.Click create store view and complete the form and save store view
then you will be able to see in the list.
How to Change the Base URL for each Store view
1.. Go to admin then select tab System->configuration
2.On the left side of the page General under that select web but before that you have to change the Current Configuration Scope to your store view name
3. Edit the base url to you subdomain(eg: http://en.yourdomain.com)
4.click save config.
How to change .htaccess for redirecting to store view if you call the subdomain
1.Your .htaccess file is at the root folder of magento.
2.Search for "RewriteEngine on" word in .htaccess file and write the code below it
RewriteCond %{HTTP_HOST} ^en.yourdomain.com
RewriteRule ^ - [E=MAGE_RUN_CODE:english]
RewriteCond %{HTTP_HOST} ^fr. yourdomain .com
RewriteRule ^ - [E=MAGE_RUN_CODE:french]
then save the .htaccess file and try to clear all cache and browsing history from your browser as well as from magento
1. Go to admin then select tab System->manage stores
2.Click create store view and complete the form and save store view
then you will be able to see in the list.
How to Change the Base URL for each Store view
1.. Go to admin then select tab System->configuration
2.On the left side of the page General under that select web but before that you have to change the Current Configuration Scope to your store view name
3. Edit the base url to you subdomain(eg: http://en.yourdomain.com)
4.click save config.
How to change .htaccess for redirecting to store view if you call the subdomain
1.Your .htaccess file is at the root folder of magento.
2.Search for "RewriteEngine on" word in .htaccess file and write the code below it
RewriteCond %{HTTP_HOST} ^en.yourdomain.com
RewriteRule ^ - [E=MAGE_RUN_CODE:english]
RewriteCond %{HTTP_HOST} ^fr. yourdomain .com
RewriteRule ^ - [E=MAGE_RUN_CODE:french]
then save the .htaccess file and try to clear all cache and browsing history from your browser as well as from magento
Tuesday, February 14, 2012
magento the shipment email is not sent
Solution Works For Me
Go to -> Mage_Sales_Model_Order_Shipment and copy the file Api.php
Make a path like this in local folder app/code/local/Mage/Sales/Model/Order/Shipment
Edit Api.php
In function Create comment the sendEmail function call
In function Create comment the sendEmail function call
try {
$transactionSave = Mage::getModel(’core/resource_transaction’)
->addObject($shipment)
->addObject($shipment->getOrder())
->save();
/*$shipment->sendEmail($email, ($includeComment ? $comment : ‘’));*/
} catch (Mage_Core_Exception $e) {
$this->_fault(’data_invalid’, $e->getMessage());
}
In function addTrack add function call sendEmail
$transactionSave = Mage::getModel(’core/resource_transaction’)
->addObject($shipment)
->addObject($shipment->getOrder())
->save();
/*$shipment->sendEmail($email, ($includeComment ? $comment : ‘’));*/
} catch (Mage_Core_Exception $e) {
$this->_fault(’data_invalid’, $e->getMessage());
}
In function addTrack add function call sendEmail
try {
$shipment->save();
$track->save();
$email=true;
$shipment->sendEmail($email,’’);
} catch (Mage_Core_Exception $e) {
$this->_fault(’data_invalid’, $e->getMessage());
}
$shipment->save();
$track->save();
$email=true;
$shipment->sendEmail($email,’’);
} catch (Mage_Core_Exception $e) {
$this->_fault(’data_invalid’, $e->getMessage());
}
Now you Shipment Email will be send as usual email with tracking number
Friday, February 3, 2012
PHP Mailing by attaching a file
<?php
$to = "some mail@mymail.com";
$subject = "New Product Details";
$message = "New product be find in attachment.";
# Open a file
$file = fopen( "product.txt", "r" );
if( $file == false )
{
echo "Error in opening file";
exit();
}
# Read the file into a variable
$size = filesize("product.txt");
$content = fread( $file, $size);
# encode the data for safe transit
# and insert \r\n after every 76 chars.
$encoded_content = chunk_split( base64_encode($content));
# Get a random 32 bit number using time() as seed.
$num = md5( time() );
# Define the main headers.
$header = "From:admin@magento-works.com\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; ";
$header .= "boundary=$num\r\n";
$header .= "--$num\r\n";
# Define the message section
$header .= "Content-Type: text/plain\r\n";
$header .= "Content-Transfer-Encoding:8bit\r\n\n";
$header .= "$message\r\n";
$header .= "--$num\r\n";
# Define the attachment section
$header .= "Content-Type: multipart/mixed; ";
$header .= "name=\"test.txt\"\r\n";
$header .= "Content-Transfer-Encoding:base64\r\n";
$header .= "Content-Disposition:attachment; ";
$header .= "filename=\"product.txt\"\r\n\n";
$header .= "$encoded_content\r\n";
$header .= "--$num--";
# Send email now
$retval = mail ( $to, $subject, "", $header );
if( $retval == true )
{
echo "Message sent successfully...";
}
else
{
echo "Message could not be sent...";
}
?>
$to = "some mail@mymail.com";
$subject = "New Product Details";
$message = "New product be find in attachment.";
# Open a file
$file = fopen( "product.txt", "r" );
if( $file == false )
{
echo "Error in opening file";
exit();
}
# Read the file into a variable
$size = filesize("product.txt");
$content = fread( $file, $size);
# encode the data for safe transit
# and insert \r\n after every 76 chars.
$encoded_content = chunk_split( base64_encode($content));
# Get a random 32 bit number using time() as seed.
$num = md5( time() );
# Define the main headers.
$header = "From:admin@magento-works.com\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: multipart/mixed; ";
$header .= "boundary=$num\r\n";
$header .= "--$num\r\n";
# Define the message section
$header .= "Content-Type: text/plain\r\n";
$header .= "Content-Transfer-Encoding:8bit\r\n\n";
$header .= "$message\r\n";
$header .= "--$num\r\n";
# Define the attachment section
$header .= "Content-Type: multipart/mixed; ";
$header .= "name=\"test.txt\"\r\n";
$header .= "Content-Transfer-Encoding:base64\r\n";
$header .= "Content-Disposition:attachment; ";
$header .= "filename=\"product.txt\"\r\n\n";
$header .= "$encoded_content\r\n";
$header .= "--$num--";
# Send email now
$retval = mail ( $to, $subject, "", $header );
if( $retval == true )
{
echo "Message sent successfully...";
}
else
{
echo "Message could not be sent...";
}
?>
Monday, January 30, 2012
Upgrade Magento from 1.5.1 to 1.6.2 with magento connect in windows
I think upgrading using magento connect is not so risk
Step:1
Go to admin pannel and login.
step:2
Go to System ->Magento Connect->Magento Connect Manager
step:3
Login with your admin user and password and copy&paste this link
Step:1
Go to admin pannel and login.
step:2
Go to System ->Magento Connect->Magento Connect Manager
step:3
Login with your admin user and password and copy&paste this link
"http://connect20.magentocommerce.com/community/Mage_All_Latest"
in the paste extenstion key install and press 'install' button.Then you get a list of all modules with latest version.
Step:4
Before clicking commit Change you have to do this
Before clicking commit Change you have to do this
To allow MCM to overwrite existing files you need to edit this file:
downloader\lib\Mage\Connect\Validator.php
and remove this part:
if (file_exists($dest)) {
$this->addError("'{$file}' already exists");
return false;
}
$this->addError("'{$file}' already exists");
return false;
}
which is right at the bottom of the file
If installation fails you will need to re-edit the file as it will be replaced by the version just downloaded
If you install without changing you will get error "files already exists" and it will not install.
Step:5
After successfull installation when you open the front end you get a error
After successfull installation when you open the front end you get a error
Service Temporarily Unavailable
The server is temporarily unable to service your request due to maintenance downtimeor capacity problems. Please try again later.
error To clear the error check if there is a file called maintenance.flag in your magento root. If so Delete it
and also clear the cache.
Step:6
Not over there is still error
NOW YOUR PROBLEM IS SOLVED YOU HAVE UPDATED MAGENTO 1.5.1.0 TO MAGENTO 1.6.2.0
Step:6
Not over there is still error
| Stops at "1025 Error on rename of catalog_category_flat_store_1 |
If you encounter the error
to solve this error by running the queries in the databaseError in file: "/xxx/app/code/core/Mage/Catalog/sql/catalog_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php" - SQLSTATE[HY000]: General error: 1025 Error on rename of './catalog_category_flat_store_1' to './#sql2-6221-31dae3' (errno: 152)”
ALTER TABLE catalog_category_entity ENGINE=INNODB; ALTER TABLE core_store ENGINE=INNODB; ALTER TABLE catalog_category_entity ENGINE=INNODB; ALTER TABLE core_store ENGINE=INNODB;
NOW YOUR PROBLEM IS SOLVED YOU HAVE UPDATED MAGENTO 1.5.1.0 TO MAGENTO 1.6.2.0
Tuesday, January 24, 2012
.htaccess Rewrite Rule for converting /names.php?name=boy&id=23&page=1 to names/boy/23/1
Pass the Query string through url not by traditional method but by using mod rule in .htaccess file
/names.php?name=boy&id=23&page=1 to names/boy/23/1
RewriteEngine on
RewriteCond %{QUERY_STRING} ^name=(.+)&id=(.+)&page=(.+)$ [NC]
RewriteRule ^names\.php$ /names/%1/%2/%3? [R=301,NE,NC,L]
If you want to convert all the pages to
http://localhost/ram1/2/3
http://localhost/ram1.php?id=2&page=3
http://localhost/ram1/1
http://localhost/ram1.phppage=1
use the rewrite rule below to automatically converts to corresponding Query String
RewriteEngine on
RewriteRule ^(.+)/([0-9]+)/([0-9]+)/?$ $1.php?id=$2&page=$3 [L]
RewriteRule ^(.+)/([0-9]+)/?$ $1.php?page=$2 [L]
/names.php?name=boy&id=23&page=1 to names/boy/23/1
RewriteEngine on
RewriteCond %{QUERY_STRING} ^name=(.+)&id=(.+)&page=(.+)$ [NC]
RewriteRule ^names\.php$ /names/%1/%2/%3? [R=301,NE,NC,L]
If you want to convert all the pages to
http://localhost/ram1/2/3
http://localhost/ram1.php?id=2&page=3
http://localhost/ram1/1
http://localhost/ram1.phppage=1
use the rewrite rule below to automatically converts to corresponding Query String
RewriteEngine on
RewriteRule ^(.+)/([0-9]+)/([0-9]+)/?$ $1.php?id=$2&page=$3 [L]
RewriteRule ^(.+)/([0-9]+)/?$ $1.php?page=$2 [L]
Friday, December 30, 2011
Simple function overloading in php
<?php
class hello
{
var $id;
var $edi;
function hello()
{
$this->id="1234";
$this->edi="abc";
}
public function display()
{
echo $this->id;
echo $this->edi;
}
}
class hello1 extends hello
{
function display($a,$b)
{
hello::display();
echo "</br>";
echo $this->id=$a;
echo $this->edi=$b;
}
}
$obj=new hello;
$obj1=new hello1;
$obj1->display("a","b");
?>
output
1234abc
ab
class hello
{
var $id;
var $edi;
function hello()
{
$this->id="1234";
$this->edi="abc";
}
public function display()
{
echo $this->id;
echo $this->edi;
}
}
class hello1 extends hello
{
function display($a,$b)
{
hello::display();
echo "</br>";
echo $this->id=$a;
echo $this->edi=$b;
}
}
$obj=new hello;
$obj1=new hello1;
$obj1->display("a","b");
?>
output
1234abc
ab
Friday, December 9, 2011
Php Code to explore every directory and files in a path
<?php
calldir("lightbox");
function calldir($path)
{
if ($handle = opendir($path)) {
echo "Directory handle: $handle</br>";
echo "Files:</br>";
$i=0;
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
echo "$file</br>";
$data=explode(".",$file);
if($data[1]==''&& $file!="." && $file!="..")
{
if (is_string($data[0]))
{
//echo $file.'</br>';
$url=$path.'/'.$file;
calldir($url);
}
}
}
closedir($handle);
}
}
?>
calldir("lightbox");
function calldir($path)
{
if ($handle = opendir($path)) {
echo "Directory handle: $handle</br>";
echo "Files:</br>";
$i=0;
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
echo "$file</br>";
$data=explode(".",$file);
if($data[1]==''&& $file!="." && $file!="..")
{
if (is_string($data[0]))
{
//echo $file.'</br>';
$url=$path.'/'.$file;
calldir($url);
}
}
}
closedir($handle);
}
}
?>
Friday, November 25, 2011
Magento 1.5.1.0 attribute import error while using .csv file,image does not exist error (solved)
Attribute error for example :- size error:1,2,3,4.... check wheather the attribute is present in the attribute value and attribute set.If you find all ok and still have the error you can goto Catalog->manage attribute->size then you select the manage option and file the value with error and copy the value fron the text box from their and paste it on the .csv file this should be repeated for all value that you find error.
Image does not exist
Please not that if you find this error your product will not be imported so better to create a profile of your own and map it to corresponding field.
If you have the image in import folder media/import and your csv contain the right name still have the error you can put a back slash infront of the image name( /name.jpg ) .
Concatenate function will help you to add (/) to your image name using excel.
=CONCATENATE("/",N:N)
Image does not exist
Please not that if you find this error your product will not be imported so better to create a profile of your own and map it to corresponding field.
If you have the image in import folder media/import and your csv contain the right name still have the error you can put a back slash infront of the image name( /name.jpg ) .
Concatenate function will help you to add (/) to your image name using excel.
=CONCATENATE("/",N:N)
Magento 1.5.1.0 -configurable product import
Magento has added the feature for importing configurable product with association .To do importing go to admin and select System->import/export->import ,this import is different from profile import.
Magento 1.5.1.0 unable to import image
The new import you will not be able to upload image for this you can use the old profile import for this goto System->import/export->DataFlow-profiles
Magento 1.5.1.0 update problem
During updating with magento you could see that you stock becomes out of stock for that you can insert a field is_instock with value 1
Magento 1.5.1.0 unable to import image
The new import you will not be able to upload image for this you can use the old profile import for this goto System->import/export->DataFlow-profiles
Magento 1.5.1.0 update problem
During updating with magento you could see that you stock becomes out of stock for that you can insert a field is_instock with value 1
Thursday, August 11, 2011
How to create a product in magento from admin panel ?
Log into admin panel in localhost with this url ( http://localhost/magento/index.php/admin ) in default
Then go to Catalog tab in admin panel and take manage products.then click on add product button.Then you are asked to select an attribute set (default) and type of product you want to create choose simple product and click continue.
Then a new page appears
General
enter product name in name textfield,description,short description,sku,enable,catalog,search
Price
enter price
select taxable goods
Image
browse image and click upload and click all the radio button
Then go to Catalog tab in admin panel and take manage products.then click on add product button.Then you are asked to select an attribute set (default) and type of product you want to create choose simple product and click continue.
Then a new page appears
General
enter product name in name textfield,description,short description,sku,enable,catalog,search
Price
enter price
select taxable goods
Image
browse image and click upload and click all the radio button
How to Create Excel csv file for product importing
First you create a product from the admin panel of magento.
Then in the admin panel go to System and select Import/Export profile
and select profiles then a window appears with options for exporting and importing.
Then click on Export All products and then select export method as CSV file from the option and click on save and continue.
Then on the left tab select RUN PROFILE and click on run profile button the you product will be exported .
you can get it from magento root folder then in the path = magento/var/export
then open the export.csv and you can see field name in the first row and in the second row product.
Just select the row and drag down to multiply and change product name ,description especially sku ,sku should be unique.then save and go to admin ->system->import/export profile->profile->import all products
Then change the xls file to csv file in the option tab in current window.
click on save and continue.
Upload file and click save and continue
Then RUN PROFILE then select your file from option and click on run profile button.
Then your product will be imported you can see the product in catalog->manage product in admin panel
Then in the admin panel go to System and select Import/Export profile
and select profiles then a window appears with options for exporting and importing.
Then click on Export All products and then select export method as CSV file from the option and click on save and continue.
Then on the left tab select RUN PROFILE and click on run profile button the you product will be exported .
you can get it from magento root folder then in the path = magento/var/export
then open the export.csv and you can see field name in the first row and in the second row product.
Just select the row and drag down to multiply and change product name ,description especially sku ,sku should be unique.then save and go to admin ->system->import/export profile->profile->import all products
Then change the xls file to csv file in the option tab in current window.
click on save and continue.
Upload file and click save and continue
Then RUN PROFILE then select your file from option and click on run profile button.
Then your product will be imported you can see the product in catalog->manage product in admin panel
Subscribe to:
Posts (Atom)


