how can i fetch cart data from joomla session? - session

Hi I am working on a module where i have to fetch cart data from the session. For that I am use below mention code. I am able to fetch the data but all in one. Now my question is how do I get those data individually(product_id individually cart id individually etc)? Please guide me regarding this issue.
Code
$_data=unserialize($_SESSION['__vm']['vmcart']);
print_r($_data);

did you check the vm cart module? your solution seams to be there.
try :
foreach ($_data->products as $product){
//var_dump($product);
echo $product->virtuemart_product_id.' || '.$product->product_name.' || '.$product->product_price;
}

I got the solution with help of below mentioned code
$cart = VirtueMartCart::getCart(); //getting cart object
$cmpny=$cart->BT; // accessing cart's elements
foreach($cmpny as $key =>$data)
{
some usfull code
}

Related

bol.com api integration with laravel I need to get product details

here is the link which has been used
https://api.bol.com/retailer/public/Retailer-API/index.html
I have to get order details and single orders with offers but I need to get product details with an image.
I have read all the docs and understood that. I just need the get API of the product, not the post API.
This website gets the product from bol.com API. I need to get product details same like this website.
here is screenshot
anyone here who works on bol.com API.
please need help it's important.
thanks for advance
you need to build scrapper to fetch information from bol.com using crawler
we did as well,
please find on github this repo
"Ultimate Web Scraper Toolkit"
using url you can fetch images here but we fetching more information
function searchByURL($url){
$res = [];
$res['product_url']=$url;
$data = getCode($url);
// Product Title
$rows = $data[1]->Find("h1.page-heading span.u-mr--xs");
foreach ($rows as $row)
{
$res['title'] = strip_tags((string)$row);
}
// Product Image
$rows = $data[1]->Find("div.image-slot img");
foreach ($rows as $row)
{
$res['product_image'] = HTTP::ConvertRelativeToAbsoluteURL($data[0], $row->src);
}
}

How to get the list of attributes on frontend in Magento 2

I'm using Magento 2, when I try add product in Backend, in the Configurations tab, I have created Configuration and I saw there three attributes.
How can I get them in a module on frontend?
I see they are stored in eav_attribute table but I dont know which SQL can be do it, because it has no conditional column
Thank so much!
Use can use below code to get attribute in your module frontend.
$attribute = $objectManager->create('\Magento\Eav\Model\Config')->getAttribute('catalog_product', 'color');
$colorAttributeId= $attribute->getAttributeId();
foreach ($attribute->getSource()->getAllOptions(true) as $option) {
$colors[$option['value']] = strtolower($option['label']);
}
print_r($colors);

retrieve all products and their respective attributes using getAdditionalData in magento

I've been looking all over the web on how I would go about retrieving filtered products and then get their respective attributes using getAdditionalData. Here's what I do:
$_collectionProduct=Mage::getModel('catalog/product')
->getCollection()
->addAttributeToFilter('status', array('eq' =>1))
->addAttributeToFilter('attribute_set_id',9)
->addAttributeToSelect('*');
This works and retrieves all the filtered products. However, now I need their attributes so I am looping
foreach ($_collectionProduct as $products) {
$_additional = $product->getAdditionalData();
}
What happens is that $_additional returns NULL.
Another scenario I have tried is the following
foreach ($_collectionProduct as $_products) {
$product= Mage::getModel("catalog/product")->load($_product->getId());
$_additional = $product->getAdditionalData();
}
This example still displays NULL. Would really appreciate if somebody would have a solution to the dilemma. Thanks.
I actually figured out why it wasn't working. It appears that getAdditionalData() is not really attached to a specific product. The product view is calling this function from core file. The actual function I needed to use was getAttributes().

Magento 1.7 - getting cart items for a specific customer

