Monday, September 19, 2016

Fatal error: Class Zend\Stdlib\Parameters contains 1 abstract method... magento 2

Fatal error: Class Zend\Stdlib\Parameters contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Serializable::unserialize) inC:\xampp\htdocs\magento2\vendor\zendframework\zend-stdlib\src\Parameters.php on line 14


Solution: To solve this solution, I have run following commands,
1. php bin/Magento setup:upgrade
2. php bin/Magento setup:static-content:deploy
3. php bin/Magento cache:clean
4. php bin/Magento cache:flush

I deleted files from Var folder as well I delete generation folder. I disable custom modules too.

Many common techniques which we try in our daily practice, I have tried but Finally, I found that it was not due to Magento's code or something. But it is due to XAMPP.

I stop apache and MySQL service and I restart both services again which fixed my problem and everything works perfectly now.

How to call helper class function in magento 2

$this->helper('[Vendor]\[Module]\Helper\[Helper Name]');

Thursday, June 9, 2016

Get first item or last item from the collection

$collection->getFirstItem() and $collection->getLastItem();

Database table for configurable product

catalog_product_relation
catalog_product_superlink_table

commonly used block types

core/template
page/html
page/html_head
page/html_header
page/html_footer
page/template_links
page/html_breadcrumbs
core/text_list
page/html_wrapper
page/switch
core/messages

Add an external javascript/css file to Magento

<action method="addJs"><script>js/custom.js</script></action>
<action method="addCss"><stylesheet>css/custom.css</stylesheet></action>
OR
<action method="addItem"><type>skin_js</type><name>js/custom.js</name></action>
<action method="addItem"><type>skin_css</type><name>css/custom. css</name></action>

fetch top 3 bestsellers products programmatically

Mage::getResourceModel('reports/product_collection')->addOrderedQty()->addAttributeToSelect('*')->setPage(1, 3)->load();

Wednesday, June 8, 2016

steps to increase the performance of magento


  1. Enable Gzip compression
  2. Combine external CSS/JS into one file
  3. Disable modules which are not used
  4. MySQL Query Caching
  5. Enable Magento caching
  6. Disable the Magento log
  7. Image Optimization

set different themes for logged in users or set different themes on runtime

 if(Mage::getSingleton('customer/session')->isLoggedIn())
{
Mage::getDesign()->setPackageName('packagename')->setTheme('themename');
}

Thursday, November 19, 2015

Get cms page url in magento

<?php
$pageid=1;
echo Mage::helper('cms/page')->getPageUrl($pageid); ?>

Or
In controller or .phtml file:
<?php echo $this->getUrl('whats_new');?>

or
<?php echo Mage::helper('cms/page')->getPageUrl('url_key'); ?>

Or
In CMS Page
{{store _direct="url_key"}}

Wednesday, November 4, 2015

Call Newsletter form anywhere in magento

<?php 
echo $this->getLayout()->createBlock('newsletter/subscribe')->setTemplate('newsletter/subscribe.phtml')->toHtml(); 
?>

Fatal error: Class Zend\Stdlib\Parameters contains 1 abstract method... magento 2

Fatal error: Class Zend\Stdlib\Parameters contains 1 abstract method and must therefore be declared abstract or implement the remaining met...