Last active
October 17, 2017 09:52
-
-
Save ravixp/5f1833e1b47d51092edf8a1247582c33 to your computer and use it in GitHub Desktop.
Sample Coding in Magento 1.9. I type a good naming conversion for classes and IDs. I add the comments to the end of every closed tags. Simple and neat formatting for PHP if else conditions / for each loop, etc. I type coding the way for easy reading for designers/developers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| @Orginal Author: Ravi Panghat | |
| @Orginal Update Date: 12/01/2014 | |
| @Orginal Description: Setup the Product Page, layout, Product Image, Tabs | |
| @Last Author: Ravi Panghat | |
| @Last Update Date: 20/03/2016 | |
| @Last Update Description: The client Richard requests to add the product's brand logo image. Implemented the brand logos. | |
| */ ?> | |
| <?php $_helper = $this->helper('catalog/output'); ?> | |
| <?php $_product = $this->getProduct(); ?> | |
| <script type="text/javascript"> | |
| var optionsPrice = new Product.OptionsPrice(<?php echo $this->getJsonConfig() ?>); | |
| </script> | |
| <div id="messages_product_view"><?php echo $this->getMessagesBlock()->toHtml() ?></div><!-- /.messages_product_view--> | |
| <div class="product-view" itemscope itemtype="http://schema.org/Product"> | |
| <div class="product-essential clearfix"> | |
| <div class="row"> | |
| <form action="<?php echo $this->getSubmitUrl($_product, array('_secure' => $this->_isSecure())) ?>" method="post" id="product_addtocart_form"<?php if($_product->getOptions()): ?> enctype="multipart/form-data"<?php endif; ?>> | |
| <?php echo $this->getBlockHtml('formkey') ?> | |
| <input type="hidden" name="product" value="<?php echo $_product->getId() ?>" /> | |
| <input type="hidden" name="related_product" id="related-products-field" value="" /> | |
| <div class="product-img-box column-xs-12 column-sm-6 column-md-8"> | |
| <div class="product-name"> | |
| <h1><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></h1> | |
| </div><!-- /.product-name--> | |
| <?php echo $this->getChildHtml('media') ?> | |
| </div><!-- /.product-img-box--> | |
| <div class="column-xs-12 column-sm-6 column-md-4"> | |
| <?php | |
| $brandImage = Mage::helper('bubble_aop')->getAttributeOptionAdditionalImage($_product->getOwBrand()); | |
| $images = Mage::helper('bubble_aop')->getAttributeOptionAdditional2Images(); | |
| $imageOrLink = array_key_exists($_product->getOwBrand(), $images) ? $images[$_product->getOwBrand()] : ''; | |
| ?> | |
| <?php if ( $_product->getOwBrand() && $brandImage )) : ?> | |
| <div class="product-brand clearfix"> | |
| <?php if (!is_array(getimagesize($imageOrLink))): ?> | |
| <a href="<?php echo Mage::getUrl($imageOrLink) ?>"> | |
| <?php endif ?> | |
| <img class="img-responsive" src="<?php echo $brandImage ?>"> | |
| <?php if (!is_array(getimagesize($imageOrLink))): ?> | |
| </a> | |
| <?php endif ?> | |
| </div><!-- /.product-brand --> | |
| <?php endif; ?> | |
| <div class="product-shop clearfix"> | |
| <div class="product-name mobile-hidden clearfix"> | |
| <span class="h1" itemprop="name"><?php echo $_helper->productAttribute($_product, $_product->getName(), 'name') ?></span> | |
| </div><!-- /.product-name --> | |
| <meta itemprop="url" content="<?php echo $_product->getUrlModel()->getUrl($_product, array('_ignore_category'=>true)); ?>" /> | |
| <meta itemprop="image" content="<?php echo $_product->getImageUrl(); ?>" /> | |
| <meta itemprop="sku" content="<?php echo $this->htmlEscape($_product->getSku()); ?>"/> | |
| <meta itemprop="description" content="<?php echo strip_tags($_product->getDescription()); ?>" /> | |
| <link itemprop="itemCondition" href="http://schema.org/NewCondition"/> | |
| <div class="price-info clearfix"> | |
| <?php echo $this->getPriceHtml($_product); ?> | |
| <?php echo $this->getChildHtml('bundle_prices') ?> | |
| <?php echo $this->getTierPriceHtml() ?> | |
| </div><!-- /.price-info --> | |
| <div class="extra-info clearfix"> | |
| <?php echo $this->getReviewsSummaryHtml($_product, 'default', false)?> | |
| <?php echo $this->getChildHtml('product_type_availability'); ?> | |
| </div><!-- /.extra-info --> | |
| <div class="product-info-links clearfix"> | |
| <a class="anchor-link" href="#product-description"><?php echo $this->__('Description'); ?></a> | |
| <a class="anchor-link" href="#product-frame-details"><?php echo $this->__('Frame Details'); ?></a> | |
| <a class="anchor-link" href="#product-delivery-returns"><?php echo $this->__('Delivery & Returns'); ?></a> | |
| </div><!-- /.product-info-links --> | |
| <?php echo $this->getChildHtml('alert_urls') ?> | |
| <?php echo $this->getChildHtml('other');?> | |
| <?php if ($_product->isSaleable() && $this->hasOptions()):?> | |
| <?php echo $this->getChildChildHtml('container1', '', true, true) ?> | |
| <?php endif;?> | |
| <div class="add-to-cart-wrapper clearfix"> | |
| <?php echo $this->getChildHtml('product_type_data') ?> | |
| <?php echo $this->getChildHtml('extrahint') ?> | |
| <?php if (!$this->hasOptions()): ?> | |
| <div class="product-has-no-options add-to-box"> | |
| <?php if($_product->isSaleable()): ?> | |
| <?php echo $this->getChildHtml('addtocart') ?> | |
| <?php if( $this->helper('wishlist')->isAllow() || $_compareUrl=$this->helper('catalog/product_compare')->getAddUrl($_product)): ?> | |
| <span class="or"><?php echo $this->__('OR') ?></span> | |
| <?php endif; ?> | |
| <?php endif; ?> | |
| <?php echo $this->getChildHtml('addto'); ?> | |
| </div><!-- /.product-info-links --> | |
| <?php echo $this->getChildHtml('extra_buttons'); ?> | |
| <?php elseif (!$_product->isSaleable()): ?> | |
| <div class="product-has-no-stock add-to-box"> | |
| <?php echo $this->getChildHtml('addto'); ?> | |
| <?php //echo $this->getChildHtml('sharing') ?> | |
| </div><!-- /.product-has-no-stock --> | |
| <?php endif; ?> | |
| </div><!-- /.add-to-cart-wrapper --> | |
| <div class="product-has-options clearfix"> | |
| <?php if ($_product->isSaleable() && $this->hasOptions()):?> | |
| <?php echo $this->getChildChildHtml('container2', '', true, true) ?> | |
| <?php endif;?> | |
| </div><!-- /.product-has-options --> | |
| </div><!-- /.product-shop --> | |
| </div><!-- /.column-xs-12 --> | |
| </form> | |
| </div><!-- /.row --> | |
| </div><!-- /.product-essential --> | |
| <script type="text/javascript"> | |
| //<![CDATA[ | |
| var productAddToCartForm = new VarienForm('product_addtocart_form'); | |
| productAddToCartForm.submit = function(button, url) { | |
| if (this.validator.validate()) { | |
| var form = this.form; | |
| var oldUrl = form.action; | |
| if (url) { | |
| form.action = url; | |
| } | |
| var e = null; | |
| try { | |
| this.form.submit(); | |
| } catch (e) { | |
| } | |
| this.form.action = oldUrl; | |
| if (e) { | |
| throw e; | |
| } | |
| if (button && button != 'undefined') { | |
| button.disabled = true; | |
| } | |
| } | |
| }.bind(productAddToCartForm); | |
| productAddToCartForm.submitLight = function(button, url){ | |
| if(this.validator) { | |
| var nv = Validation.methods; | |
| delete Validation.methods['required-entry']; | |
| delete Validation.methods['validate-one-required']; | |
| delete Validation.methods['validate-one-required-by-name']; | |
| // Remove custom datetime validators | |
| for (var methodName in Validation.methods) { | |
| if (methodName.match(/^validate-datetime-.*/i)) { | |
| delete Validation.methods[methodName]; | |
| } | |
| } | |
| if (this.validator.validate()) { | |
| if (url) { | |
| this.form.action = url; | |
| } | |
| this.form.submit(); | |
| } | |
| Object.extend(Validation.methods, nv); | |
| } | |
| }.bind(productAddToCartForm); | |
| //]]> | |
| </script> | |
| <?php echo $this->getChildHtml('related_products'); ?> | |
| <?php $delivery_information = $this->getLayout()->createBlock('cms/block')->setBlockId('product_delivery_information')->toHtml(); ?> | |
| <?php $additional_attributes = $this->getChildHtml('additional') ?> | |
| <div class="product-info-box clearfix"> | |
| <div class="row"> | |
| <div class="column-xs-12 column-sm-8 column-md-8"> | |
| <div class="product-description-box" id="product-description"> | |
| <h2 class="product-info-title"> | |
| <?php echo $this->__('Description'); ?> | |
| </h2> | |
| <div class="product-info-content"> | |
| <?php if ($_product->getShortDescription()):?> | |
| <div class="short-description"> | |
| <div class="std"><?php echo $_helper->productAttribute($_product, nl2br($_product->getShortDescription()), 'short_description') ?></div> | |
| </div><!-- /.short-description --> | |
| <?php endif;?> | |
| <?php echo $_product->getDescription; ?> | |
| </div><!-- /.product-info-content --> | |
| </div><!-- /.product-description --> | |
| <?php if ($delivery_information): ?> | |
| <div class="product-delivery-info-box" id="product-delivery-returns"> | |
| <h2 class="product-info-title product-delivery-info-title"> | |
| <?php echo $this->__('Delivery & Returns'); ?> | |
| </h2> | |
| <div class="product-info-content product-delivery-content"> | |
| <?php echo $delivery_information; ?> | |
| </div><!-- /.product-info-content --> | |
| </div><!-- /.product-delivery-info-box --> | |
| <?php endif; ?> | |
| <?php echo $additional_attributes; ?> | |
| </div><!-- /.column-xs-12 --> | |
| </div><!-- /.row --> | |
| </div><!-- /.product-info-box --> | |
| </div><!-- /.product-view --> | |
| <?php echo $this->getChildHtml('upsell_products'); ?><?php echo $this->getChildHtml('product_additional_data') ?> | |
| <?php /* TODO - Ravi Panghat | |
| <div class="product-collateral"> | |
| <?php if ($detailedInfoGroup = $this->getChildGroup('detailed_info', 'getChildHtml')):?> | |
| <div class="collateral-tabs"> | |
| <?php foreach ($detailedInfoGroup as $alias => $html):?> | |
| <div class="tab"><span><?php echo $this->escapeHtml($this->getChildData($alias, 'title')) ?></span></div> | |
| <div class="tab-container"> | |
| <div class="tab-content"><?php echo $html ?></div> | |
| </div> | |
| <?php endforeach;?> | |
| </div> | |
| <?php endif; ?> | |
| </div> | |
| */ ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment