String to int in php return 0

there are cases when

int(’11’) or intval(’22’)

will return a 0 and not  the number himself and that is because there is spaces in the number

the solution is to use regular expression

$int = (int) preg_replace(‘/\D/’, ”, $strNonNumeric);
OR

$int = (int) preg_replace(‘/[^0-9]/’, ”, $strNonNumeric);

 

Advertisements
Posted in כללי | Leave a comment

how to get product by sku or id in magento 2

$objectManager =  \Magento\Framework\App\ObjectManager::getInstance();        

 

                $appState = $objectManager->get(‘\Magento\Framework\App\State’);

                $appState->setAreaCode(‘frontend’);

 

                $productRepository = $objectManager->get(‘\Magento\Catalog\Model\ProductRepository’);

 

                $id = 1; // YOUR PRODUCT ID;

                $sku = ’24-MB01′; // YOUR PRODUCT SKU

 

                // get product by product id

                $product = $productRepository->getById($id);

 

                // get product by product sku

                $product = $productRepository->get($sku);

Posted in כללי | Tagged | Leave a comment

how to start learn magento 2

1- first install :

Continue reading

Posted in כללי | Tagged | Leave a comment

My first game in google play

http://play.google.com/store/apps/details?id=com.Asaf.MonkeyBanky

Posted in כללי | Tagged , | Leave a comment

How to use branch and trunk in svn

in the doc i explain on :

how to create branch

how to do merge from branch to trunk

how to do merge from trunk to branch

svn trunk and branch

Posted in כללי | Tagged , | Leave a comment

How to pass by reference to coroutine in unity

first – it can’t be done

second there is different solution that doing the job, it’s cal callback, we can pass callback to the coroutine, example :

class A

{

User user;

StartCoroutine(networkConnection.RequestLogin(userFromDb => this.user =              userFromDb));

}

class networkConnection

{

public IEnumerator RequestLogin(System.Action userFromDb)

{

//fetch data from DB and put in local variable “user “, and then …

userFromDb(user);

}

}

Continue reading

Posted in כללי | Tagged | Leave a comment

Source tree avoid problems when first install

when install this software(it’s gui tool to work with git or bitbucket) the wizard start and he ask you to enter the detail of your account in one of git or bitbucket, fill them !!

after that he ask you if you want to make your first clone then you can skip it.

when the software start go to..

Continue reading

Posted in כללי | Tagged , , | Leave a comment