I am editing the invoice in Magento and wondered how I would start a new page ie. so that I can start adding content to page 2?
$pdf = new Zend_Pdf();
//use this line each time you want to create new page
$page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
$pdf->pages[] = $page;
You can use Mage_Sales_Model_Order_Pdf_Invoice::newPage() to add pages to an invoice PDF.
Related
I have created a Prestashop Backoffice module but on clicking module tab in menu , I am getting error enter image description here 404 page not found?
I want to create a template on clicking module tab and display some text there.
You need to add the entry of the back-office controller in the Menu. You can use the following code to add the controller in the tab:
For Prestashop 1.7:
$parentTab->name = array();
foreach (Language::getLanguages(true) as $lang) {
$parentTab->name[$lang['id_lang']] = $this->l('ShipRocket');
}
$parentTab->class_name = 'AdminShiprocket';
$parentTab->module = $this->name;
$parentTab->active = 1;
$parentTab->id_parent = Tab::getIdFromClassName('SELL');
$parentTab->icon = 'rocket';
$parentTab->add();
You have to use the controller=AdminShiprocketController in the URL which is wrong. You need to use controller=AdminShiprocket to render the controller.
Also, add the controller file in /modules/module_name/controllers/admin/.
The filename should be: AdminShiprocketController.php
I want to create a bundle products for my estore but the bundle product has more than 50 products
So i want to add carousel or slider to these product. I tried adding some sliders but it is not working??
Please suggest me with some ideas.
Got this code from inchoo, so should work
$bundled_product = Mage::getModel('catalog/product')->load(YOUR_BUNDLED_PRODUCT_ID);
$selectionCollection = $bundled_product->getTypeInstance(true)->getSelectionsCollection(
$bundled_product->getTypeInstance(true)->getOptionsIds($bundled_product), $bundled_product
);
$bundled_items = array();
foreach($selectionCollection as $option)
{
$bundled_items[] = $option->product_id;
}
print_r($bundled_items);
$bundled_items has all the product ids, so you can simple load the product, and get all the detailed info. So Simply provide the data as per the need of the carousel.
To load the product
Mage::getModel('catalog/product')->load(PUT_ID_HERE);
In Magento I'm using <?php if ($this->getIsHomePage()):?> to check if it's the main page or not but how would I check if the user is on a custompage? CMS Page Url Key game-store
To get the URL key / identifier of any CMS page in Magento, use the following bit of code.
<?php
$yourUrlKey = 'game-store';
$cmsPageUrlKey = Mage::getSingleton('cms/page')->getIdentifier();
if($yourUrlKey == $cmsPageUrlKey){
//do something here
}
?>
The above code will print your URL Key
Either
$model = Mage::getModel('cms/page')->load('game-store','identifier');
var_dump($model->getData());
var_dump($model->getPageId());
or
$model = Mage::getModel('cms/page')->getCollection()
->addFieldTofilter('identifier','game-store')
->getFirstItem();
var_dump($model->getData());
var_dump($model->getPageId());
should do it.
In magento by using this code:
$currentPageId =$this->getRequest()->getParam('page_id');
we can get the current page id.
But how can I get the page id of a particular page?
For example, I have a page with URL key about-fruit-store.
I want to get its page id. How can I get it?
Either
$model = Mage::getModel('cms/page')->load('about-fruit-store','identifier');
var_dump($model->getData());
var_dump($model->getPageId());
or
$model = Mage::getModel('cms/page')->getCollection()
->addFieldTofilter('identifier','about-fruit-store')
->getFirstItem();
var_dump($model->getData());
var_dump($model->getPageId());
should do it.
I'm designing a custom product page with a button that when clicked I need to have an alert come up with a "Yes" or "No" option.
If "Yes" is selected I then need the following to happen.
Add another product into the cart based on the products quantity i.e. between 1 & 2 items add product A between 3 & 4 Items product B, between 5 & 12 product C and so on.
Any idea of the best way to accomplish this?
It has to be a alert style popup (ajax popup preferred) cannot be a checkbox on the product page.
Thanks!
So I've come across a solution to my problem... I'm using a Simple Modal (That TheBlackBenzKid hinted me to) that I'm either going to call from a custom button or with the add to cart button. This in turn will redirect to a php page that will redirect to the cart. For the php page I'll just include the code to put a item into the cart from there anyone could figure out how to customize it to there own needs.
<?php
// Include Magento application (URL to Mage.php)
require_once ( "app/Mage.php" );
umask(0);
//specified quantity my own variable I'm using for quantities
$spqty = 9;
// Initialize Magento
Mage::app("default");
// You have two options here,
// "frontend" for frontend session or "adminhtml" for admin session
Mage::getSingleton("core/session", array("name" => "frontend"));
$session = Mage::getSingleton("customer/session");
// get the current Magento cart
$cart = Mage::getSingleton('checkout/cart');
if ($spqty <= 2) {
// insert item to cart where "98" is the product ID (NOT SKU!) Where "2" is the quantity
$cart->addProduct(98, array('qty' => 2));
} elseif ($spqty >= 4 ){
// you can add multiple products at the same time by adding this line multiple times
$cart->addProduct(96, array('qty' => 3));
}
// save the cart
$cart->save();
// very straightforward, set the cart as updated
Mage::getSingleton('checkout/session')->setCartWasUpdated(true);
// redirect to index.php
header("Location: index.php/checkout/cart");
I also found some of this information from this guys blog I'll link to the article
How to add a product from an external site into Magento
I'm happy to answer any questions on this...
This is not the best answer, but code to get you started:
You could make the cart function use:
<input type="button" onClick="javascript:nValidateForm();"/>
And your form code:
<form name="m2mform" id="m2mform" method="post" onSubmit="javascript:nValidateForm();">
And then just call an external JavaScript in your page XML headers and add it to cart so that JS file will always be checked and validate the popup.