I really need to check what products (or only if any) a specific customer has in cart.
I want to create a cron task to check if customer has opened cart older than for example 2 days and then send him a mail with reminder message. I've got an array with customers:
$collection = Mage::getModel('customer/customer')->getCollection()->addAttributeToSelect('*');
$customers = array();
foreach ($collection as $customer) {
$customers[] = $customer->toArray();
But for two days I can't find the way to check the cart items for each of them.
I tried:
foreach ($customers as $item) {
$quote = Mage::getModel('sales/quote')->loadByCustomer($item['entity_id']);
if ($quote) {
$collection = $quote->getItemsCollection(false);
}
else {
echo '<script type="text/javascript">alert("test")</script>';
}
print_r($collection);
foreach ($collection as $tmp)
echo $tmp->getQty();
}
I tried also many more but nothing work for me :/
I also don't know how to print returned items, every field in the array is protected.
Please help if You can or You only think You can ;) Google didn't help with it.
Thanks
I believe you are using Magento Community since Enterprise already has an abandoned cart reminder. If you have access to Enterprise you can find the code here: Enterprise_Reminder_Model_Rule_Condition_Cart::_prepareConditionsSql($customer, $website)
This method creates a raw sql using magento Resource read adapter and adds different conditions to verify if cart is abandoned or not you can see some of them below ( don't forget to check quote.updated_at )
$select = $this->getResource()->createSelect();
$select->from(array('quote' => $table), array(new Zend_Db_Expr(1)));
...
$select->where('quote.is_active = 1');
$select->where($this->_createCustomerFilter($customer, 'quote.customer_id'));
...
I hope this excerpt helps gives you a start, I don't know if I can post the code from Enterprise here.

Magento mass-assign products to category

As the title says,i need to mass-assign products to a category and from the admin i can only edit one product at a time; i dont know why it just doesnt work to mass add them from the "category products" tab in the category page.
Thats why i need another method that's fast,like using phpMyAdmin or something alike.
Any help?
Thanks in advance!
I created a simple script to do this outside of Magento. Be sure to test this first on a single product and make sure it looks as you'd expect.
// Load Magento
require_once 'path/to/app/Mage.php';
Mage::app();
// $productIds is an array of the products you want to modify.
// Create it however you want, I did it like this...
$productsIds = Mage::getModel('catalog/product')->getCollection()
->addAttributeToFilter('sku', array('like' => 'something'))
->getAllIds();
// Array of category_ids to add.
$newCategories = array(20);
foreach ($productIds as $id) {
$product = Mage::getModel('catalog/product')->load($id);
$product->setCategoryIds(
array_merge($product->getCategoryIds(), $newCategories)
);
$product->save();
}
If you wish to overwrite a product's existing categories, change array_merge(...) to just $newCategories.
I would shy away from tackling this problem from the database side of things. If you do go that direction make sure and take lots of backups and do it during low usage.
The following thread on the Magento forum identifies the very same problem. One poster recommends a raw sql approach with example. Again, I would be careful - make sure you take backups.
The answer I like best from the thread (posted by Magento MVP):
Go into the category you don’t want them in, find the product list.
Click the check boxes on the products you want to remove and select
delete from the little dropdown.
Now go into the category where you
do want them, go to the product list. Select the NO dropdown so it
shows items not in the category. You might have to do a selective
search to limit stuff and do it in a couple iterations. Click the
check boxes and tell it to add stuff.
You may as well do this using the magento API
This is the script I use for mass adding products. sku.txt contains one sku per line.
<?php
$wsdlUrl = "magento-root/index.php/api/soap/?wsdl";
$proxy = new SoapClient($wsdlUrl);
$sessionId = $proxy->login('apiuser', 'apipasswd');
$listOfDiscountedSKUFile = "sku.txt";
function readinFile($filePath)
{
$fp = fopen($filePath,'r') or exit("Unable to open file!");
$dataItems = array();
while(!feof($fp))
{
$dataItems[] = trim(fgets($fp));
}
fclose($fp);
var_dump($dataItems);
return $dataItems;
}
function addToCategory($sku,$categoryId)
{
global $proxy,$sessionId;
$proxy->call($sessionId, 'category.assignProduct', array($categoryId, $sku));
}
function IsNullOrEmptyString($question){
return (!isset($question) || trim($question)==='');
}
$categoryId = 82;//e.g.
$listOfSKU = readinFile($listOfDiscountedSKUFile);
foreach($listOfSKU as $sku)
{
addToCategory($sku,$category);
}
?>
I managed to resolve the problem with the following code :
$write = Mage::getSingleton('core/resource')->getConnection('core_write');
$x = 1171;
$y = 2000;
$categoryID = 4;
$productPosition = 0;
while($x <= $y) {
$write->query("REPLACE INTO `catalog_category_product` (`category_id`, `product_id`, `position`) VALUES ($categoryID, $x++, $productPosition)");
}
echo "The job is done";
?>
I hope the code is clear for everyone,if it's not,reply and i'll try to explain it.
#nachito : here it is.

Resources