Magento Engineer
social
Journal

Programming Blogs to Improve Your Coding Skills!

The industry's top wizards and other experts share their advice and research findings.

Ad comes here
Ad comes here

How to run custom MySql query in Magento2 and fetch data?

<?php

//Connection with magento2 database

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$resource = $objectManager->get('Magento\Framework\App\ResourceConnection');
$connection = $resource->getConnection('core_read');

//Now execute your mysql query

$fetch="SELECT * FROM catalog_product_entity";

$result = $connection->fetchAll($fetch);

?>

Ad comes here

How do you Encrypt and Decrypt a PHP String?

/**Function to encrypt or decrypt the given value**/
/**Create a function for Encryption url**/

function encrypt_decrypt($string){   
    $string_length=strlen($string);
    $encrypted_string="";     
    for ($position = 0;$position<$string_length;$position++){         
        $key = (($string_length+$position)+1);
        $key = (255+$key) % 255;
        $get_char_to_be_encrypted = SUBSTR($string, $position, 1);
        $ascii_char = ORD($get_char_to_be_encrypted);
        $xored_char = $ascii_char ^ $key;  //xor operation
        $encrypted_char = CHR($xored_char);
        $encrypted_string .= $encrypted_char;
    }
    /***Return the encrypted/decrypted string***/
    return $encrypted_string;
 }

/*** While passing the unique value to a link- Do the following steps ***/
$pid=88;//Let's 88 is the actual id
/***For more security multiply some value-You can set the multiplication value in config file*/
$passstring=$pid*12345;
$encrypted_string=encrypt_decrypt($passstring);
$param=urlencode($encrypted_string);

/*** Add this url to your anchor link***/
$url='your_target_path.php?id='.$param;
 
/*** While fetching the params in the target file- Do the following steps ***/
$getid=$_GET['id'];
$passstring=urldecode(stripslashes($getid));
$decrypted_string= encrypt_decrypt($passstring);
/***Divide the decrypted value with the same value we used for the multiplication***/
$your_actual_id= $decrypted_string/12345;

/*** Now fire your MySql query by this ID***/

Ad comes here

How to use Stripe payment gateway with Shopify ?

Here are the instructions to use Stripe as your payment gateway for your Shopify store:


    A- Login to your Shopify store.
    B- Click Settings.
    C- Click Payments.
    D- In the Accept Credit Cards section select Shopify Payments.
    E- Deactivate Shopify Payments.(When you deactivate shopify payment after then Stripe payment gateway will show)
    F- Now select stripe payment .
    G- Click Activate.
    H- Click Complete account setup.
    I- Enter the various details and submit.

Upon taking the steps above you’ll be able to accept credit card payments and, although Shopify Payments use Stripe, you won’t be able to view your Shopify Payments in the Stripe Dashboard.

Ad comes here
Error's and solution's
Update Cookies Preferences