Posts

Showing posts from October, 2020

Magento 2 404 error for scripts and css

 Magento 2 404 error for scripts and css 1)  Please check mistakenly not deleted .htaccess file at pub/static path. 2) When Magento is not running on production mode , it will create symlinks for some static resource. So what to do is delete pub/static/frontend and pub/static/adminhtml   Alert : Do not delete .htaccess under pub/static/ folder.  3) Changing the behavior. Open up app/etc/di.xml and find the virtualType name="developerMaterialization" section. In that section one may find code item name="view_preprocessed" that needs to be modified or deleted. You can modify it by changing the contents from  Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink   to  Magento\Framework\App\View\Asset\MaterializationStrategy\Copy This should  have solve your problem with the symlink creation. If like efforts, Please share, comment and subscribe for future posts and inspire more.

How to use Zend log Magento 2

 To use Zend log use below code in any PHP file. $yourmessageString = 'Hey from magento zend log'; $yourmessageArray = ['Hey from magento zend log Array ']; $writer = new \Zend\Log\Writer\Stream(BP . ‘/var/log/custom.log’); $logger = new \Zend\Log\Logger(); $logger->addWriter($writer); $logger->info($yourmessageString); $logger->info(print_r($yourmessageArray,true)); //for array and objects

Knock out js Short hands

 Knock out JS short hand properties. You can use  1.  this.knockoutProperty /= value;  instead  this.knockoutProperty(this.knockoutProperty() / value) 2.   this.knockoutProperty *= value;  instead  this.knockoutProperty(this.knockoutProperty() * value) 3. this.knockoutProperty -= value;  instead  this.knockoutProperty(this.knockoutProperty() - value) 4.  this.knockoutProperty += value;  instead  this.knockoutProperty(this.knockoutProperty() + value) Please like , share and subscribe.