Doctrine Console Commands

Example doctrine console command: php vendor/bin/doctrine orm:generate-entities –help Available commands: dbal:import Import SQL file(s) directly to Database. dbal:run-sql Executes arbitrary SQL directly from the command…

View array content in twig

The dump function dumps information about a template variable. It can be used as an alternative to var_dump or print_r from php. This is mostly…

Magento – Categories Images

Get category image: <?php $_category = $this->getCurrentCategory(); $_imageUrl = $this->getImageUrl(); ?> Get category thumbnail: <?php $_category = $this->getCurrentCategory(); $_imageUrl = $this->getThumbnail(); ?>

PHP – SOAP sample

PHP simple SOAP sample SOAP server file (soapserver.php): <?php // Set a function in SOAP server file function hello($someone) { return “Hello ” . $someone…

Magento get child products for a configurable product

Magento get products childs for a configurable product // $currentProduct = $this->getProduct(); $configurable_products = Mage::getModel(‘catalog/product_type_configurable’)->setProduct($currentProduct); $products_collection = $configurable_products->getUsedProductCollection()->addAttributeToSelect(‘*’)->addFilterByRequiredOptions(); foreach($products_collection as $_product){ echo $_product->getId() . “:…

Magento – Show Quantity Box in Products List

In file ‘list.phtml’ file change the <button> line near line 108 from this: <?php if($_product->isSaleable()): ?> <button class=”form-button” onclick=”setLocation(‘<?php echo $this->getAddToCartUrl($_product) ?<‘)”>>span> <?php echo $this->__(‘Add…

Magento – use singleton database connection

Magento database connection write mode: $db = Mage::getSingleton(‘core/resource’)->getConnection(‘core_write’); Magento database connection read mode: $db = Mage::getSingleton(‘core/resource’)->getConnection(‘core_read’); Query model $result = $db->query(“SELECT * FROM tablename”); if…

Magento – custom block

Custom block (for CMS pages): {{block type=”core/template” name=”template_name” template=”mydir/mytemplate.phtml” }}